From 5639c5675c858c907d74ef5b718f47ec04191ce5 Mon Sep 17 00:00:00 2001 From: Tuan Pham Ngoc Date: Wed, 15 Oct 2025 12:03:56 +0700 Subject: [PATCH 1/4] Fix installation error on Windows --- installation/src/Model/CleanupModel.php | 42 ++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/installation/src/Model/CleanupModel.php b/installation/src/Model/CleanupModel.php index e3e9b971e97b2..9994b8a8a2372 100644 --- a/installation/src/Model/CleanupModel.php +++ b/installation/src/Model/CleanupModel.php @@ -10,6 +10,7 @@ namespace Joomla\CMS\Installation\Model; +use Joomla\Filesystem\Exception\FilesystemException; use Joomla\Filesystem\File; use Joomla\Filesystem\Folder; @@ -33,15 +34,48 @@ class CleanupModel extends BaseInstallationModel */ public function deleteInstallationFolder() { - $return = Folder::delete(JPATH_INSTALLATION) && (!file_exists(JPATH_ROOT . '/joomla.xml') || File::delete(JPATH_ROOT . '/joomla.xml')); + // First, we try to delete the installation folder + try { + Folder::delete(JPATH_INSTALLATION); + } catch (FilesystemException $e) { + /** + * Windows quirk: The installation folder may fail to delete because + * index.php, though already deleted, remains locked by PHP until + * the request ends. If no subfolders and only that file is present, + * we can assume the deletion effectively successful and continue cleanup. + */ + if (PHP_OS_FAMILY == 'Windows') { + $files = Folder::files(JPATH_INSTALLATION); + $folders = Folder::folders(JPATH_INSTALLATION); + + if (count($folders) > 0 || count($files) > 1) { + return false; + } + } else { + return false; + } + } + + // Remove the file joomla.xml if in root folder if exists + if (file_exists(JPATH_ROOT . '/joomla.xml')) { + try { + File::delete(JPATH_ROOT . '/joomla.xml'); + } catch (FilesystemException $e) { + return false; + } + } // Rename the robots.txt.dist file if robots.txt doesn't exist - if ($return && !file_exists(JPATH_ROOT . '/robots.txt') && file_exists(JPATH_ROOT . '/robots.txt.dist')) { - $return = File::move(JPATH_ROOT . '/robots.txt.dist', JPATH_ROOT . '/robots.txt'); + if (!file_exists(JPATH_ROOT . '/robots.txt') && file_exists(JPATH_ROOT . '/robots.txt.dist')) { + try { + File::move(JPATH_ROOT . '/robots.txt.dist', JPATH_ROOT . '/robots.txt'); + } catch (FilesystemException $e) { + return false; + } } clearstatcache(true, JPATH_INSTALLATION . '/index.php'); - return $return; + return true; } } From dde7e41b981a626d6a6c9a007b869403e6b69c65 Mon Sep 17 00:00:00 2001 From: Tuan Pham Ngoc Date: Wed, 15 Oct 2025 12:39:46 +0700 Subject: [PATCH 2/4] CS --- installation/src/Model/CleanupModel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installation/src/Model/CleanupModel.php b/installation/src/Model/CleanupModel.php index 9994b8a8a2372..e1e3ccca20343 100644 --- a/installation/src/Model/CleanupModel.php +++ b/installation/src/Model/CleanupModel.php @@ -48,7 +48,7 @@ public function deleteInstallationFolder() $files = Folder::files(JPATH_INSTALLATION); $folders = Folder::folders(JPATH_INSTALLATION); - if (count($folders) > 0 || count($files) > 1) { + if (\count($folders) > 0 || \count($files) > 1) { return false; } } else { From ae4040f5d731d8899b9a8dfb2608c018422cb62e Mon Sep 17 00:00:00 2001 From: Tuan Pham Ngoc Date: Wed, 15 Oct 2025 13:53:33 +0700 Subject: [PATCH 3/4] Update installation/src/Model/CleanupModel.php Co-authored-by: Richard Fath --- installation/src/Model/CleanupModel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installation/src/Model/CleanupModel.php b/installation/src/Model/CleanupModel.php index e1e3ccca20343..522fbde477242 100644 --- a/installation/src/Model/CleanupModel.php +++ b/installation/src/Model/CleanupModel.php @@ -56,7 +56,7 @@ public function deleteInstallationFolder() } } - // Remove the file joomla.xml if in root folder if exists + // Remove file joomla.xml in root folder if it exists if (file_exists(JPATH_ROOT . '/joomla.xml')) { try { File::delete(JPATH_ROOT . '/joomla.xml'); From 77e58b5cfa086cc0faa25e075b03270a98f814c3 Mon Sep 17 00:00:00 2001 From: Tuan Pham Ngoc Date: Wed, 15 Oct 2025 13:53:40 +0700 Subject: [PATCH 4/4] Update installation/src/Model/CleanupModel.php Co-authored-by: Richard Fath --- installation/src/Model/CleanupModel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installation/src/Model/CleanupModel.php b/installation/src/Model/CleanupModel.php index 522fbde477242..0aad0cf12329d 100644 --- a/installation/src/Model/CleanupModel.php +++ b/installation/src/Model/CleanupModel.php @@ -44,7 +44,7 @@ public function deleteInstallationFolder() * the request ends. If no subfolders and only that file is present, * we can assume the deletion effectively successful and continue cleanup. */ - if (PHP_OS_FAMILY == 'Windows') { + if (PHP_OS_FAMILY === 'Windows') { $files = Folder::files(JPATH_INSTALLATION); $folders = Folder::folders(JPATH_INSTALLATION);