[6.1] Fix Installer::setAdapter() backwards compatibility during J5 to J6 upgrade by tejaschavan724 · Pull Request #48673 · joomla/joomla-cms · GitHub
Skip to content

[6.1] Fix Installer::setAdapter() backwards compatibility during J5 to J6 upgrade - #48673

Closed
tejaschavan724 wants to merge 1 commit into
joomla:6.1-devfrom
tejaschavan724:fix-installer-setadapter-migration
Closed

tejaschavan724 wants to merge 1 commit into
joomla:6.1-devfrom
tejaschavan724:fix-installer-setadapter-migration

Conversation

@tejaschavan724

@tejaschavan724 tejaschavan724 commented Oct 21, 2026 •

Copy link
Copy Markdown

Pull Request resolves #48530.

  • I read the Generative AI policy and my contribution is either not created with the help of AI or is compatible with the policy and GNU/GPL 2 or later.

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 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():

  • If $adapter === null:
    • If the adapter is already registered in $this->adapters, it returns true.
    • Otherwise, it resolves the class by conventional name ($this->classprefix . ucfirst($name) . 'Adapter') and registers it.
  • If $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.

Testing Instructions

  1. On a Joomla 6.1 instance, verify calling $installer->setAdapter('file') with a single argument succeeds without throwing an ArgumentCountError.
  2. Verify calling $installer->setAdapter('custom', CustomAdapter::class) or $installer->setAdapter('custom', $adapterObject) continues to work as expected.
  3. Test a Joomla 5.4 to 6.1 update via CLI (php cli/joomla.php core:update) and verify the update completes the finalisation phase without halting on setAdapter().

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 expected

Expected result AFTER applying this Pull Request

The update completes successfully without argument count errors.

Link to documentations

Please select:

  • No documentation changes for guide.joomla.org needed
  • No documentation changes for manual.joomla.org needed

@brianteeman

Copy link
Copy Markdown
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants