Moodle

Error in cron, tags section

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.9.1
  • Fix Version/s: 1.9.3
  • Component/s: Tags
  • Labels:
    None
  • Database:
    PostgreSQL
  • Affected Branches:
    MOODLE_19_STABLE
  • Fixed Branches:
    MOODLE_19_STABLE

Description

I was executing a lot of cron scripts while playing with another bugs and then, sometimes, I've got this errror, related to tags:

ERROR: column "nr" does not exist

SELECT tb.tagid , COUNT AS nr FROM mdl_tag_instance ta INNER JOIN mdl_tag_instance tb ON ta.itemid = tb.itemid WHERE ta.tagid = 1 AND tb.tagid != 1 GROUP BY tb.tagid HAVING nr > 2 ORDER BY nr DESC

line 686 of lib/dmllib.php: call to debugging()
line 966 of lib/dmllib.php: call to get_recordset_sql()
line 775 of tag/lib.php: call to get_records_sql()
line 807 of tag/lib.php: call to tag_compute_correlations()
line 369 of admin/cron.php: call to tag_cron()

Using PostgreSQL (not tested under other DBs)

Ciao

Activity

Hide
Petr Škoda (skodak) added a comment -

pg does not support aliases in ORDER BY, right?

--> ORDER BY COUNT DESC

Show
Petr Škoda (skodak) added a comment - pg does not support aliases in ORDER BY, right? --> ORDER BY COUNT DESC
Hide
Mathieu Petit-Clair added a comment -

Thanks for the fix. Committed & merged.

Show
Mathieu Petit-Clair added a comment - Thanks for the fix. Committed & merged.
Hide
Dongsheng Cai added a comment -

Verified, Closed.

Show
Dongsheng Cai added a comment - Verified, Closed.
Hide
Dean Stringer added a comment -

We were having the same problem under Moodle 1.9.1 and PostgreSQL 8.1 but the ORDER clause wasn't the issue it was the HAVING one. Here's a patch that sorted this problem out for us and stopped the Errors:

diff --git a/tag/lib.php b/tag/lib.php
— a/tag/lib.php
+++ b/tag/lib.php
@@ -765,7 +765,7 @@ function tag_compute_correlations($min_correlation=2) {
"FROM {$CFG->prefix}tag_instance ta INNER JOIN {$CFG->prefix}tag_instance tb ON ta.itemid = tb.itemid ".
"WHERE ta.tagid = {$tag->id} AND tb.tagid != {$tag->id} ".
"GROUP BY tb.tagid ".

  • "HAVING nr > $min_correlation ".
    + "HAVING COUNT > $min_correlation ".
    "ORDER BY nr DESC";
Show
Dean Stringer added a comment - We were having the same problem under Moodle 1.9.1 and PostgreSQL 8.1 but the ORDER clause wasn't the issue it was the HAVING one. Here's a patch that sorted this problem out for us and stopped the Errors: diff --git a/tag/lib.php b/tag/lib.php — a/tag/lib.php +++ b/tag/lib.php @@ -765,7 +765,7 @@ function tag_compute_correlations($min_correlation=2) { "FROM {$CFG->prefix}tag_instance ta INNER JOIN {$CFG->prefix}tag_instance tb ON ta.itemid = tb.itemid ". "WHERE ta.tagid = {$tag->id} AND tb.tagid != {$tag->id} ". "GROUP BY tb.tagid ".
  • "HAVING nr > $min_correlation ". + "HAVING COUNT > $min_correlation ". "ORDER BY nr DESC";
Hide
Mathieu Petit-Clair added a comment -

'nr' is now removed and both COUNT and HAVING have been changed. ... Closing.

Show
Mathieu Petit-Clair added a comment - 'nr' is now removed and both COUNT and HAVING have been changed. ... Closing.

Dates

  • Created:
    Updated:
    Resolved: