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

Undefined table alias used in function forum_delete_userdata

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.7, 1.7.1, 1.8
    • Fix Version/s: 1.7.2, 1.8
    • Component/s: Forum
    • Labels:
      None
    • Affected Branches:
      MOODLE_17_STABLE, MOODLE_18_STABLE
    • Fixed Branches:
      MOODLE_17_STABLE, MOODLE_18_STABLE

      Description

      While (probably) fixing an issue mentioned in MDL-7845 another bug was introduced in function forum_delete_userdata (with line numbers):
      4398 $sql = "DELETE FROM {$CFG->prefix}forum_posts
      4399 WHERE discussion IN (
      4400 SELECT fd.id FROM {$CFG->prefix}forum_discussions fd, {$CFG->prefix}forum f
      4401 WHERE f.course={$data->courseid} AND f.id=fd.forum "; // closing ) added bellow
      ...and later...
      4411 if (!empty($data->reset_forum_single)) {
      4412 $select = "$sql AND f.type = 'single' and fp.parent > 0 )";
      4413 if (execute_sql($select, false) and $showfeedback)

      { 4414 notify($strreset.': '.get_string('singleforum','forum'), 'notifysuccess'); 4415 }

      4416 }

      here the "fp.parent" refers to a missing table alias, as forum_posts is no longer aliased. In fact, the whole table (forum_posts) is not used in the sub-select at all.

        Attachments

          Activity

            People

            Assignee:
            vyshane Vy-Shane Sin Fat
            Reporter:
            samulik Samuli Karevaara
            Tester:
            Nobody
            Participants:
            Component watchers:
            Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              30/Mar/07