original_string: protected static function send_message_to_processors($eventdata, \stdClass $savemessage, array
      $processorlist) {
          global $CFG, $DB;
  
          // We cannot communicate with external systems in DB transactions,
          // buffer the messages if necessary.
          if ($DB->is_transaction_started()) {
              // We need to clone all objects so that devs may not modify it from outside later.
              $eventdata = clone($eventdata);
              $eventdata->userto = clone($eventdata->userto);
              $eventdata->userfrom = clone($eventdata->userfrom);
  
              // Conserve some memory the same was as $USER setup does.
              unset($eventdata->userto->description);
              unset($eventdata->userfrom->description);
  
              self::$buffer[] = array($eventdata, $savemessage, $processorlist);
              return $savemessage->id;
          }
  
          // Send the message to processors.
          self::call_processors($eventdata, $processorlist);
  
          // Trigger event for sending a message or notification - we need to do this before marking as read!
          self::trigger_message_events($eventdata, $savemessage);
  
          if (empty($CFG->messaging)) {
              // If they have deselected all processors and its a notification mark it read. The user doesn't want to be bothered.
              // The same goes if the messaging is completely disabled.
              if ($eventdata->notification) {
                  $savemessage->timeread = null;
                  \core_message\api::mark_notification_as_read($savemessage);
              } else {
                  \core_message\api::mark_message_as_read($eventdata->userto->id, $savemessage);
              }
          }
  
          return $savemessage->id;
      }
code: protected static function send_message_to_processors($eventdata, \stdClass $savemessage, array
      $processorlist) {
          global $CFG, $DB;
  
          // We cannot communicate with external systems in DB transactions,
          // buffer the messages if necessary.
          if ($DB->is_transaction_started()) {
              // We need to clone all objects so that devs may not modify it from outside later.
              $eventdata = clone($eventdata);
              $eventdata->userto = clone($eventdata->userto);
              $eventdata->userfrom = clone($eventdata->userfrom);
  
              // Conserve some memory the same was as $USER setup does.
              unset($eventdata->userto->description);
              unset($eventdata->userfrom->description);
  
              self::$buffer[] = array($eventdata, $savemessage, $processorlist);
              return $savemessage->id;
          }
  
          // Send the message to processors.
          self::call_processors($eventdata, $processorlist);
  
          // Trigger event for sending a message or notification - we need to do this before marking as read!
          self::trigger_message_events($eventdata, $savemessage);
  
          if (empty($CFG->messaging)) {
              // If they have deselected all processors and its a notification mark it read. The user doesn't want to be bothered.
              // The same goes if the messaging is completely disabled.
              if ($eventdata->notification) {
                  $savemessage->timeread = null;
                  \core_message\api::mark_notification_as_read($savemessage);
              } else {
                  \core_message\api::mark_message_as_read($eventdata->userto->id, $savemessage);
              }
          }
  
          return $savemessage->id;
      }
code_tokens: protected static function send_message_to_processors ( $ eventdata , \ stdClass $ savemessage , array $ processorlist ) { global $ CFG , $ DB ; // We cannot communicate with external systems in DB transactions, // buffer the messages if necessary. if ( $ DB -> is_transaction_started ( ) ) { // We need to clone all objects so that devs may not modify it from outside later. $ eventdata = clone ( $ eventdata ) ; $ eventdata -> userto = clone ( $ eventdata -> userto ) ; $ eventdata -> userfrom = clone ( $ eventdata -> userfrom ) ; // Conserve some memory the same was as $USER setup does. unset ( $ eventdata -> userto -> description ) ; unset ( $ eventdata -> userfrom -> description ) ; self :: $ buffer [ ] = array ( $ eventdata , $ savemessage , $ processorlist ) ; return $ savemessage -> id ; } // Send the message to processors. self :: call_processors ( $ eventdata , $ processorlist ) ; // Trigger event for sending a message or notification - we need to do this before marking as read! self :: trigger_message_events ( $ eventdata , $ savemessage ) ; if ( empty ( $ CFG -> messaging ) ) { // If they have deselected all processors and its a notification mark it read. The user doesn't want to be bothered. // The same goes if the messaging is completely disabled. if ( $ eventdata -> notification ) { $ savemessage -> timeread = null ; \ core_message \ api :: mark_notification_as_read ( $ savemessage ) ; } else { \ core_message \ api :: mark_message_as_read ( $ eventdata -> userto -> id , $ savemessage ) ; } } return $ savemessage -> id ; }
docstring: Send message to message processors.
  
  @param \stdClass|\core\message\message $eventdata
  @param \stdClass $savemessage
  @param array $processorlist
  @return int $messageid
docstring_tokens: Send message to message processors .