From d2ce617561313edbde7427f308006be6a9577a48 Mon Sep 17 00:00:00 2001 From: Marc Date: Mon, 22 Dec 2025 12:06:49 +0100 Subject: [PATCH 1/2] fix: create .htaccess file in case it doesn't exist yet Currently, the updateHtaccess() function can't deal with a missing .htaccess file, it assumes at least an empty .htaccess file. In some cases, the file may be missing though, and this commit adds functionality for creating it when this edgecase occurs. Signed-off-by: Marc --- lib/private/Setup.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/private/Setup.php b/lib/private/Setup.php index ad1e59135d162..55090a9eff8aa 100644 --- a/lib/private/Setup.php +++ b/lib/private/Setup.php @@ -580,6 +580,15 @@ public static function updateHtaccess(): bool { $setupHelper = Server::get(Setup::class); + // Note: The .htaccess file also needs to exist, otherwise `is_writable()` + // will return false, even though the file could be written. + // This function writes the .htaccess file in that case. + if (!file_exists($setupHelper->pathToHtaccess())) { + if (!touch($setupHelper->pathToHtaccess())) { + return false; + } + } + if (!is_writable($setupHelper->pathToHtaccess())) { return false; } From bfbec605d0653007b44f644b940bc4bc9a8c4a22 Mon Sep 17 00:00:00 2001 From: Marc Date: Mon, 22 Dec 2025 12:18:06 +0100 Subject: [PATCH 2/2] fix: changed wording of error for occ maintenance:update:htaccess This adds a hint to the error message that file creation may also have failed. Signed-off-by: Marc --- core/Command/Maintenance/UpdateHtaccess.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/Command/Maintenance/UpdateHtaccess.php b/core/Command/Maintenance/UpdateHtaccess.php index 8ff10e800cdcc..84f70acbb7c2a 100644 --- a/core/Command/Maintenance/UpdateHtaccess.php +++ b/core/Command/Maintenance/UpdateHtaccess.php @@ -29,7 +29,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln('.htaccess has been updated'); return 0; } else { - $output->writeln('Error updating .htaccess file, not enough permissions, not enough free space or "overwrite.cli.url" set to an invalid URL?'); + $output->writeln('Error updating (or creating) .htaccess file, not enough permissions, not enough free space or "overwrite.cli.url" set to an invalid URL?'); return 1; } }