Details

    • Type: Sub-task
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.9
    • Fix Version/s: 1.9
    • Component/s: Tags
    • Labels:
      None
    • Affected Branches:
      MOODLE_19_STABLE
    • Fixed Branches:
      MOODLE_19_STABLE

      Description

      This error is generated occasionally when running admin/cron.php

      <div class="notifytiny" style="text-align:center">ERROR: relation "core_blog" does not exist<br /><br />
      DELETE FROM core_tag_instance WHERE
      core_tag_instance.id
      IN
      ( SELECT sq1.id
      FROM
      (SELECT sq2.*
      FROM core_tag_instance sq2
      LEFT JOIN core_blog item
      ON sq2.itemid = item.id
      WHERE item.id IS NULL
      AND sq2.itemtype = 'blog')
      sq1
      ) <ul style="text-align: left"><li>line 1393 of lib/dmllib.php: call to debugging()</li><li>line 917 of tag/lib.php: call to delete_records_select()</li><li>line 1132 of tag/lib.php: call to tag_instance_table_cleanup()</li><li>line 339 of admin/cron.php: call to tag_cron()</li></ul></div>

      This is an interesting error, as it has taken some time for me to spot it. The call to tag_cron() is within the 'only call occasionally' section of admin/cron.php, so it does not always appear.

      The fix is very easy. The table <prefix>blog no longer exists. So changing the appropriate line in this query solves the issue:

      LEFT JOIN core_blog item //original line
      LEFT JOIN core_tag item //corrected line

      In the code it is line 910 of tag/lib.php where the variable $type->itemtype should be replaced with 'tag', as is already done in the case just below on line 930.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

              Hide
              jb23347 John Beedell added a comment -

              Sorry, one more minor error found when running cron again after the time above.

              <div class="notifytiny" style="text-align:center">ERROR: syntax error at or near "nr" at character 28<br /><br />
              SELECT tb.tagid , COUNT nr
              FROM core_tag_instance ta
              INNER JOIN core_tag_instance tb ON ta.itemid = tb.itemid
              WHERE ta.tagid = 5
              GROUP BY tb.tagid
              ORDER BY nr DESC<ul style="text-align: left"><li>line 686 of lib/dmllib.php: call to debugging()</li><li>line 944 of lib/dmllib.php: call to get_recordset_sql()</li><li>line 854 of tag/lib.php: call to get_records_sql()</li><li>line 1137 of tag/lib.php: call to cache_correlated_tags()</li><li>line 339 of admin/cron.php: call to tag_cron()</li></ul></div>

              Again the quick fix of course is to add 'as' to line 845 in tag/lib.php:

              SELECT tb.tagid , COUNT as nr

              PS I would be happy to make these changes if required, as I will be submitting some other changes to the tag code for MDL-11992 (adding course tagging) next week (I hope).

              Show
              jb23347 John Beedell added a comment - Sorry, one more minor error found when running cron again after the time above. <div class="notifytiny" style="text-align:center">ERROR: syntax error at or near "nr" at character 28<br /><br /> SELECT tb.tagid , COUNT nr FROM core_tag_instance ta INNER JOIN core_tag_instance tb ON ta.itemid = tb.itemid WHERE ta.tagid = 5 GROUP BY tb.tagid ORDER BY nr DESC<ul style="text-align: left"><li>line 686 of lib/dmllib.php: call to debugging()</li><li>line 944 of lib/dmllib.php: call to get_recordset_sql()</li><li>line 854 of tag/lib.php: call to get_records_sql()</li><li>line 1137 of tag/lib.php: call to cache_correlated_tags()</li><li>line 339 of admin/cron.php: call to tag_cron()</li></ul></div> Again the quick fix of course is to add 'as' to line 845 in tag/lib.php: SELECT tb.tagid , COUNT as nr PS I would be happy to make these changes if required, as I will be submitting some other changes to the tag code for MDL-11992 (adding course tagging) next week (I hope).
              Hide
              emerrill Eric Merrill added a comment -

              I kinda think this should be broken into 2 tickets.

              the second issue (needing to add 'as') is also hitting us during every cron on postgres.

              -eric

              Show
              emerrill Eric Merrill added a comment - I kinda think this should be broken into 2 tickets. the second issue (needing to add 'as') is also hitting us during every cron on postgres. -eric
              Hide
              scyrma Mathieu Petit-Clair added a comment -

              Latest commits should fix this issue. Thanks!

              Show
              scyrma Mathieu Petit-Clair added a comment - Latest commits should fix this issue. Thanks!
              Hide
              stronk7 Eloy Lafuente (stronk7) added a comment -

              Just as reference for future:

              http://docs.moodle.org/en/Development:Coding#Database_structures (point 11)

              It enforces the use of the "AS" keyword for columns and forbid if for tables.

              It's the only cross-db combination.

              Ciao

              Show
              stronk7 Eloy Lafuente (stronk7) added a comment - Just as reference for future: http://docs.moodle.org/en/Development:Coding#Database_structures (point 11) It enforces the use of the "AS" keyword for columns and forbid if for tables. It's the only cross-db combination. Ciao
              Hide
              dougiamas Martin Dougiamas added a comment -

              See problem at MDLSITE-345

              Show
              dougiamas Martin Dougiamas added a comment - See problem at MDLSITE-345
              Hide
              dougiamas Martin Dougiamas added a comment - - edited

              It seems that the change from 'blog' to 'tag' table was incorrect (should be 'post' table, Mat has already fixed it now in CVS), and has resulted in dataloss on moodle.org (cron deleted a lot of tag instances). My standard backups don't have the data (because it was more than a week ago), I'm trying to source some older backups.

              Show
              dougiamas Martin Dougiamas added a comment - - edited It seems that the change from 'blog' to 'tag' table was incorrect (should be 'post' table, Mat has already fixed it now in CVS), and has resulted in dataloss on moodle.org (cron deleted a lot of tag instances). My standard backups don't have the data (because it was more than a week ago), I'm trying to source some older backups.
              Hide
              scyrma Mathieu Petit-Clair added a comment -

              Should be fixed now.

              Show
              scyrma Mathieu Petit-Clair added a comment - Should be fixed now.

                People

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

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Fix Release Date:
                    3/Mar/08