From 677b2e79f1d261d6aa9352401c9bfe0809fa11d8 Mon Sep 17 00:00:00 2001 From: David Monllao Date: Thu, 21 Nov 2013 13:12:11 +0800 Subject: [PATCH] MDL-41592 general: Also checking the site path --- admin/tool/behat/cli/util.php | 16 ++++++++-------- lib/setuplib.php | 5 ++++- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/admin/tool/behat/cli/util.php b/admin/tool/behat/cli/util.php index 7423dc4315d..28c933a0e2f 100644 --- a/admin/tool/behat/cli/util.php +++ b/admin/tool/behat/cli/util.php @@ -93,6 +93,14 @@ ini_set('log_errors', '1'); // Getting $CFG data. require_once(__DIR__ . '/../../../../config.php'); +// When we use the utilities we don't know how the site +// will be accessed, so if neither $CFG->behat_switchcompletely or +// $CFG->behat_wwwroot are set we must think that the site will +// be accessed using the built-in server which is set by default +// to localhost:8000. We need to do this to prevent uses of the production +// wwwroot when the site is being installed / dropped... +$CFG->behat_wwwroot = behat_get_wwwroot(); + // Checking the integrity of the provided $CFG->behat_* vars // to prevent conflicts with production and phpunit environments. behat_check_config_vars(); @@ -125,14 +133,6 @@ if (!file_exists("$CFG->behat_dataroot/behattestdir.txt")) { testing_initdataroot($CFG->behat_dataroot, 'behat'); } -// When we use the utilities we don't know how the site -// will be accessed, so if neither $CFG->behat_switchcompletely or -// $CFG->behat_wwwroot are set we must think that the site will -// be accessed using the built-in server which is set by default -// to localhost:8000. We need to do this to prevent uses of the production -// wwwroot when the site is being installed / dropped... -$CFG->behat_wwwroot = behat_get_wwwroot(); - // Overrides vars with behat-test ones. $vars = array('wwwroot', 'prefix', 'dataroot'); foreach ($vars as $var) { diff --git a/lib/setuplib.php b/lib/setuplib.php index abda23d5b52..9aaf060590d 100644 --- a/lib/setuplib.php +++ b/lib/setuplib.php @@ -770,7 +770,10 @@ function initialise_fullme() { // Do not abuse this to try to solve lan/wan access problems!!!!! } else { - if (($rurl['host'] !== $wwwroot['host']) or (!empty($wwwroot['port']) and $rurl['port'] != $wwwroot['port'])) { + if (($rurl['host'] !== $wwwroot['host']) or + (!empty($wwwroot['port']) and $rurl['port'] != $wwwroot['port']) or + (strpos($rurl['path'], $wwwroot['path']) !== 0)) { + // Explain the problem and redirect them to the right URL if (!defined('NO_MOODLE_COOKIES')) { define('NO_MOODLE_COOKIES', true);