Moodle
  1. Moodle
  2. MDL-33194

Can't subscribe other user to forum

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.3
    • Fix Version/s: 2.1.7, 2.2.4
    • Component/s: Forum
    • Labels:
    • Rank:
      41115

      Description

      If you attempt to subscribe another user to a forum you produce the following stack trace:
      Debug info: Column 'userid' cannot be null
      INSERT INTO mdl_forum_subscriptions (userid,forum) VALUES(?,?)
      [array (
      0 => NULL,
      1 => '2',
      )]
      Error code: dmlwriteexception
      Stack trace:
      line 416 of /lib/dml/moodle_database.php: dml_write_exception thrown
      line 952 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
      line 994 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw()
      line 4560 of /mod/forum/lib.php: call to mysqli_native_moodle_database->insert_record()
      line 170 of /mod/forum/subscribe.php: call to forum_subscribe()
      Output buffer: <br /> <b>Notice</b>: Undefined property: stdClass::$id in <b>/html/mod/forum/subscribe.php</b> on line <b>134</b><br /> <br /> <b>Notice</b>: Undefined property: stdClass::$id in <b>/html/mod/forum/subscribe.php</b> on line <b>170</b><br />

      The $DB->get_record() call on line 65 includes only three parameters, so it never returns any fields. I'm not sure how to actually reach this code via the interface; I noticed the function call and worked backwards to produce the stack trace.

        Issue Links

          Activity

          Hide
          Sam Hemelryk added a comment -

          Good catch thanks Charles! Fix looks spot on, integrator this needs to be backported to 21 as well.

          Cheers
          Sam

          Show
          Sam Hemelryk added a comment - Good catch thanks Charles! Fix looks spot on, integrator this needs to be backported to 21 as well. Cheers Sam
          Hide
          Dan Poltawski added a comment -

          Thanks Charles, I've integrated this to master, 22 and 21

          Show
          Dan Poltawski added a comment - Thanks Charles, I've integrated this to master, 22 and 21
          Hide
          Frédéric Massart added a comment -

          Test successful on master, 2.2 and 2.1, but I could not find how to reach this page without hacking the URL.

          Charles, could you explain how you reproduced this bug?

          This also raises another issue which I will link to this one.

          Show
          Frédéric Massart added a comment - Test successful on master, 2.2 and 2.1, but I could not find how to reach this page without hacking the URL. Charles, could you explain how you reproduced this bug? This also raises another issue which I will link to this one.
          Hide
          Charles Fulton added a comment -

          I also had to hack the URL, which does make me wonder if this code is even in use.

          Show
          Charles Fulton added a comment - I also had to hack the URL, which does make me wonder if this code is even in use.
          Hide
          Dan Poltawski added a comment -

          Congratulations!

          Your work has made into the latest Moodle release!

          You are only authorised to celebrate after testing 15 Moodle 2.3 QA tests, thanks!

          Show
          Dan Poltawski added a comment - Congratulations! Your work has made into the latest Moodle release! You are only authorised to celebrate after testing 15 Moodle 2.3 QA tests, thanks!

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: