Repository navigation
fix(apphost): register OpenRegister's autoloader before referencing AppHost (gate-64 / ADR-040) - #288
Merged
Merged
Conversation
…ppHost Nextcloud registers apps in sorted order: OC_App::getEnabledApps() does sort($apps) and Coordinator::registerApps() walks that list calling OC_App::registerAutoloading($appId, $path) and then $app->register() for one app at a time, so every app registers before the PSR-4 prefix of every alphabetically-later app exists. `scholiq` sorts after `openregister`, so OCA\OpenRegister\ happens to be autoloadable here today — by alphabet, not by design. Scholiq depends on that accident more sharply than most: its Bootstrap::register() call is UNGUARDED, so the moment the ordering stops holding the resulting \Error aborts the WHOLE of Application::register(). Coordinator catches it, logs an 'emergency' and continues, leaving Scholiq enabled and serving with ServiceOverrideRegistrar and EventListenerWiring silently never run. Fix: register OpenRegister's prefix ourselves first. registerAutoloading() touches only the autoloader and is idempotent, so on the current ordering this costs nothing. IAppManager::loadApp() is deliberately NOT used: it marks OpenRegister loaded and calls Coordinator::bootApp(), booting it before its own register() has run. Caught by hydra gate-64 (apphost-autoload-prelude), ADR-040. Unblocks the gate-64 failure on the hydra-gates v1.5.0 bump PR (#287).
Contributor
Quality Report — ConductionNL/scholiq @
|
| Check | PHP | Vue | Security | License | Tests |
|---|---|---|---|---|---|
| lint | ✅ | ||||
| phpcs | ✅ | ||||
| phpmd | ❌ | ||||
| psalm | ❌ | ||||
| phpstan | ✅ | ||||
| phpmetrics | ✅ | ||||
| eslint | ✅ | ||||
| stylelint | ✅ | ||||
| build | ✅ | ||||
| check-specs | ✅ | ||||
| composer | ✅ | ✅ 100/100 | |||
| npm | ✅ | ✅ 750/750 | |||
| PHPUnit | ❌ | ||||
| Newman | ⏭️ | ||||
| Playwright | ⏭️ | ||||
| Hydra gates | ❌ |
Quality workflow — 2026-08-06 08:05 UTC
Download the full PDF report from the workflow artifacts.
Two CI findings on the prelude, both real: 1. psalm UndefinedClass on \OC_App. It is Nextcloud's server-private legacy bootstrap class, absent from nextcloud/ocp, and there is no OCP interface for registering another app's autoloader. Declared as a suppressed referencedClass in psalm.xml, the same way doriath declares it. 2. The coverage ratchet. `return true` after the call plus `return false` in the catch gave the method a branch that NO environment can exercise both sides of — whichever runs, the other is dead in that run — so the class could never reach full line coverage. No caller ever consumed the return value either: what callers depend on is the class_exists() guard that follows the call. The method is now void with a single statement in the try and a comment-only catch, so every executable line runs in every environment. The tests now assert the two things that are actually observable: that control returns to the caller at all (a Throwable escaping would fail the test, and in production would abort the whole register()), and that a second call does not stack another autoloader. phpmd StaticAccess on the new composition-root call is documented on the calling method rather than baselined.
…narios The two scenarios added for the ADR-040 prelude each carried an '@e2e exclude'. An exclusion is not evidence, and neither behaviour is reachable from a browser or an HTTP client: both live in the app-registration phase, which completes before the first request is dispatched, and the absent-OpenRegister path cannot be set up on an instance that needs OpenRegister to serve the app at all. Stated in the requirement prose instead, naming the unit test that does assert them (tests/Unit/AppInfo/OpenRegisterAutoloaderTest.php). No scenario is declared, so none is excluded.
Contributor
Quality Report — ConductionNL/scholiq @
|
| Check | PHP | Vue | Security | License | Tests |
|---|---|---|---|---|---|
| lint | ✅ | ||||
| phpcs | ✅ | ||||
| phpmd | ✅ | ||||
| psalm | ✅ | ||||
| phpstan | ✅ | ||||
| phpmetrics | ✅ | ||||
| eslint | ✅ | ||||
| stylelint | ✅ | ||||
| build | ✅ | ||||
| check-specs | ✅ | ||||
| composer | ✅ | ✅ 100/100 | |||
| npm | ✅ | ✅ 750/750 | |||
| PHPUnit | ❌ | ||||
| Newman | ⏭️ | ||||
| Playwright | ⏭️ | ||||
| Hydra gates | ❌ |
Quality workflow — 2026-08-06 08:18 UTC
Download the full PDF report from the workflow artifacts.
Contributor
Quality Report — ConductionNL/scholiq @
|
| Check | PHP | Vue | Security | License | Tests |
|---|---|---|---|---|---|
| lint | ✅ | ||||
| phpcs | ✅ | ||||
| phpmd | ✅ | ||||
| psalm | ✅ | ||||
| phpstan | ✅ | ||||
| phpmetrics | ✅ | ||||
| eslint | ✅ | ||||
| stylelint | ✅ | ||||
| build | ✅ | ||||
| check-specs | ✅ | ||||
| composer | ✅ | ✅ 100/100 | |||
| npm | ✅ | ✅ 750/750 | |||
| PHPUnit | ❌ | ||||
| Newman | ⏭️ | ||||
| Playwright | ⏭️ | ||||
| Hydra gates | ❌ |
Quality workflow — 2026-08-06 08:25 UTC
Download the full PDF report from the workflow artifacts.
The coverage ratchet was right and the code was wrong. Clover for scholiq shows it exactly: line 100 (the registerAutoloading call) count=2, line 101 (the catch) count=0. The catch was never entered — because every instance this suite runs on HAS OpenRegister installed, so getAppPath() never throws. The never-rethrow branch, which is the entire reason this class exists, had never once been executed by a test. register() now takes an optional app id. Production callers pass nothing and get 'openregister'; the new test passes an id that cannot resolve, so getAppPath() throws and the catch runs. The literal stays AT the registerAutoloading call site rather than becoming a signature default, so it remains visible to a reader and to hydra gate-64, which reads that call's arguments. The new test asserts something real rather than merely not throwing: a prelude whose app cannot be resolved must leave spl_autoload_functions() untouched.
Contributor
Quality Report — ConductionNL/scholiq @
|
| Check | PHP | Vue | Security | License | Tests |
|---|---|---|---|---|---|
| lint | ✅ | ||||
| phpcs | ✅ | ||||
| phpmd | ✅ | ||||
| psalm | ✅ | ||||
| phpstan | ✅ | ||||
| phpmetrics | ✅ | ||||
| eslint | ✅ | ||||
| stylelint | ✅ | ||||
| build | ✅ | ||||
| check-specs | ✅ | ||||
| composer | ✅ | ✅ 100/100 | |||
| npm | ✅ | ✅ 750/750 | |||
| PHPUnit | ✅ | ||||
| Newman | ⏭️ | ||||
| Playwright | ⏭️ | ||||
| Hydra gates | ✅ |
Quality workflow — 2026-08-06 08:42 UTC
Download the full PDF report from the workflow artifacts.
This was referenced Aug 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The defect
Nextcloud registers apps in sorted order:
OC_App::getEnabledApps()doessort($apps)andCoordinator::registerApps()walks that list callingOC_App::registerAutoloading($appId, $path)and then$app->register()one app at a time. Every app'sregister()therefore runs before the PSR-4 prefix of every alphabetically-later app exists.scholiqsorts afteropenregister, soOCA\OpenRegister\happens to be autoloadable here today — by alphabet, not by design. Scholiq leans on that accident harder than most apps do: itsBootstrap::register()call is unguarded. The moment the ordering stops holding — an app id change, a multi-apps_pathsinstall, this composition root moving into a package that sorts earlier — the resulting\Erroraborts the whole ofApplication::register().Coordinator::registerApps()catches the Throwable, logs anemergencyandcontinues, so Scholiq would stay enabled and keep serving withServiceOverrideRegistrarandEventListenerWiringsilently never run.hydra gate-64
apphost-autoload-preludeflags this, and it is the one failure on the hydra-gates v1.5.0 bump PR #287.The fix
lib/AppInfo/OpenRegisterAutoloader.php— register OpenRegister's PSR-4 prefix ourselves before touching anyOCA\OpenRegister\…name:OC_App::registerAutoloading()touches only the autoloader and is idempotent, so on the current ordering this call costs nothing.IAppManager::loadApp('openregister')is deliberately not used: it marks OpenRegister loaded and callsCoordinator::bootApp(), booting it before its ownregister()has run.register()failure it exists to prevent.It lives in its own class so that "never throws" contract is reachable from a unit test:
Applicationcannot be constructed without a Nextcloud DI container.Verification
OpenRegisterAutoloader.phpfrom the same tree puts it back to FAIL.tests/Unit/AppInfo/OpenRegisterAutoloaderTest.phpasserts the never-throws and idempotence contracts.With this merged, #287 (
hydra-gates-ref → v1.5.0) should go green.Spec: new requirement in
openspec/specs/apphost-adoption/spec.md.Ref: ADR-040, hydra-gates gate-64 (ConductionNL/.github#174).