[4.4] File::delete() throws error and terminates installation/update/uninstall#42533
[4.4] File::delete() throws error and terminates installation/update/uninstall#42533laoneo merged 2 commits intojoomla:4.4-devfrom
Conversation
Before calling File::delete(), the file path gets checked for existence with the PHP build in function is_file(). Only if the provided path is an existing file, it gets deleted using File::delete().
@alikon The message you get with com_patchtester is a warning telling that a folder which should be deleted during the install/update is not existent. This gives you a warning, but is does not terminate the script. With non-existing files it is different: Deleting of non-existent folders is not scope of this PR since it "just" outputs you warning messages. In worst case you will get a huge number of messages telling all the different folders which could not be deleted. But the installation/update was still successful and the system is still healthy and usable. I updated the initial comment of this PR to show you the error you get before applying this PR. |
|
For all the testers... Prebuilt download packages of this PR are available here https://artifacts.joomla.org/drone/joomla/joomla-cms/4.4-dev/42533/downloads. |
|
I think we should rather fix the |
|
I have tested this item ✅ successfully on ccb0e59 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/42533. |
The problem was the |
|
@Elfangor93 i've got your point now |
|
I have tested this item ✅ successfully on ccb0e59 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/42533. |
|
RTC This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/42533. |
So for me is sounds more reasonable to add a delete function back to the CMS class, call the base class with a try and catch. Like that is the BC break fixed. Or? |
@laoneo Sorry I don’t get it. You want to change the code so it uses the CMS class again and that one shall call the framework class with a try catch? Sorry but that is unnecessarily complicated, and requiring that from this PR here is a perfect example of how to stop a good PR with no reason. P.S.: As far as I remember we want to come away from the CMS‘ filesystem library at all so we can throw it away one day, so using that again would be a step back. |
|
Ah..., forget what I said. I thought that the File::delete from the CMS got remove and we work directly on the fw class. But all what was done is to change the namespace. So fine for me. |
|
Sorry, for the noise. All good here. Thanks for the fix! |

With PR #40257 the
File::delete()method in the framework was changed. It now throws a PHP error if it is called on a non-existing file path.This behavior prevents installation, update and uninstall scripts of extensions from beeing executed correctly since the whole execution gets terminated as soon as
Joomla\CMS\Installertries to delete a file which does not exist anymore.Pull Request for Issue #42495.
Summary of Changes
All occurrences of
File::delete()inJoomla\CMS\Installerare first checked to see if the provided path exists and is a file by using the PHP built-in functionif (is_file()) {File::delete()}.Testing Instructions
Actual result BEFORE applying this Pull Request
Update terminates and a message appears stating
Joomla\Filesystem\File::delete: Failed deleting inaccessible file controller.phpandError installing componentAfter this unsuccessful update, uninstalling partially removed the component also does not work anymore.
It states
Component Uninstall: Can't uninstall. Please remove manually.andError uninstalling component.Expected result AFTER applying this Pull Request
Update runs through without warning or error for non-existing files.
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