User tests: Successful: Unsuccessful:
Pull Request resolves #48530.
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 6 libraries/src/Installer/Installer.php.
During the finalization phase, the in-memory Joomla 5.4 updater (administrator/components/com_joomlaupdate/src/Model/UpdateModel.php line 946) invokes:
$installer->setAdapter($installer->extension->type);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 $adapter a required parameter with no default value.
When the updater calls setAdapter($name) with only one argument, PHP throws a fatal error:
ArgumentCountError: Too few arguments to function Joomla\CMS\Installer\Installer::setAdapter(), 1 passed and exactly 2 expected
This PR makes $adapter optional ($adapter = null) in Installer::setAdapter():
$adapter === null:
$this->adapters, it returns true.$this->classprefix . ucfirst($name) . 'Adapter') and registers it.$adapter is 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.
$installer->setAdapter('file') with a single argument succeeds without throwing an ArgumentCountError.$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 on setAdapter().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 expected
The update completes successfully without argument count errors.
Please select: