summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2014-07-07 19:36:41 +0200
committerMorris Jobke <hey@morrisjobke.de>2014-07-07 19:36:41 +0200
commitb2377129b6b51685010fc80f1410c6152ee9b7e5 (patch)
tree95b478b31f52f28290c4f317b21b5318d7d3feb2 /lib
parented9b9ba671131e356938627e6344064f190f5313 (diff)
parentbef093471933e434cafba69f1e50ad5308da6dd2 (diff)
downloadnextcloud-server-b2377129b6b51685010fc80f1410c6152ee9b7e5.tar.gz
nextcloud-server-b2377129b6b51685010fc80f1410c6152ee9b7e5.zip
Merge pull request #9494 from owncloud/issue/9490
[issues/9490] \OC::$WEBROOT is invalid when called from cron.php
Diffstat (limited to 'lib')
-rw-r--r--lib/base.php14
-rwxr-xr-xlib/private/request.php2
2 files changed, 12 insertions, 4 deletions
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
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';
}