PR-5.1-dev Pending

User tests: Successful: Unsuccessful:

avatar roland-d
roland-d
26 Feb 2024

Summary of Changes

If you have a script.php in your extension which extends the Installerscript but also implements the InstallerScriptInterface you get an Internal Server Error because the preflight in the Installerscript does not match the function declaration in the InstallerScriptInterface.

Testing Instructions

This is a little hard :)

  1. Create a script.php to be used in an extension to be installed
  2. The script.php needs to contain this code
<?php
use Joomla\CMS\Installer\InstallerAdapter;
use Joomla\CMS\Installer\InstallerScript;
use Joomla\CMS\Installer\InstallerScriptInterface;

defined('_JEXEC') or die;

return new class () implements ServiceProviderInterface {
    public function register(Container $container)
    {
        $container->set(
            InstallerScriptInterface::class,
            new class ()  extends InstallerScript implements InstallerScriptInterface {
                public function install(InstallerAdapter $adapter): bool
                {
                    return true;
                }

                public function update(InstallerAdapter $adapter): bool
                {
                    return true;
                }

                public function uninstall(InstallerAdapter $adapter): bool
                {
                    return true;
                }

                public function preflight(string $type, InstallerAdapter $adapter): bool
                {
                    return true;
                }
                public function postflight(string $type, InstallerAdapter $adapter): bool
                {
                    return true;
                }
            }
        );
    }
};
  1. Add the script.php to your extension
  2. Install the extension
  3. Notice the Internal Server Error
  4. Apply the patch
  5. Install the extension
  6. Notice the extension installs as expected

Actual result BEFORE applying this Pull Request

You get an Internal Server Error

Expected result AFTER applying this Pull Request

The extension is installed

Link to documentations

Please select:

  • Documentation link for docs.joomla.org:

  • No documentation changes for docs.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

avatar roland-d roland-d - open - 26 Feb 2024
avatar roland-d roland-d - change - 26 Feb 2024
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 26 Feb 2024
Category Libraries
avatar laoneo
laoneo - comment - 27 Feb 2024

Is this not a bc break, as it would require that all extending classes , which do overwrite that function , need to be updated? That's why InstallerScript cannot implement the interface.

avatar roland-d
roland-d - comment - 28 Feb 2024

Thank you for the feedback. I will solve my issue in another way.

avatar roland-d roland-d - close - 28 Feb 2024
avatar roland-d roland-d - change - 28 Feb 2024
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2024-02-28 21:37:18
Closed_By roland-d
Labels Added: PR-5.1-dev

Add a Comment

Login with GitHub to post a comment