Skip to content

fix: avoid stale autoload misses during upgrades#7893

Merged
vitormattos merged 18 commits into
mainfrom
fix/upgrade-autoload-migrations
Jul 13, 2026
Merged

fix: avoid stale autoload misses during upgrades#7893
vitormattos merged 18 commits into
mainfrom
fix/upgrade-autoload-migrations

Conversation

@vitormattos

@vitormattos vitormattos commented Jul 13, 2026

Copy link
Copy Markdown
Member

Summary

  • add regression coverage for same-process upgrade-time autoload misses cached by Composer
  • rebuild the current LibreSign Composer loader from Composer-generated metadata before migrations run
  • register the refresh as a pre-migration repair step so newly introduced migrations and their fresh dependencies stay loadable during the same upgrade request
  • rename the repair step to RefreshAutoloaderBeforeMigrations so the name matches the behavior

Fixes #7892.

Testing

  • composer test:unit -- --filter "UpgradeSafeAutoloaderTest|RefreshAutoloaderBeforeMigrationsTest"
  • composer cs:check

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
@github-project-automation github-project-automation Bot moved this to 0. Needs triage in Roadmap Jul 13, 2026
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
@vitormattos
vitormattos requested review from YvesCesar and Copilot July 13, 2026 17:49
@vitormattos

Copy link
Copy Markdown
Member Author

/backport to stable34

@vitormattos

Copy link
Copy Markdown
Member Author

/backport to stable33

@vitormattos

Copy link
Copy Markdown
Member Author

/backport to stable32

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses upgrade-time autoload failures where Composer can cache previous “class not found” misses within the same PHP process, causing newly introduced migration classes to be reported as “unknown” during upgrades. It introduces an app-level mitigation by rebuilding and re-registering LibreSign’s Composer loader immediately before migrations run, plus regression tests for the scenario.

Changes:

  • Add UpgradeSafeAutoloader to rebuild the app’s Composer\Autoload\ClassLoader from Composer-generated metadata and reload Composer “files” autoloaders.
  • Register a new pre-migration repair step RefreshAutoloaderBeforeMigrations in appinfo/info.xml to refresh the loader just before migrations execute.
  • Add unit tests to cover autoload refresh behavior and same-process upgrade-time autoload miss caching.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/php/Unit/Migration/UpgradeSafeAutoloaderTest.php Adds regression tests simulating same-process autoload miss caching and validating loader refresh behavior.
tests/php/Unit/Migration/RefreshAutoloaderBeforeMigrationsTest.php Adds unit test coverage for the new pre-migration repair step refreshing the current app loader.
lib/Migration/UpgradeSafeAutoloader.php Implements rebuilding/re-registering a fresh ClassLoader from Composer metadata and re-loading autoload “files”.
lib/Migration/RefreshAutoloaderBeforeMigrations.php Adds a pre-migration repair step that refreshes LibreSign’s autoloader before Nextcloud migrations run.
appinfo/info.xml Registers the new repair step under <pre-migration> to ensure it runs before migrations.

Comment thread tests/php/Unit/Migration/UpgradeSafeAutoloaderTest.php
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
@vitormattos
vitormattos merged commit 5cc1523 into main Jul 13, 2026
70 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 4. to release

Development

Successfully merging this pull request may close these issues.

Upgrading libresign does not find migration Version18002Date20260511000000

2 participants