{{ message }}
Repository navigation
[6.1] Fix Installer::setAdapter() backwards compatibility during J5 to J6 upgrade - #48673
Closed
tejaschavan724 wants to merge 1 commit into
Closed
tejaschavan724 wants to merge 1 commit into
tejaschavan724 wants to merge 1 commit into
Conversation
Contributor
3 tasks done
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.

Pull Request resolves #48530.
Summary of Changes
When upgrading from Joomla 5.4 to Joomla 6.1 (notably via CLI e.g.
php cli/joomla.php core:update), the Joomla 6 archive is extracted onto disk, which deploys the new Joomla 6libraries/src/Installer/Installer.php.During the finalization phase, the in-memory Joomla 5.4 updater (
administrator/components/com_joomlaupdate/src/Model/UpdateModel.phpline 946) invokes:In Joomla 5,
Adapter::setAdapter($name, &$adapter = null)accepted a single argument and resolved the adapter class by name.However, in Joomla 6 (#43792),
Installer::setAdapter($name, $adapter)made$adaptera required parameter with no default value.When the updater calls
setAdapter($name)with only one argument, PHP throws a fatal error:This PR makes
$adapteroptional ($adapter = null) inInstaller::setAdapter():$adapter === null:$this->adapters, it returnstrue.$this->classprefix . ucfirst($name) . 'Adapter') and registers it.$adapteris provided (object or class name string), it sets it as before.This ensures seamless backwards compatibility for transitions from Joomla 5 to Joomla 6 without breaking the new Joomla 6 architecture.
Testing Instructions
$installer->setAdapter('file')with a single argument succeeds without throwing anArgumentCountError.$installer->setAdapter('custom', CustomAdapter::class)or$installer->setAdapter('custom', $adapterObject)continues to work as expected.php cli/joomla.php core:update) and verify the update completes the finalisation phase without halting onsetAdapter().Actual result BEFORE applying this Pull Request
The update fails with:
Fatal error: Uncaught ArgumentCountError: Too few arguments to function Joomla\CMS\Installer\Installer::setAdapter(), 1 passed .../administrator/components/com_joomlaupdate/src/Model/UpdateModel.php on line 946 and exactly 2 expectedExpected result AFTER applying this Pull Request
The update completes successfully without argument count errors.
Link to documentations
Please select: