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

XMLDB editor fails to parse data properly in certain cases + fix

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • 1.9.10
    • 1.9.9
    • Database SQL/XMLDB
    • None
    • MOODLE_19_STABLE
    • MOODLE_19_STABLE

      I've just found that some data we've generated failed on the install of our block with this error:

      Errors found in XMLDB file: Problem loading statement insert block_qualmgr_criterion, Incorrect number of fields (learn_outcome_id, name, description) VALUES ('10618', '2.5', 'd) or values ('10618', '2.5', 'd) Values and beliefs')

      The problem is that the 'fields' bit has overrun to the next bracket along and hasn't stopped where it should, so it thinks that the comma separated list of DB fields looks like this:

      learn_outcome_id, name, description) VALUES ('10618', '2.5', 'd

      It comes from this line in our install.xml file:

      <SENTENCE TEXT="(learn_outcome_id, name, description) VALUES ('10618', '2.5', 'd) Values and beliefs')" />

      Which gets interpreted by this regexp in /lib/xmldb/classes/XMLDBStatement.class.php on line 339:

      preg_match('/^\((.*)\)\s+VALUES/is', $sentence, $matches);

      The problem being that any data containing ') value' is going to mess this up because the regexp is greedy. Changing it so that the regexp is not case sensitive would be an improvement, but even better would be to prevent this from being a greedy match too, like this:

      preg_match('/^\((.*)\)\s+VALUES/Us', $sentence, $matches);

            skodak Petr Skoda
            mattgibson Matt Gibson (Inactive)
            Nobody Nobody (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:

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