diff options
author | Daniel Kesselberg <mail@danielkesselberg.de> | 2018-09-10 22:33:35 +0200 |
---|---|---|
committer | Daniel Kesselberg <mail@danielkesselberg.de> | 2018-09-10 22:33:35 +0200 |
commit | 62c03beb1d2dc133542c088e6c72b201211ccfba (patch) | |
tree | 50b33ce5f4cfda5b120df995f7aca4db81c34718 /lib/private/Setup.php | |
parent | 210b0f092f93fa30f5c3542f684e55cc3ba5532f (diff) | |
download | nextcloud-server-62c03beb1d2dc133542c088e6c72b201211ccfba.tar.gz nextcloud-server-62c03beb1d2dc133542c088e6c72b201211ccfba.zip |
Extract logic for webroot into method and add test
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
Diffstat (limited to 'lib/private/Setup.php')
-rw-r--r-- | lib/private/Setup.php | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/lib/private/Setup.php b/lib/private/Setup.php index 25e0b4d8817..a31d746a062 100644 --- a/lib/private/Setup.php +++ b/lib/private/Setup.php @@ -431,16 +431,16 @@ class Setup { } /** - * Append the correct ErrorDocument path for Apache hosts - * @return bool True when success, False otherwise + * Find webroot from config + * + * @param SystemConfig $config + * @return bool|string */ - public static function updateHtaccess() { - $config = \OC::$server->getSystemConfig(); - + public static function findWebRoot(SystemConfig $config) { // For CLI read the value from overwrite.cli.url - if(\OC::$CLI) { + if (\OC::$CLI) { $webRoot = $config->getValue('overwrite.cli.url', ''); - if($webRoot === '') { + if ($webRoot === '') { return false; } $webRoot = parse_url($webRoot, PHP_URL_PATH); @@ -452,6 +452,19 @@ class Setup { $webRoot = !empty(\OC::$WEBROOT) ? \OC::$WEBROOT : '/'; } + return $webRoot; + } + + /** + * Append the correct ErrorDocument path for Apache hosts + * + * @return bool True when success, False otherwise + * @throws \OCP\AppFramework\QueryException + */ + public static function updateHtaccess() { + $config = \OC::$server->getSystemConfig(); + $webRoot = self::findWebRoot($config); + $setupHelper = new \OC\Setup( $config, \OC::$server->getIniWrapper(), @@ -467,10 +480,10 @@ class Setup { $htaccessContent = explode($content, $htaccessContent, 2)[0]; //custom 403 error page - $content.= "\nErrorDocument 403 ".$webRoot."/"; + $content .= "\nErrorDocument 403 " . $webRoot . '/'; //custom 404 error page - $content.= "\nErrorDocument 404 ".$webRoot."/"; + $content .= "\nErrorDocument 404 " . $webRoot . '/'; // Add rewrite rules if the RewriteBase is configured $rewriteBase = $config->getValue('htaccess.RewriteBase', ''); |