From 1675542df4a1cfb203dfcbe2393b559577043803 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 12 Sep 2016 15:51:33 +0200 Subject: [PATCH 1/2] Display an error when updating .htaccess failed --- core/Command/Maintenance/UpdateHtaccess.php | 10 +++++++--- lib/private/Setup.php | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/core/Command/Maintenance/UpdateHtaccess.php b/core/Command/Maintenance/UpdateHtaccess.php index 2185078620..89eeb7ccf5 100644 --- a/core/Command/Maintenance/UpdateHtaccess.php +++ b/core/Command/Maintenance/UpdateHtaccess.php @@ -38,8 +38,12 @@ class UpdateHtaccess extends Command { } protected function execute(InputInterface $input, OutputInterface $output) { - \OC\Setup::updateHtaccess(); - $output->writeln('.htaccess has been updated'); - return 0; + if (\OC\Setup::updateHtaccess()) { + $output->writeln('.htaccess has been updated'); + return 0; + } else { + $output->writeln('Error updating .htaccess file, not enough permissions?'); + return 1; + } } } diff --git a/lib/private/Setup.php b/lib/private/Setup.php index 3b3a57c3e9..2c7a287908 100644 --- a/lib/private/Setup.php +++ b/lib/private/Setup.php @@ -472,9 +472,10 @@ class Setup { if ($content !== '') { //suppress errors in case we don't have permissions for it - @file_put_contents($setupHelper->pathToHtaccess(), $htaccessContent.$content . "\n"); + return (bool) @file_put_contents($setupHelper->pathToHtaccess(), $htaccessContent.$content . "\n"); } + return false; } public static function protectDataDirectory() { From 4b26d7d86a6f08c4e2aabc86472c8133f36cf103 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 13 Sep 2016 10:50:58 +0200 Subject: [PATCH 2/2] Update docs --- lib/private/Setup.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/private/Setup.php b/lib/private/Setup.php index 2c7a287908..4c72fbc962 100644 --- a/lib/private/Setup.php +++ b/lib/private/Setup.php @@ -410,6 +410,7 @@ class Setup { /** * Append the correct ErrorDocument path for Apache hosts + * @return bool True when success, False otherwise */ public static function updateHtaccess() { $config = \OC::$server->getConfig(); @@ -418,7 +419,7 @@ class Setup { if(\OC::$CLI) { $webRoot = $config->getSystemValue('overwrite.cli.url', ''); if($webRoot === '') { - return; + return false; } $webRoot = parse_url($webRoot, PHP_URL_PATH); $webRoot = rtrim($webRoot, '/');