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

messagelib is using is_int() on userids, which causes message send to fail sometimes. Needs to be is_numeric().

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.3
    • Fix Version/s: 2.2.5, 2.3.2
    • Component/s: Messages
    • Labels:
    • Testing Instructions:
      Hide
      1. Dump the attached test.php in root of your moodle install
      2. Edit test.php and change the $eventdata->userto to a valid user id
      3. Run test.php from browser
      4. make sure you get "Success" echoed
      5. login as the userto user and make sure you get the msg
      Show
      Dump the attached test.php in root of your moodle install Edit test.php and change the $eventdata->userto to a valid user id Run test.php from browser make sure you get "Success" echoed login as the userto user and make sure you get the msg
    • Affected Branches:
      MOODLE_23_STABLE
    • Fixed Branches:
      MOODLE_22_STABLE, MOODLE_23_STABLE
    • Pull Master Branch:
      MDL-34535-master

      Description

      Writing a module that send a message like this fails because line 63 of messagelib.php doesn't recognise the userid which comes in as a string.

      $eventdata = new stdClass();
      $eventdata->component = 'mod_coursework';
      $eventdata->name = 'deadlinechanged';
      $eventdata->userfrom = $USER;
      // $dbrecord is from a standard $DB->get_record() call
      $eventdata->userto = $dbrecord->studentid;
      // etc
       
      message_send($eventdata);

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            salvetore Michael de Raadt added a comment -

            Oh for a strongly typed language...

            Thanks for spotting that and suggesting a fix.

            Show
            salvetore Michael de Raadt added a comment - Oh for a strongly typed language... Thanks for spotting that and suggesting a fix.
            Hide
            skodak Petr Skoda added a comment -

            hi, our is_number() might be more suitable for integers because is_numeric() is for floats too.

            Show
            skodak Petr Skoda added a comment - hi, our is_number() might be more suitable for integers because is_numeric() is for floats too.
            Hide
            rwijaya Rossiani Wijaya added a comment -

            Looks good Ankit.
            +1 for integration.

            Show
            rwijaya Rossiani Wijaya added a comment - Looks good Ankit. +1 for integration.
            Hide
            ankit_frenz Ankit Agarwal added a comment -

            Thanks for the review Rosie,
            Sending this for integration.

            Show
            ankit_frenz Ankit Agarwal added a comment - Thanks for the review Rosie, Sending this for integration.
            Hide
            poltawski Dan Poltawski added a comment -

            Integrated, thanks guys.

            Maybe you could provide a test.php rather than making the person hack their course/view.php for test instructions

            Show
            poltawski Dan Poltawski added a comment - Integrated, thanks guys. Maybe you could provide a test.php rather than making the person hack their course/view.php for test instructions
            Hide
            ankit_frenz Ankit Agarwal added a comment -

            Thanks Dan, updated testing instructions and added the testing script
            Cheers

            Show
            ankit_frenz Ankit Agarwal added a comment - Thanks Dan, updated testing instructions and added the testing script Cheers
            Hide
            fred Frédéric Massart added a comment -

            Test successful on 2.2, 2.3 and master. Yay! \o/

            Show
            fred Frédéric Massart added a comment - Test successful on 2.2, 2.3 and master. Yay! \o/
            Hide
            stronk7 Eloy Lafuente (stronk7) added a comment -

            YEAR!*

            CAF*, TOT!*

            • Your effort amazingly resulted. (unbelievable :-P)
            • Closing as fixed.
            • Tons of thanks.
            Show
            stronk7 Eloy Lafuente (stronk7) added a comment - YEAR!* CAF*, TOT!* Your effort amazingly resulted. (unbelievable :-P) Closing as fixed. Tons of thanks.

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  10/Sep/12