Skip to content

Commit

Permalink
taking care of behat wwwroot
Browse files Browse the repository at this point in the history
  • Loading branch information
ferishili committed Dec 6, 2024
1 parent af6a5ec commit 46ee79b
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions classes/local/maintenance_class.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,14 +320,27 @@ public function can_access(string $method) {
*/
public function decide_access_bounce() {
global $CFG, $COURSE, $SITE;
$wwwroot = $CFG->wwwroot;
$wwwrootparsed = parse_url($wwwroot);
$iswebrequest = isset($_SERVER['REMOTE_ADDR']); // It is a web call when the REMOTE_ADDR is set in $_SERVER!

$isbahat = defined('BEHAT_SITE_RUNNING') && BEHAT_SITE_RUNNING;
$iscli = defined('CLI_SCRIPT') && CLI_SCRIPT;
$isphpunit = defined('PHPUNIT_TEST') && PHPUNIT_TEST;

$wwwroot = $CFG->wwwroot;

// Hanlde behat wwwroot.
if ($isbahat && empty($wwwroot)) {
$wwwroot = $CFG->behat_wwwroot;
}

$wwwrootparsed = parse_url($wwwroot);

// Make sure path exists in wwwrootparsed.
if (empty($wwwrootparsed) || !isset($wwwrootparsed['path'])) {
$wwwrootparsed['path'] = '';
}

$iswebrequest = isset($_SERVER['REMOTE_ADDR']); // It is a web call when the REMOTE_ADDR is set in $_SERVER!

// If it is a web request.
if ($iswebrequest && !$iscli && !$isphpunit) {
// We have to carefully decide whether to redirect back to the referer or the course page.
Expand Down

0 comments on commit 46ee79b

Please sign in to comment.