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

Web services: json_last_error_msg requires PHP 5.5, should not be in pre 3.2

XMLWordPrintable

    • MOODLE_30_STABLE
    • MOODLE_30_STABLE, MOODLE_31_STABLE
    • Hide

      1. In any course, create a Page
      2. In the Content of the page, switch to HTML mode and paste the following HTML:

      <form method="post" action="../../lib/ajax/service.php">
      <input type="submit" name="whatever" value="Submit invalid JSON to lib/ajax/service.php">
      </form>

      3. Save and display, then click the button.

      EXPECTED: The returned text should be an exception message in JSON format. The message inside this code should be:
      PHP 5.4: "Invalid json in request: 4"
      PHP 5.5+: "Invalid json in request: Syntax error" (no change)

      BEFORE FIX: Behaviour in PHP 5.5+ was identical, but in PHP 5.4, you typically got a blank screen response (and error in server logs).

      Show
      1. In any course, create a Page 2. In the Content of the page, switch to HTML mode and paste the following HTML: <form method="post" action="../../lib/ajax/service.php"> <input type="submit" name="whatever" value="Submit invalid JSON to lib/ajax/service.php"> </form> 3. Save and display, then click the button. EXPECTED: The returned text should be an exception message in JSON format. The message inside this code should be: PHP 5.4: "Invalid json in request: 4" PHP 5.5+: "Invalid json in request: Syntax error" (no change) BEFORE FIX: Behaviour in PHP 5.5+ was identical, but in PHP 5.4, you typically got a blank screen response (and error in server logs).

      lib/ajax/service.php includes a call to json_last_error_msg (if there is an error). This function requires PHP 5.5, resulting in error messages in the PHP log if called on a PHP 5.4 system.

      Latest Moodle requires newer PHP versions so no problem there, but this code should not be in supported 3.0 and 3.1 branches. I'll do a quick patch to take it out.

            quen Sam Marshall
            quen Sam Marshall
            Tim Hunt Tim Hunt
            Dan Poltawski Dan Poltawski
            Dan Poltawski Dan Poltawski
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.