No Code Attached Yet
avatar pjdevries
pjdevries
5 Jan 2022

Steps to reproduce the issue

  • Install the attached library package in a clean Joomla! 4.0.x site,
  • Upgrade the library by installing the same package a second time.
  • Uninstall the library.

The attached package does nothing really useful, other than proving uninstallation of library packages is erroneous. It simply creates a text file named JPATH_LIBRARIES/lib_foo_script.txt, containing lines for the executed preflight() and postflight() methods in script.php with the performed installer action.

Expected result

File JPATH_LIBRARIES/lib_foo_script.txt to contain the following:

preflight: install
postflight: install
preflight: uninstall
postflight: uninstall
preflight: update
postflight: update
preflight: uninstall
postflight: uninstall

As can be seen, preflight() and postflight() methods are triggered both as part of the update process and during uninstall.

Actual result

File JPATH_LIBRARIES/lib_foo_script.txt to contain the following:

preflight: install
postflight: install
preflight: update
postflight: update

As can be seen, preflight() and postflight() methods are neither triggered as part of the update process nor during uninstall.

System information (as much as possible)

Joomla! 4.0.5

Additional comments

As can be seen, when uninstalling library packages, installer script.php methods are not executed. The problem is that during an uninstall, script.php is assumed in a different location than where it was copied during installation.

During installation, script.php is copied the the extension_root, i.e. the base directory of the library. See Joomla\CMS\Installer\Adapter\LibraryAdapter::finaliseInstall() (.../libraries/src/Installer/Adapter/LibraryAdapter.php, line 144):

$path['dest'] = $this->parent->getPath('extension_root') . '/' . $this->manifest_script;

During uninstall, script.php is looked for in in a manifests sub folder. See Joomla\CMS\Installer\Adapter\LibraryAdapter::setupUninstall() (.../libraries/src/Installer/Adapter/LibraryAdapter.php, line 376):

$this->parent->setPath('source', JPATH_MANIFESTS . '/libraries/' . $manifest->libraryname);

The problem also occurs during a library upgrade, because it's uninstalled first as part of the process.

I managed to get the expected result by replacing the above mentioned line with the setPath() in LibraryAdapter::setupUninstall() with the following:

$this->parent->setPath('source', $this->parent->getPath('extension_root'));

Not sure if it is the proper solution, but it does seem to solve the problem.

lib_foo.zip

avatar pjdevries pjdevries - open - 5 Jan 2022
avatar joomla-cms-bot joomla-cms-bot - change - 5 Jan 2022
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 5 Jan 2022
avatar pjdevries
pjdevries - comment - 5 Jan 2022

Please test #36570

avatar richard67 richard67 - change - 5 Jan 2022
Status New Closed
Closed_Date 0000-00-00 00:00:00 2022-01-05 18:45:45
Closed_By richard67
avatar richard67 richard67 - close - 5 Jan 2022
avatar richard67
richard67 - comment - 5 Jan 2022

Please next time close your issue yourself when having made a PR to solve it. Thanks. Closing as having a pull request.

Add a Comment

Login with GitHub to post a comment