Uploaded image for project: 'Plugins'
  1. Plugins
  2. CONTRIB-6201

Advanced Forum Distinct/Group By Clause cause database errors with Postgresql

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • 2.9.3, 3.0, 3.0.1, 3.0.2
    • Module: Advanced forum
    • None
    • 2016012600
    • MOODLE_29_STABLE, MOODLE_30_STABLE

      I have uncovered a number of postgres sql specific errors which prevent a number of forum functions to work as designed.

      /mod/hsfourum/renderer.php

      Line apprx 307

      Fails:
      $replyusers = $DB->get_records_sql("SELECT DISTINCT $fields FROM

      {hsuforum_posts} hp JOIN {user} u ON hp.userid = u.id WHERE hp.discussion = ? AND hp.privatereply = 0 ORDER BY hp.modified DESC", array($discussion->id));

      Postgres requires the order by column to be part of the fields in the select

      Works:

      $replyusers = $DB->get_records_sql("SELECT DISTINCT $fields, hp.modified FROM{hsuforum_posts}

      hp JOIN

      {user}

      u ON hp.userid = u.id WHERE hp.discussion = ? AND hp.privatereply = 0 ORDER BY hp.modified DESC", array($discussion->id));

      Also,
      lib/table/posters.php

      Apprx Line 54 sql begins, must add u.id to group by apprx line 61 in order for sql to run in postgres.
      Similar error group by clause.

            aolley Adam Olley
            katcher Eric Katchan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.