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.
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.
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.
Joomla! 4.0.5
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.
Labels |
Added:
No Code Attached Yet
|
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2022-01-05 18:45:45 |
Closed_By | ⇒ | richard67 |
Please next time close your issue yourself when having made a PR to solve it. Thanks. Closing as having a pull request.
Please test #36570