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

Comments in xmldb cause errors if they include '

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.8
    • Fix Version/s: 1.7.2, 1.8, 1.9
    • Component/s: Database SQL/XMLDB
    • Labels:
      None
    • Database:
      PostgreSQL
    • Affected Branches:
      MOODLE_18_STABLE
    • Fixed Branches:
      MOODLE_17_STABLE, MOODLE_18_STABLE, MOODLE_19_STABLE

      Description

      If you make a comment on a database table that has a ' in you get errors, at least in Postgres but it may apply to other database types as well.

      For example, I made the following change in my copy of lib/xmldb/generators/postgres7.class.php

      from

      $comment.= " IS '" . substr($xmldb_table->getComment(), 0, 250) . "'";

      to

      $comment.= " IS '" . addslashes(substr($xmldb_table->getComment(), 0, 250)) . "'";

      This fixed it but I'm not sure it's the right approach, also it probably affects other databases most of which I can't test on, so I think somebody who has a clue how that code works should fix it, not me.

      For now I have changed my comment to not include a ' symbol. I think this solution may be ok for 1.8.

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                30/Mar/07