No Code Attached Yet
avatar Elfangor93
Elfangor93
11 Dec 2023

Steps to reproduce the issue

Try to delete a non-existent file by execute the following line within Joomla > 4.4:
$res = \Joomla\Filesystem\File::delete(JPATH_ROOT . 'test.php');

Expected result

$res = true

Actual result

PHP Error Joomla\Filesystem\File::delete: Failed deleting inaccessible file test.php

System information (as much as possible)

Wampserver v3.3.1 on Windows 10 (64bit)
Joomla v4.4.1
PHP v8.1.2
MySQL v5.7.37

Additional comments

The old delete method ($res = \Joomla\CMS\Filesystem\File::delete(JPATH_ROOT . 'test.php');) returns true when deleteing a non-existent file. With the new class \Joomla\Filesystem\File, a PHP Error is thrown instead. This BC break stops some extension installation scripts from beeing executed correctly.

Example: JoomGalleryfriends/JG4-dev#161

avatar Elfangor93 Elfangor93 - open - 11 Dec 2023
avatar joomla-cms-bot joomla-cms-bot - change - 11 Dec 2023
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 11 Dec 2023
avatar Elfangor93
Elfangor93 - comment - 11 Dec 2023

I propose eighter to make sure \Joomla\Filesystem\File::delete() returns true again when deleteing a non-existent file or change all occurrences of \Joomla\Filesystem\File::delete() within Joomla\CMS\Installer such that it outputs for example a warning like Trying to delete file "test.php" but file didn't exist. instead of throwing an error which end the whole execution and leave a half-installed extension behind.

What is your opinion on that?

avatar richard67
richard67 - comment - 11 Dec 2023

The change from the CMS to the Framework filesystem library was made with PR #40257 .

A simple and I personally think sufficient fix could be to wrap calls to File::delete() into an if (is_file(...)) like it is e.g. proposed here #42088 for 4.4-dev (and already done in 5.0-dev) for Joomla Update or at other places.

@Hackwar Any other ideas?

avatar alikon
alikon - comment - 11 Dec 2023

sufficient fix could be to wrap calls to File::delete() into an if (is_file(...)) like it is e.g. proposed here #42088 for 4.4-dev (and already done in 5.0-dev)

me too i think so

@Elfangor93 can you link an extension so we can do some tests ?

avatar alikon
alikon - comment - 11 Dec 2023

related to #42468

avatar Elfangor93
Elfangor93 - comment - 11 Dec 2023

can you link an extension so we can do some tests

We came across this issue when trying to update JoomGallery from version 3.6.2 to version 4.0.0. See JoomGalleryfriends/JG4-dev#161 (comment).

Steps to reproduce the error with JoomGallery

  1. Setup Joomla 3.10.12
  2. Install JoomGallery 3.6.2
  3. Update Joomla to 4.4.x using com_joomlaupdate
  4. Install JoomGallery 4.0.0-dev
avatar richard67 richard67 - close - 17 Dec 2023
avatar richard67 richard67 - change - 17 Dec 2023
Status New Closed
Closed_Date 0000-00-00 00:00:00 2023-12-17 13:03:04
Closed_By richard67
avatar richard67
richard67 - comment - 17 Dec 2023

Closing as having a pull request. See #42533 .

Add a Comment

Login with GitHub to post a comment