Merge pull request #9494 from owncloud/issue/9490
[issues/9490] \OC::$WEBROOT is invalid when called from cron.php
This commit is contained in:
commit
b2377129b6
|
@ -41,16 +41,16 @@ $CONFIG = array(
|
||||||
/* Blacklist a specific file and disallow the upload of files with this name - WARNING: USE THIS ONLY IF YOU KNOW WHAT YOU ARE DOING. */
|
/* Blacklist a specific file and disallow the upload of files with this name - WARNING: USE THIS ONLY IF YOU KNOW WHAT YOU ARE DOING. */
|
||||||
"blacklisted_files" => array('.htaccess'),
|
"blacklisted_files" => array('.htaccess'),
|
||||||
|
|
||||||
/* The automatic hostname detection of ownCloud can fail in certain reverse proxy situations. This option allows to manually override the automatic detection. You can also add a port. For example "www.example.com:88" */
|
/* The automatic hostname detection of ownCloud can fail in certain reverse proxy and CLI/cron situations. This option allows to manually override the automatic detection. You can also add a port. For example "www.example.com:88" */
|
||||||
"overwritehost" => "",
|
"overwritehost" => "",
|
||||||
|
|
||||||
/* The automatic protocol detection of ownCloud can fail in certain reverse proxy situations. This option allows to manually override the protocol detection. For example "https" */
|
/* The automatic protocol detection of ownCloud can fail in certain reverse proxy and CLI/cron situations. This option allows to manually override the protocol detection. For example "https" */
|
||||||
"overwriteprotocol" => "",
|
"overwriteprotocol" => "",
|
||||||
|
|
||||||
/* The automatic webroot detection of ownCloud can fail in certain reverse proxy situations. This option allows to manually override the automatic detection. For example "/domain.tld/ownCloud". The value "/" can be used to remove the root. */
|
/* The automatic webroot detection of ownCloud can fail in certain reverse proxy and CLI/cron situations. This option allows to manually override the automatic detection. For example "/domain.tld/ownCloud". The value "/" can be used to remove the root. */
|
||||||
"overwritewebroot" => "",
|
"overwritewebroot" => "",
|
||||||
|
|
||||||
/* The automatic detection of ownCloud can fail in certain reverse proxy situations. This option allows to define a manually override condition as regular expression for the remote ip address. For example "^10\.0\.0\.[1-3]$" */
|
/* The automatic detection of ownCloud can fail in certain reverse proxy and CLI/cron situations. This option allows to define a manually override condition as regular expression for the remote ip address. For example "^10\.0\.0\.[1-3]$" */
|
||||||
"overwritecondaddr" => "",
|
"overwritecondaddr" => "",
|
||||||
|
|
||||||
/* A proxy to use to connect to the internet. For example "myproxy.org:88" */
|
/* A proxy to use to connect to the internet. For example "myproxy.org:88" */
|
||||||
|
|
14
lib/base.php
14
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] !== '/') {
|
if (OC::$WEBROOT != '' && OC::$WEBROOT[0] !== '/') {
|
||||||
OC::$WEBROOT = '/' . OC::$WEBROOT;
|
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
|
// search the 3rdparty folder
|
||||||
|
|
|
@ -95,7 +95,7 @@ class OC_Request {
|
||||||
* reverse proxies
|
* reverse proxies
|
||||||
*/
|
*/
|
||||||
public static function serverHost() {
|
public static function serverHost() {
|
||||||
if(OC::$CLI) {
|
if (OC::$CLI && defined('PHPUNIT_RUN')) {
|
||||||
return 'localhost';
|
return 'localhost';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue