summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2016-04-20 22:00:44 +0200
committerLukas Reschke <lukas@owncloud.com>2016-04-20 22:00:44 +0200
commitcd299b853743fbc93511258390fe04bde2ceafad (patch)
treed35b68562954eef0afb5e3a1ace222e733979482
parent7e2a1656f9e9fbfda7835bf448a7c63100ab2378 (diff)
downloadnextcloud-server-cd299b853743fbc93511258390fe04bde2ceafad.tar.gz
nextcloud-server-cd299b853743fbc93511258390fe04bde2ceafad.zip
Write .htaccess also from CLI
The new updater as shipped with ownCloud 9.0.x invokes `occ` via `shell_exec`. This means that the `\OC::$CLI` code is used when updating. This removes the manual `.htaccess` modifications, effectively leading to the fact that URLs without index.php in it stop working. This also affects share URLs which could be considered a rather serious regression. - User installs 9.0.0 via web - User shares /s/1234 - User updates to 9.0.1 via ownCloud updater - Link to /s/1234 is broken, /index.php/s/1234 works
-rw-r--r--lib/private/setup.php22
1 files changed, 15 insertions, 7 deletions
diff --git a/lib/private/setup.php b/lib/private/setup.php
index 6303d0d47f3..d2f3802ebad 100644
--- a/lib/private/setup.php
+++ b/lib/private/setup.php
@@ -400,12 +400,21 @@ class Setup {
* Append the correct ErrorDocument path for Apache hosts
*/
public static function updateHtaccess() {
- // From CLI we don't know the defined web root. Thus we can't write any
- // directives into the .htaccess file.
+ $config = \OC::$server->getConfig();
+
+ // For CLI read the value from overwrite.cli.url
if(\OC::$CLI) {
- return;
+ $webRoot = $config->getSystemValue('overwrite.cli.url', '');
+ if($webRoot === '') {
+ return;
+ }
+ $webRoot = parse_url($webRoot, PHP_URL_PATH);
+ $webRoot = rtrim($webRoot, '/');
+ } else {
+ $webRoot = !empty(\OC::$WEBROOT) ? \OC::$WEBROOT : '/';
}
- $setupHelper = new \OC\Setup(\OC::$server->getConfig(), \OC::$server->getIniWrapper(),
+
+ $setupHelper = new \OC\Setup($config, \OC::$server->getIniWrapper(),
\OC::$server->getL10N('lib'), new \OC_Defaults(), \OC::$server->getLogger(),
\OC::$server->getSecureRandom());
@@ -413,13 +422,12 @@ class Setup {
$content = "#### DO NOT CHANGE ANYTHING ABOVE THIS LINE ####\n";
if(strpos($htaccessContent, $content) === false) {
//custom 403 error page
- $content.= "\nErrorDocument 403 ".\OC::$WEBROOT."/core/templates/403.php";
+ $content.= "\nErrorDocument 403 ".$webRoot."/core/templates/403.php";
//custom 404 error page
- $content.= "\nErrorDocument 404 ".\OC::$WEBROOT."/core/templates/404.php";
+ $content.= "\nErrorDocument 404 ".$webRoot."/core/templates/404.php";
// Add rewrite base
- $webRoot = !empty(\OC::$WEBROOT) ? \OC::$WEBROOT : '/';
$content .= "\n<IfModule mod_rewrite.c>";
$content .= "\n RewriteRule . index.php [PT,E=PATH_INFO:$1]";
$content .= "\n RewriteBase ".$webRoot;