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

Malformed question pluginfile requests cause a PHP warning

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.7.5, 2.8.3
    • Fix Version/s: 2.7.8, 2.8.6
    • Component/s: Questions
    • Labels:
    • Testing Instructions:
      Hide
      1. Save the attached test.php into the root of your Moodle.
      2. Visit it.
      3. Right click on the broken image, and do 'View image' (or whatever your brower calls it.)
      4. Note that the image URL looks like https://example.com/moodle/pluginfile.php/1/question/questiontext/404LJ4w3ij/1/0/problem.jpg with a random string '404LJ4w3ij' where there should be an question_usage.id.
      5. Check in the PHP error log, to verify that no error has been logged there.

      (Note that, the error will not be displayed on screen, because pluginfile.php does define('NO_DEBUG_DISPLAY', true);.)

      Show
      Save the attached test.php into the root of your Moodle. Visit it. Right click on the broken image, and do 'View image' (or whatever your brower calls it.) Note that the image URL looks like https://example.com/moodle/pluginfile.php/1/question/questiontext/404LJ4w3ij/1/0/problem.jpg with a random string '404LJ4w3ij' where there should be an question_usage.id. Check in the PHP error log, to verify that no error has been logged there. (Note that, the error will not be displayed on screen, because pluginfile.php does define('NO_DEBUG_DISPLAY', true);.)
    • Affected Branches:
      MOODLE_27_STABLE, MOODLE_28_STABLE
    • Fixed Branches:
      MOODLE_27_STABLE, MOODLE_28_STABLE
    • Pull from Repository:
    • Pull Master Branch:

      Description

      I only found this due to a bug in the STACK question type (https://github.com/maths/moodle-qtype_stack/issues/116) but it is worth fixing now it has been found.

      See the attached test.php script (save into the root of your Moodle).

      The point is not that the image is not displayed. (Of course it is not, we just made a reference to a non-existent image.) The problem is that an error is logged:

      PHP Warning: array_key_exists(): The first argument should be either a string or an integer in /vle/www_root/lib/classes/component.php on line 872

        Attachments

          Activity

            People

            Assignee:
            timhunt Tim Hunt
            Reporter:
            timhunt Tim Hunt
            Peer reviewer:
            Simey Lameze
            Integrator:
            David Monllaó
            Tester:
            John Okely
            Participants:
            Component watchers:
            Tim Hunt, Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              11/May/15