Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-48430

Custom menu with non valid URL generates unrecoverable exception

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      -Edit custom_menu setting
      -Use the next text:

      MDL-48430|http:///moodle.org/
      

      -Save
      -Go to a page that shows the custom menu

      Show
      -Edit custom_menu setting -Use the next text: MDL-48430|http:///moodle.org/ -Save -Go to a page that shows the custom menu
    • Workaround:
      Hide

      In function convert_text_to_menu_nodes on outputcomponents.php
      Do a try catch in the line:

      $itemurl = new moodle_url($setting);
      

      try {
         $itemurl = new moodle_url($setting);
      } catch (Exception $e){
         $itemurl = null
      }
      

      Show
      In function convert_text_to_menu_nodes on outputcomponents.php Do a try catch in the line: $itemurl = new moodle_url($setting); try { $itemurl = new moodle_url($setting); } catch (Exception $e){ $itemurl = null }
    • Difficulty:
      Easy
    • Affected Branches:
      MOODLE_26_STABLE, MOODLE_28_STABLE
    • Fixed Branches:
      MOODLE_27_STABLE, MOODLE_28_STABLE
    • Pull Master Branch:
      MDL-48430_master

      Description

      Using a wrong url in custom menu can generate an Exception that cannot be solved without editing database or config file.

      This is the traceback of 2.6

      Debug info: 
      Error code: invalidurl
      Stack trace:
      line 355 of /lib/weblib.php: moodle_exception thrown
      line 2808 of /lib/outputcomponents.php: call to moodle_url->__construct()
      line 2743 of /lib/outputcomponents.php: call to custom_menu::convert_text_to_menu_nodes()
      ....
      

      This is caused becase parse_url in the construction of moodle_url returns false.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                12/Jan/15