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

Message API does not respect user_get_user_details parameters type

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.4.6, 3.5.2, 3.6
    • Fix Version/s: 3.4.7, 3.5.4
    • Component/s: Messages
    • Labels:

      Description

      The first parameter of user_get_user_details must be a user record (from mdl_user) as indicated in the function documentation.

      It happens that the message API is calling this function via show_online_status passing as parameter partial user objects that are not user records from the DB

      I discovered this while working in a fix for MDL-63395

      Some errors, in this case the user object is missing the deleted field from the user table:

      1) core_message_api_testcase::test_search_users_in_course
      Undefined property: stdClass::$deleted

      /Users/juanleyvadelgado/moodles/stable_master/moodle/user/lib.php:1153
      /Users/juanleyvadelgado/moodles/stable_master/moodle/user/lib.php:272
      /Users/juanleyvadelgado/moodles/stable_master/moodle/message/classes/helper.php:338
      /Users/juanleyvadelgado/moodles/stable_master/moodle/message/classes/helper.php:317
      /Users/juanleyvadelgado/moodles/stable_master/moodle/message/classes/api.php:185
      /Users/juanleyvadelgado/moodles/stable_master/moodle/message/tests/api_test.php:164
      /Users/juanleyvadelgado/moodles/stable_master/moodle/lib/phpunit/classes/advanced_testcase.php:80

      To re-run:
      vendor/bin/phpunit "core_message_api_testcase" message/tests/api_test.php

      2) core_message_api_testcase::test_search_users
      Undefined property: stdClass::$deleted

      /Users/juanleyvadelgado/moodles/stable_master/moodle/user/lib.php:1153
      /Users/juanleyvadelgado/moodles/stable_master/moodle/user/lib.php:272
      /Users/juanleyvadelgado/moodles/stable_master/moodle/message/classes/helper.php:338
      /Users/juanleyvadelgado/moodles/stable_master/moodle/message/classes/helper.php:317
      /Users/juanleyvadelgado/moodles/stable_master/moodle/message/classes/api.php:229
      /Users/juanleyvadelgado/moodles/stable_master/moodle/message/tests/api_test.php:262
      /Users/juanleyvadelgado/moodles/stable_master/moodle/lib/phpunit/classes/advanced_testcase.php:80

      To re-run:
      vendor/bin/phpunit "core_message_api_testcase" message/tests/api_test.php

      3) core_message_api_testcase::test_search_messages
      Undefined property: stdClass::$deleted

      /Users/juanleyvadelgado/moodles/stable_master/moodle/user/lib.php:1153
      /Users/juanleyvadelgado/moodles/stable_master/moodle/user/lib.php:272
      /Users/juanleyvadelgado/moodles/stable_master/moodle/message/classes/helper.php:338
      /Users/juanleyvadelgado/moodles/stable_master/moodle/message/classes/helper.php:317
      /Users/juanleyvadelgado/moodles/stable_master/moodle/message/classes/api.php:144
      /Users/juanleyvadelgado/moodles/stable_master/moodle/message/tests/api_test.php:303
      /Users/juanleyvadelgado/moodles/stable_master/moodle/lib/phpunit/classes/advanced_testcase.php:80

        Attachments

          Activity

            People

            Assignee:
            cescobedo Carlos Escobedo
            Reporter:
            jleyva Juan Leyva
            Peer reviewer:
            Juan Leyva
            Integrator:
            Eloy Lafuente (stronk7)
            Tester:
            CiBoT
            Participants:
            Component watchers:
            Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              14/Jan/19