From e8537afd60d2c5d37e48a99aca9e72394cc044dd Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 7 Jul 2014 14:39:06 +0200 Subject: Only overwrite serverHost when in unit tests The intention of the original commit 12f7cb87679453fa96c796df857b7e7193d4ee09 was to fix tests. But cron should always return a valid host not localhost. --- lib/private/request.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/private/request.php b/lib/private/request.php index 619eae3e9b5..5fd5b3a7197 100755 --- a/lib/private/request.php +++ b/lib/private/request.php @@ -95,7 +95,7 @@ class OC_Request { * reverse proxies */ public static function serverHost() { - if(OC::$CLI) { + if (OC::$CLI && defined('PHPUNIT_RUN')) { return 'localhost'; } -- cgit v1.2.3 From 5d3e1bc023d48bc080fa0a65dad120b7e2530867 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 7 Jul 2014 15:01:02 +0200 Subject: Only calculate the WEBROOT from scriptName if it contains $SUBURI If not we are most likely in CLI mode. However to be able to still generate valid URLs, we need to use the overwrite webroot instead. Fix #9490 --- lib/base.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/base.php b/lib/base.php index b526840a97d..840d9044711 100644 --- a/lib/base.php +++ b/lib/base.php @@ -117,10 +117,18 @@ class OC { } } - OC::$WEBROOT = substr($scriptName, 0, strlen($scriptName) - strlen(OC::$SUBURI)); + if (substr($scriptName, 0 - strlen(OC::$SUBURI)) === OC::$SUBURI) { + OC::$WEBROOT = substr($scriptName, 0, 0 - strlen(OC::$SUBURI)); - if (OC::$WEBROOT != '' and OC::$WEBROOT[0] !== '/') { - OC::$WEBROOT = '/' . OC::$WEBROOT; + if (OC::$WEBROOT != '' && OC::$WEBROOT[0] !== '/') { + OC::$WEBROOT = '/' . OC::$WEBROOT; + } + } else { + // The scriptName is not ending with OC::$SUBURI + // This most likely means that we are calling from CLI. + // However some cron jobs still need to generate + // a web URL, so we use overwritewebroot as a fallback. + OC::$WEBROOT = OC_Config::getValue('overwritewebroot', ''); } // search the 3rdparty folder -- cgit v1.2.3