MDL-41592 general: Also checking the site path
authorDavid Monllao <davidm@moodle.com>
Thu, 21 Nov 2013 05:12:11 +0000 (13:12 +0800)
committerDavid Monllao <davidm@moodle.com>
Mon, 2 Dec 2013 06:18:10 +0000 (14:18 +0800)
admin/tool/behat/cli/util.php
lib/setuplib.php

index 7423dc4..28c933a 100644 (file)
@@ -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) {
index abda23d..9aaf060 100644 (file)
@@ -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);