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

Buggy SELECT statement in function tag_compute_correlations()

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Duplicate
    • 2.0.2
    • None
    • Tags
    • PostgreSQL
    • MOODLE_20_STABLE

    Description

      Steps to reproduce
      ==============

      Look into the error log of cron.php or run tag_cron() in tags/lib.php.

      Error Message
      ===========

      Default exception handler: Fehler beim Lesen der Datenbank Debug: ERROR:  column "co.id" must appear in the GROUP BY clause or be used in an aggregate function
      LINE 1: SELECT ta.tagid, tb.tagid AS correlation, co.id AS correlati...
                                                        ^
      SELECT ta.tagid, tb.tagid AS correlation, co.id AS correlationid, co.correlatedtags 
                    FROM mdl_tag_instance ta 
               LEFT JOIN mdl_tag_instance tb 
                      ON (ta.itemtype = tb.itemtype AND ta.itemid = tb.itemid AND ta.tagid <> tb.tagid) 
               LEFT JOIN mdl_tag_correlation co 
                      ON co.tagid = ta.tagid 
                   WHERE tb.tagid IS NOT NULL 
                GROUP BY ta.tagid, tb.tagid 
                  HAVING COUNT(*) > $1 
                ORDER BY ta.tagid ASC, COUNT(*) DESC, tb.tagid ASC
      [array (
        0 => 2,
      )]
      * line 391 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 634 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end()
      * line 844 of /tag/lib.php: call to pgsql_native_moodle_database->get_recordset_sql()
      * line 910 of /tag/lib.php: call to tag_compute_correlations()
      * line 310 of /lib/cronlib.php: call to tag_cron()
      * line 61 of /admin/cli/cron.php: call to cron_run()}}

      Suggested Fix
      ===========

      It's probably save to just add co.id and co.correlatedtags to the GROUP BY clause.

      Attachments

        Issue Links

          Activity

            People

              samhemelryk Sam Hemelryk
              mkemmerling Markus Kemmerling
              David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: