MDL-47162 core_message: debug whenever courseid is missing

Instead of silently defaulting to SITEID when courseid (coming
from message_send()/\core\message\manager::send_message()) is missing,
now a debugging message is shown to allow developers to fix their
messages to, always, include courseid.

Raw creation of events via message_sent::create() missing other[courseid]
leads to coding exception since now (there shouldn't be any legacy use, as far as
they are always created via create_from_ids() when sending a message.

Updated upgrade.txt notes a little bit, added references the 3.6 final
deprecation issue (MDL-55449) and covered with unit tests.
This commit is contained in:
Eloy Lafuente (stronk7) 2016-10-28 00:06:31 +02:00
parent 9d0e8a4f6d
commit a29bcf7819
5 changed files with 78 additions and 5 deletions

View file

@ -50,6 +50,7 @@ require_once(__DIR__ . '/../message/lib.php');
* Note: processor failure is is not reported as false return value,
* earlier versions did not do it consistently either.
*
* @todo MDL-55449 Drop support for stdClass in Moodle 3.6
* @category message
* @param \core\message\message $eventdata information about the message (component, userfrom, userto, ...)
* @return mixed the integer ID of the new message or false if there was a problem with submitted data
@ -57,6 +58,7 @@ require_once(__DIR__ . '/../message/lib.php');
function message_send($eventdata) {
global $CFG, $DB;
// TODO MDL-55449 Drop support for stdClass in Moodle 3.6.
if ($eventdata instanceof \stdClass) {
if (!isset($eventdata->courseid)) {
$eventdata->courseid = null;