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

Wrong coding_exception used on problems sending messages

XMLWordPrintable

    • MOODLE_400_STABLE
    • MOODLE_311_STABLE
    • Hide
      1. Sanity check, just verify that there aren't any other cases in lib/classes/message/manager.php pointing to global-scope code and missing the backslash.

      For reference, I've done that here, getting the results below, and ALL the potential cases are effectively using a correct namespace or global \.

      $ ag -s ' new |(?<!self)::' lib/classes/message/manager.php
      71:            throw new \moodle_exception("Message is not being sent to a conversation. Please check event data.");
      95:        $members = $DB->get_records_sql($sql, [$eventdata->convid, \core_message\api::CONVERSATION_ACTION_MUTED,
      98:            throw new \moodle_exception("Conversation has no members or does not exist.");
      114:        if ($conv->type == \core_message\api::MESSAGE_CONVERSATION_TYPE_SELF) {
      124:        if ($conv->type == \core_message\api::MESSAGE_CONVERSATION_TYPE_INDIVIDUAL) {
      157:            $usertoisrealuser = (\core_user::is_real_user($recipient->id) != false);
      161:            if ($conv->type == \core_message\api::MESSAGE_CONVERSATION_TYPE_INDIVIDUAL) {
      164:            } else if ($conv->type == \core_message\api::MESSAGE_CONVERSATION_TYPE_GROUP) {
      181:            $s = new \stdClass();
      182:            $s->sitename = format_string($SITE->shortname, true, array('context' => \context_course::instance(SITEID)));
      191:                    \core_message\helper::prevent_unclosed_html_tags($localisedeventdata->fullmessage, true);
      199:                    \core_message\helper::prevent_unclosed_html_tags($localisedeventdata->fullmessagehtml, true);
      244:                        throw new \coding_exception($preferrormsg);
      346:                \core_message\api::mark_notification_as_read($savemessage);
      349:                \core_message\api::mark_message_as_read($eventdata->userto->id, $savemessage);
      395:            \core_message\api::mark_message_as_read($eventdata->userto->id, $savemessage);
      454:            \core\event\notification_sent::create_from_ids(
      464:                if ($conv->type == \core_message\api::MESSAGE_CONVERSATION_TYPE_GROUP) {
      465:                    \core\event\group_message_sent::create_from_ids(
      475:            \core\event\message_sent::create_from_ids(
      495:            // Let new messaging class add custom content based on the processor.
      506:            $stdproc = new \stdClass();
      508:            $processor = \core_message\api::get_processed_processor_object($stdproc);
      

      Show
      Sanity check, just verify that there aren't any other cases in lib/classes/message/manager.php pointing to global-scope code and missing the backslash. For reference, I've done that here, getting the results below, and ALL the potential cases are effectively using a correct namespace or global \. $ ag -s ' new |(?<!self)::' lib/classes/message/manager.php 71: throw new \moodle_exception("Message is not being sent to a conversation. Please check event data."); 95: $members = $DB->get_records_sql($sql, [$eventdata->convid, \core_message\api::CONVERSATION_ACTION_MUTED, 98: throw new \moodle_exception("Conversation has no members or does not exist."); 114: if ($conv->type == \core_message\api::MESSAGE_CONVERSATION_TYPE_SELF) { 124: if ($conv->type == \core_message\api::MESSAGE_CONVERSATION_TYPE_INDIVIDUAL) { 157: $usertoisrealuser = (\core_user::is_real_user($recipient->id) != false); 161: if ($conv->type == \core_message\api::MESSAGE_CONVERSATION_TYPE_INDIVIDUAL) { 164: } else if ($conv->type == \core_message\api::MESSAGE_CONVERSATION_TYPE_GROUP) { 181: $s = new \stdClass(); 182: $s->sitename = format_string($SITE->shortname, true, array('context' => \context_course::instance(SITEID))); 191: \core_message\helper::prevent_unclosed_html_tags($localisedeventdata->fullmessage, true); 199: \core_message\helper::prevent_unclosed_html_tags($localisedeventdata->fullmessagehtml, true); 244: throw new \coding_exception($preferrormsg); 346: \core_message\api::mark_notification_as_read($savemessage); 349: \core_message\api::mark_message_as_read($eventdata->userto->id, $savemessage); 395: \core_message\api::mark_message_as_read($eventdata->userto->id, $savemessage); 454: \core\event\notification_sent::create_from_ids( 464: if ($conv->type == \core_message\api::MESSAGE_CONVERSATION_TYPE_GROUP) { 465: \core\event\group_message_sent::create_from_ids( 475: \core\event\message_sent::create_from_ids( 495: // Let new messaging class add custom content based on the processor. 506: $stdproc = new \stdClass(); 508: $processor = \core_message\api::get_processed_processor_object($stdproc);

      This is a regression caused after MDL-67853.

      Trying to send a message to any user, you'll get

      Exception - Class 'core\message\coding_exception' not found

      To fix the issue, you need to go to "Site administration > General > Messaging > Notification settings" and hit the "Save changes" button (without changing anything)

            stronk7 Eloy Lafuente (stronk7)
            rezaie9 Shamim Rezaie
            Paul Holden Paul Holden
            Sara Arjona (@sarjona) Sara Arjona (@sarjona)
            CiBoT CiBoT
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 41 minutes
                41m

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