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

DB error when getting count of replies on MSSQL

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.7.2, 2.8.3
    • Fix Version/s: 2.7.6, 2.8.4
    • Component/s: Forum
    • Labels:
    • Environment:
      Debian.
    • Sprint:
      Team Beards Sprint 3

      Description

      I'm getting the following DB read error message when trying to view all posts in a Standard forum displayed in a blog-like format:

      Debug info: The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP or FOR XML is also specified.
      SELECT TOP 100 * FROM (SELECT p.discussion, (COUNT(p.id) - 1) AS replies, MAX(p.id) AS lastpostid
      FROM mdl_forum_posts p
      JOIN mdl_forum_discussions d ON p.discussion = d.id
      WHERE d.forum = ?
      GROUP BY p.discussion , d.timemodified
      ORDER BY d.timemodified DESC) sq
      [array (
      0 => '13027',
      )]
      Error code: dmlreadexception

      Stack trace:
      line 443 of /lib/dml/moodle_database.php: dml_read_exception thrown
      line 242 of /lib/dml/mssql_native_moodle_database.php: call to moodle_database->query_end()
      line 724 of /lib/dml/mssql_native_moodle_database.php: call to mssql_native_moodle_database->query_end()
      line 758 of /lib/dml/mssql_native_moodle_database.php: call to mssql_native_moodle_database->get_recordset_sql()
      line 2482 of /mod/forum/lib.php: call to mssql_native_moodle_database->get_records_sql()
      line 5683 of /mod/forum/lib.php: call to forum_count_discussion_replies()
      line 223 of /mod/forum/view.php: call to forum_print_latest_discussions()

      This has only happened recently, so I'm a little puzzled as to the cause.

        Attachments

          Activity

            People

            Assignee:
            dobedobedoh Andrew Nicols
            Reporter:
            martyjacobs Marty
            Peer reviewer:
            Ankit Agarwal
            Integrator:
            Dan Poltawski
            Tester:
            CiBoT
            Participants:
            Component watchers:
            Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              9/Mar/15