Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge branch 'MDL-29805-23' of git://github.com/mouneyrac/moodle into…

… MOODLE_23_STABLE
  • Loading branch information...
commit 1b39edd66227e4dd517b4ca105527b1ef4033e35 2 parents 09fc0fd + 22e9de0
Sam Hemelryk samhemelryk authored

Showing 3 changed files with 20 additions and 3 deletions. Show diff stats Hide diff stats

  1. +1 0  lang/en/error.php
  2. +18 3 lib/setuplib.php
  3. +1 0  login/token.php
1  lang/en/error.php
@@ -432,6 +432,7 @@
432 432 $string['remotedownloaderror'] = 'Download of component to your server failed, please verify proxy settings, PHP cURL extension is highly recommended.<br /><br />You must download the <a href="{$a->url}">{$a->url}</a> file manually, copy it to "{$a->dest}" in your server and unzip it there.';
433 433 $string['remotedownloadnotallowed'] = 'Download of components to your server isn\'t allowed (allow_url_fopen is disabled).<br /><br />You must download the <a href="{$a->url}">{$a->url}</a> file manually, copy it to "{$a->dest}" in your server and unzip it there.';
434 434 $string['reportnotavailable'] = 'This type of report is only available for the site course';
  435 +$string['requirecorrectaccess'] = 'Invalid url or port.';
435 436 $string['requireloginerror'] = 'Course or activity not accessible.';
436 437 $string['restorechecksumfailed'] = 'Some problem happened with the restore information stored in your session. Please check your PHP memory/DB package size limits. Restore stopped.';
437 438 $string['restore_path_element_missingmethod'] = 'Restore method {$a} is missing. It must be defined by a developer.';
21 lib/setuplib.php
@@ -356,7 +356,7 @@ function default_exception_handler($ex) {
356 356 }
357 357
358 358 if (is_early_init($info->backtrace)) {
359   - echo bootstrap_renderer::early_error($info->message, $info->moreinfourl, $info->link, $info->backtrace, $info->debuginfo);
  359 + echo bootstrap_renderer::early_error($info->message, $info->moreinfourl, $info->link, $info->backtrace, $info->debuginfo, $info->errorcode);
360 360 } else {
361 361 try {
362 362 if ($DB) {
@@ -370,7 +370,7 @@ function default_exception_handler($ex) {
370 370 // so we just print at least something instead of "Exception thrown without a stack frame in Unknown on line 0":-(
371 371 if (CLI_SCRIPT or AJAX_SCRIPT) {
372 372 // just ignore the error and send something back using the safest method
373   - echo bootstrap_renderer::early_error($info->message, $info->moreinfourl, $info->link, $info->backtrace, $info->debuginfo);
  373 + echo bootstrap_renderer::early_error($info->message, $info->moreinfourl, $info->link, $info->backtrace, $info->debuginfo, $info->errorcode);
374 374 } else {
375 375 echo bootstrap_renderer::early_error_content($info->message, $info->moreinfourl, $info->link, $info->backtrace, $info->debuginfo);
376 376 $outinfo = get_exception_info($out_ex);
@@ -761,6 +761,20 @@ function initialise_fullme() {
761 761 if (!defined('NO_MOODLE_COOKIES')) {
762 762 define('NO_MOODLE_COOKIES', true);
763 763 }
  764 + // The login/token.php script should call the correct url/port.
  765 + if (defined('REQUIRE_CORRECT_ACCESS')) {
  766 + $wwwrootport = empty($wwwroot['port'])?'':$wwwroot['port'];
  767 + $calledurl = $rurl['host'];
  768 + if (!empty($rurl['port'])) {
  769 + $calledurl .= ':'. $rurl['port'];
  770 + }
  771 + $correcturl = $wwwroot['host'];
  772 + if (!empty($wwwrootport)) {
  773 + $correcturl .= ':'. $wwwrootport;
  774 + }
  775 + throw new moodle_exception('requirecorrectaccess', 'error', '', null,
  776 + 'You called ' . $calledurl .', you should have called ' . $correcturl);
  777 + }
764 778 redirect($CFG->wwwroot, get_string('wwwrootmismatch', 'error', $CFG->wwwroot), 3);
765 779 }
766 780 }
@@ -1497,7 +1511,7 @@ public static function early_error_content($message, $moreinfourl, $link, $backt
1497 1511 * @param string $debuginfo extra information for developers
1498 1512 * @return string
1499 1513 */
1500   - public static function early_error($message, $moreinfourl, $link, $backtrace, $debuginfo = null) {
  1514 + public static function early_error($message, $moreinfourl, $link, $backtrace, $debuginfo = null, $errorcode = null) {
1501 1515 global $CFG;
1502 1516
1503 1517 if (CLI_SCRIPT) {
@@ -1525,6 +1539,7 @@ public static function early_error($message, $moreinfourl, $link, $backtrace, $d
1525 1539 $e->stacktrace = format_backtrace($backtrace, true);
1526 1540 }
1527 1541 }
  1542 + $e->errorcode = $errorcode;
1528 1543 @header('Content-Type: application/json; charset=utf-8');
1529 1544 echo json_encode($e);
1530 1545 return;
1  login/token.php
@@ -22,6 +22,7 @@
22 22 */
23 23
24 24 define('AJAX_SCRIPT', true);
  25 +define('REQUIRE_CORRECT_ACCESS', true);
25 26 define('NO_MOODLE_COOKIES', true);
26 27
27 28 require_once(dirname(dirname(__FILE__)) . '/config.php');

0 comments on commit 1b39edd

Please sign in to comment.
Something went wrong with that request. Please try again.