Messaging not working after moodle 3.3 and PHP 7.1 upgrade

Messaging not working after moodle 3.3 and PHP 7.1 upgrade

by Paul Lindgreen -
Number of replies: 7
Picture of Particularly helpful Moodlers

Just upgraded from php 5.6 to 7.0, than moodle 3.1 to 3.3 and than php 7.0 to 7.1 and discovered messaging was not working.

I noticed the following php error messages but have no idea how to troubleshoot it:

[14-Jun-2018 14:21:36 zzzzzzz] PHP Notice:  Undefined variable: errormessage in zzzzzzzz\message\externallib.php on line 164

When I send someone a message in the first screenshot below the message appears in the lefthand menu 'You: 221pm test'. When I refresh the page the message disappears and the much older message shows up instead (second screenshot).
I have been sending messages between multiple test account and adminsitrator accounts and none have made it through yet.

The Scheduled Task regarding Messaging appears to work fine (see screenshots below.)

Messaging is turned on (see last screenshot).

Im guessing this is a php issue? Perhaps I should try downgrading php 7.1 to 7.0? Or is there a php.ini setting I should update?

====

environment windows2008/IIS7.5/Mysql

======


Average of ratings: -
In reply to Paul Lindgreen

Re: Messaging not working after moodle 3.3 and PHP 7.1 upgrade

by Paul Lindgreen -
Picture of Particularly helpful Moodlers

re:  [14-Jun-2018 14:21:36 zzzzzzz] PHP Notice:  Undefined variable: errormessage in zzzzzzzz\message\externallib.php on line 164

Line 164 refers to bold line below:

if ($success) {
                $resultmsg['msgid'] = $success;
} else {
                // WARNINGS: for backward compatibility we return this errormessage.
                //          We should have thrown exceptions as these errors prevent results to be returned.
                // See http://docs.moodle.org/dev/Errors_handling_in_web_services#When_to_send_a_warning_on_the_server_side .
                $resultmsg['msgid'] = -1;
                $resultmsg['errormessage'] = $errormessage;
 }

Not very encouraging, no $success and the error message doesnt work either. Ill try to find out where $success is at least changed to false, looks like 3 possible locations for that, line 141,131,125

            // Check if the user is a contact
            //TODO MDL-31118 performance improvement - edit the function so we can pass an array instead userid
            $blocknoncontacts = get_user_preferences('message_blocknoncontacts', NULL, $message['touserid']);
            // message_blocknoncontacts option is on and current user is not in contact list
            if ($success && empty($contactlist[$message['touserid']]) && !empty($blocknoncontacts)) {
                // The user isn't a contact and they have selected to block non contacts so this message won't be sent.
                $success = false;
                $errormessage = get_string('userisblockingyounoncontact', 'message',
                        fullname(core_user::get_user($message['touserid'])));
            }


            //check that the touser is not blocking the current user
            if ($success and !empty($blocklist[$message['touserid']]) and !$canreadallmessages) {
                $success = false;
                $errormessage = get_string('userisblockingyou', 'message');
            }


            //check the user exists
            if (empty($tousers[$message['touserid']])) {
                $success = false;
                $errormessage = get_string('touserdoesntexist', 'message', $message['touserid']);
            }

In reply to Paul Lindgreen

Re: Messaging not working after moodle 3.3 and PHP 7.1 upgrade

by Paul Lindgreen -
Picture of Particularly helpful Moodlers

Tried to send a message to all class participants from a Teacher and received the following message indicating no messages were sent.

Moodle Debugging is set at Developer level.



In reply to Paul Lindgreen

Re: Messaging not working after moodle 3.3 and PHP 7.1 upgrade

by Paul Lindgreen -
Picture of Particularly helpful Moodlers

re: [14-Jun-2018 14:21:36 zzzzzzz] PHP Notice:  Undefined variable: errormessage in zzzzzzzz\message\externallib.php on line 164

In addition to the undefined variable error (for every message attempting now) in php I also generate a related messaging error occasioanally:

[15-Jun-2018 09:25:36 zzzz] PHP Notice:  Trying to get property of non-object in zzzzz\message\classes\output\messagearea\message.php on line 87 (and lines 88,89,90,91,92,93,94)


In reply to Paul Lindgreen

Re: Messaging not working after moodle 3.3 and PHP 7.1 upgrade

by Paul Lindgreen -
Picture of Particularly helpful Moodlers

I can add a Contact but same results, send the message, doesn't show up in message list and after a page reload its gone.

Downgraded php from 7.1 to 7.0 , the same results though.

Prior to this update I also performed the UTF8mb4 conversion, not sure if it related, thought ild mention it anyways.

May try downgrading php again from 7.0 to 5.6 and if that doesn't work try Moodle 3.3->3.4 (or 3.2, its a dev environment so its ok to try)

In reply to Paul Lindgreen

Re: Messaging not working after moodle 3.3 and PHP 7.1 upgrade

by Paul Lindgreen -
Picture of Particularly helpful Moodlers

browser developer tools suggest messages are submitted to and received from lib/ajax/service.php successfully with 200 response codes, response body not sure what to say.



'timesent' indicates '9:53 AM', not sure where that time is coming from, my local time is 3:43PM.

In reply to Paul Lindgreen

Re: Messaging not working after moodle 3.3 and PHP 7.1 upgrade

by Colin Fraser -
Picture of Documentation writers Picture of Testers

AFAIK, and IANAD, the Messaging system has undergone something of a reconstruction over the last few versions and while it is set at a default of Yes, in Site Admin > Advanced Features, there may be some additional settings that require to be made to ensure it works. You might want to look at the Moodle Doc on Messaging Settings to get an updated view of what is going on.

Average of ratings: Useful (2)
In reply to Colin Fraser

Re: Messaging not working after moodle 3.3 and PHP 7.1 upgrade

by Paul Lindgreen -
Picture of Particularly helpful Moodlers

I reviewed the Messaging settings as you suggested and sure enough you were right, under Plugins->Message Outputs->Default message outputs, the following 2 settings were unchecked, I checked them and all looks good now. Thanks a million.

It would be nice if Moodle disabled the ability to enter and send messages under these circumstances, or provide a message to indicate why messages are not successfully sent...its easy to believe messaging is enabling and working when you can enter a message and click send.


Average of ratings: Useful (1)