Moodle
  1. Moodle
  2. MDL-31085

invalid sql in filter/data/filter.php

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 2.2.1
    • Fix Version/s: 2.2.2
    • Component/s: Filters
    • Database:
      PostgreSQL
    • Testing Instructions:
      Hide
      • Enable the database filter and apply it to content
      • Visit a course page or any page with content (e.g. page)
      • Add some content (e.g. label, or topic description)

      Expected Result

      Page displayed correctly

      Actual Result

      Page goes bang

      Show
      Enable the database filter and apply it to content Visit a course page or any page with content (e.g. page) Add some content (e.g. label, or topic description) Expected Result Page displayed correctly Actual Result Page goes bang
    • Affected Branches:
      MOODLE_22_STABLE
    • Fixed Branches:
      MOODLE_22_STABLE
    • Pull Master Branch:
      master_MDL-31085
    • Rank:
      37510

      Description

      Debug info: ERROR: operator does not exist: text = integer
      LINE 8: AND df.param1 = 1
      ^
      HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
      SELECT dc.id AS contentid, dr.id AS recordid, dc.content AS content, d.id AS dataid
      FROM mdl_data d
      JOIN mdl_data_fields df ON df.dataid = d.id
      JOIN mdl_data_records dr ON dr.dataid = d.id
      JOIN mdl_data_content dc ON dc.fieldid = df.id AND dc.recordid = dr.id
      WHERE d.course = $1
      AND df.type = 'text'
      AND df.param1 = 1
      [array (
      0 => '180',
      )]
      Stack trace:

      line 394 of /lib/dml/moodle_database.php: dml_read_exception thrown
      line 232 of /lib/dml/pgsql_native_moodle_database.php: call to moodle_database->query_end()
      line 678 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end()
      line 76 of /filter/data/filter.php: call to pgsql_native_moodle_database->get_records_sql()
      line 157 of /lib/filterlib.php: call to filter_data->filter()
      line 195 of /lib/filterlib.php: call to filter_manager->apply_filter_chain()
      line 296 of /lib/filterlib.php: call to filter_manager->filter_text()
      line 1063 of /lib/weblib.php: call to performance_measuring_filter_manager->filter_text()
      line 72 of /blocks/html/block_html.php: call to format_text()
      line 280 of /blocks/moodleblock.class.php: call to block_html->get_content()
      line 232 of /blocks/moodleblock.class.php: call to block_base->formatted_contents()
      line 926 of /lib/blocklib.php: call to block_base->get_content_for_output()
      line 978 of /lib/blocklib.php: call to block_manager->create_block_contents()
      line 349 of /lib/blocklib.php: call to block_manager->ensure_content_created()
      line 4 of /theme/base/layout/frontpage.php: call to block_manager->region_has_content()
      line 685 of /lib/outputrenderers.php: call to include()
      line 637 of /lib/outputrenderers.php: call to core_renderer->render_page_layout()
      line ? of unknownfile: call to core_renderer->header()
      line 1363 of /lib/setuplib.php: call to call_user_func_array()
      line ? of unknownfile: call to bootstrap_renderer->__call()
      line 91 of /index.php: call to bootstrap_renderer->header()

        Issue Links

          Activity

          Hide
          Dan Marsden added a comment -

          happened during conversion of quotes - this:
          AND ' . $DB->sql_compare_text('df.param1', 1) . ' = 1';
          should be:
          AND ' . $DB->sql_compare_text('df.param1', 1) . " = '1'";

          Show
          Dan Marsden added a comment - happened during conversion of quotes - this: AND ' . $DB->sql_compare_text('df.param1', 1) . ' = 1'; should be: AND ' . $DB->sql_compare_text('df.param1', 1) . " = '1'";
          Hide
          Andrew Davis added a comment -

          Hi Dan. Could you add some testing instructions please.

          Show
          Andrew Davis added a comment - Hi Dan. Could you add some testing instructions please.
          Hide
          Dan Marsden added a comment -

          no idea how to reproduce sorry - no time to look further at it either.. but this one should be obvious that it's wrong by looking at the code.

          Show
          Dan Marsden added a comment - no idea how to reproduce sorry - no time to look further at it either.. but this one should be obvious that it's wrong by looking at the code.
          Hide
          Marcus Boon added a comment -

          I think it happens when you do an upgrade from 1.9 to 2.1 and then to 2.2. At least thats what happened to me as well.

          Show
          Marcus Boon added a comment - I think it happens when you do an upgrade from 1.9 to 2.1 and then to 2.2. At least thats what happened to me as well.
          Hide
          Andrew Nicols added a comment -

          Supplied patches for 22 and master look fine to me, and work as expected

          MOODLE_21_STABLE not affected as it does not have the database filter
          Confirmed using Postgres

          Show
          Andrew Nicols added a comment - Supplied patches for 22 and master look fine to me, and work as expected MOODLE_21_STABLE not affected as it does not have the database filter Confirmed using Postgres
          Hide
          Dan Marsden added a comment -

          thanks Andrew - submitting for integration!

          Show
          Dan Marsden added a comment - thanks Andrew - submitting for integration!
          Hide
          Sam Hemelryk added a comment -

          Thanks Dan, this has been integrated now

          Show
          Sam Hemelryk added a comment - Thanks Dan, this has been integrated now
          Hide
          Andrew Davis added a comment -

          Seems to be working as promised.

          Show
          Andrew Davis added a comment - Seems to be working as promised.
          Hide
          Eloy Lafuente (stronk7) added a comment -

          It is late here and I'm very tired but I didn't want to go to sleep before expressing my admiration for your amazing collaboration. Thanks!

          Closing as fixed, heading to zzzZZZzzz, niao

          Show
          Eloy Lafuente (stronk7) added a comment - It is late here and I'm very tired but I didn't want to go to sleep before expressing my admiration for your amazing collaboration. Thanks! Closing as fixed, heading to zzzZZZzzz, niao

            People

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

              Dates

              • Created:
                Updated:
                Resolved: