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

          Dan Marsden created issue -
          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'";
          Dan Marsden made changes -
          Field Original Value New Value
          Link This issue is a regression caused by MDL-29993 [ MDL-29993 ]
          Dan Marsden made changes -
          Fix Version/s STABLE backlog [ 10463 ]
          Labels partner triaged
          Dan Marsden made changes -
          Dan Marsden made changes -
          Assignee Eloy Lafuente (stronk7) [ stronk7 ] Dan Marsden [ danmarsden ]
          Dan Marsden made changes -
          Status Open [ 1 ] Waiting for peer review [ 10012 ]
          Peer reviewer stronk7
          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.
          Andrew Nicols made changes -
          Testing Instructions * Create a database on a course
          * Add some entries
          * Enable the database filter
          * Visit a course page
          Andrew Nicols made changes -
          Testing Instructions * Create a database on a course
          * Add some entries
          * Enable the database filter
          * Visit a course page
          * Enable the database filter and apply it to content
          * Visit a course page
          Database PostgreSQL [ 10002 ]
          Andrew Nicols made changes -
          Priority Minor [ 4 ] Critical [ 2 ]
          Andrew Nicols made changes -
          Testing Instructions * Enable the database filter and apply it to content
          * Visit a course page
          * 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)

          h3. Expected Result
          Page displayed correctly

          h3. Actual Result
          Page goes bang
          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
          Andrew Nicols made changes -
          Labels partner triaged partner patch triaged
          Dan Marsden made changes -
          Status Waiting for peer review [ 10012 ] Development in progress [ 3 ]
          Hide
          Dan Marsden added a comment -

          thanks Andrew - submitting for integration!

          Show
          Dan Marsden added a comment - thanks Andrew - submitting for integration!
          Dan Marsden made changes -
          Status Development in progress [ 3 ] Waiting for integration review [ 10010 ]
          Eloy Lafuente (stronk7) made changes -
          Currently in integration Yes [ 10041 ]
          Sam Hemelryk made changes -
          Status Waiting for integration review [ 10010 ] Integration review in progress [ 10004 ]
          Integrator samhemelryk
          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
          Sam Hemelryk made changes -
          Status Integration review in progress [ 10004 ] Waiting for testing [ 10005 ]
          Fix Version/s 2.2.2 [ 11552 ]
          Fix Version/s STABLE backlog [ 10463 ]
          Andrew Davis made changes -
          Status Waiting for testing [ 10005 ] Testing in progress [ 10011 ]
          Tester andyjdavis
          Hide
          Andrew Davis added a comment -

          Seems to be working as promised.

          Show
          Andrew Davis added a comment - Seems to be working as promised.
          Andrew Davis made changes -
          Status Testing in progress [ 10011 ] Tested [ 10006 ]
          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
          Eloy Lafuente (stronk7) made changes -
          Status Tested [ 10006 ] Closed [ 6 ]
          Resolution Fixed [ 1 ]
          Currently in integration Yes [ 10041 ]
          Eloy Lafuente (stronk7) made changes -
          Integration date 17/Feb/12

            People

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

              Dates

              • Created:
                Updated:
                Resolved: