[2.x] fix(extension manager): repair major-update detection and constraint relaxation - #4947
Open
karl-bullock wants to merge 2 commits into
Open
[2.x] fix(extension manager): repair major-update detection and constraint relaxation#4947karl-bullock wants to merge 2 commits into
karl-bullock wants to merge 2 commits into
Conversation
added 2 commits
August 17, 2026 02:37
The update check skips any package that is not an installed extension. flarum/core is not one, so it was dropped on every run, even though surfacing a new major of it is the stated purpose of the first composer outdated call, and both LastUpdateCheck::getNewMajorVersion() and the admin frontend read a flarum/core entry back out of that list.
ComposerJson::require('*', '*') tested Extension::nameToId($packageName),
which in the wildcard branch is always the literal '*'. That never resolves
to an extension, so every iteration continued and no constraint was ever
relaxed, while nameToId() emitted a warning per require entry. Test $p, the
package being iterated, and skip platform requirements that have no vendor
segment.
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.
Affected versions: based on
2.xatff36902(Application::VERSION=2.0.0-rc.6). Both defects are present there.The extension manager's major-update feature cannot complete, for any version, because of two independent defects in the same path. The second is masked by the first, so fixing either alone is not enough.
1.
flarum/coreis filtered out of the update checkCheckForUpdatesHandler::handle()skips every package that is not an installed extension:Extension::nameToId('flarum/core')isflarum-core, andflarum/coreis not aflarum-extensionpackage, sogetExtension()returns null and core is dropped on every run. Nothing forflarum/coreis ever written toupdates.installed, soLastUpdateCheck::getNewMajorVersion()returns null andMajorUpdateHandlerthrowsNoNewMajorVersionExceptionbefore doing any work. Over the API that is a409 no_new_major_version.This looks like an oversight rather than a deliberate exclusion, because the surrounding code is written to expect core in that list:
composer outdatedcall is made so major updates are visible, and that "That includes flarum/core itself"LastUpdateCheck::getNewMajorVersion()searchesupdates.installedfor aflarum/coreentryControlSectionState.formatCoreUpdate()filters the same list forflarum/coreand builds a pseudo-extension from it,MajorUpdaterrenderscoreUpdate['latest-major'], andExtensionCardhas a dedicatedisCorebranchAll of that is unreachable today.
2.
ComposerJson::require('*', '*')never relaxes anythingMajorUpdateHandler::updateComposerJson()sets every direct requirement to*and then pinsflarum/coreto the new major. The wildcard branch tests the wrong variable:In that branch
$packageNameis always the literal*.Extension::nameToId('*')never resolves to an extension, so every iterationcontinues and no constraint is ever changed. It also emits anUndefined array key 1warning per require entry, since*has no vendor segment.The result is that a major update would run
composer updatewithflarum/corepinned to the new major while every extension stayed on its old constraint, which is exactly the unresolvable state the upgrade guide's troubleshooting section tells people to fix by hand.Why this has not been reported through the UI
Updater.tsxonly rendersMajorUpdaterwhenisProductionReady(core.package['latest-major']), and that returns true only forstable. With no stable 2.0.0 released yet, the panel does not render for anrctarget regardless, so the two defects behind it have not been exercised from the interface. The API endpoint has no such gate, which is where the409shows up.Measured, before and after
On a Flarum 1.8.19 forum with the extension manager enabled, extensions pinned to
^1.8,minimum-stability: beta, PHP 8.4.24, Composer 2.10.2.composer outdated --format jsonreportsflarum/core 1.8.19 -> v2.0.0-rc.5 update-possiblein this state.Before:
After:
Scope, stated plainly
The runtime verification above was done against
v1.0.8, because that is the code a forum upgrading from 1.8 actually runs, and it is where this has a user-visible consequence today. Both files have the same defect verbatim on2.x, which is what this patch targets. If you would like the same fix on the1.xline so it reaches people upgrading from 1.8, I am happy to open that separately.extensions/package-manageris not listed inmonorepo_testsin.github/workflows/backend.yml, so CI does not exercise this extension. Enabling it needs two things first. Itstests/integration/setup.phpis the only one of the seventeen extensions here still requiring../../vendor/autoload.phprather than thephp-packages/testing/bootstrap/monorepo.phpbootstrap every other one uses. And the fixture inSetupComposer.phppinsflarum/coreto1.0.0, which current Composer declines to install because of published security advisories, socomposer test:setupfails before any test runs. I hit that on Composer 2.10.2, and this workflow installscomposer:v2. Happy to look at both separately if that is useful.