Make indexing of user messages tolerant to user deletion.
When creating the search document for user messages,
add a check to see if the user has been deleted in the
system. If they have been deleted abort creating the search
document.
This is to avoid rasining an error when trying to get the
user context for a deleted user.
The OR clause in these queries used different sets of columns to select
userid which meant that the indexes that included user id could not be
used.
This change splits the query so that each individual part can use one of
the indexes that includes a userid which speeds them up considerably.
If there was no conversation found and the method returned early, the
active transaction was not marked as committable and the error was
reported by the request shutdown handler.
Attaching a unit test for the case just because it did not seem to be
covered. I was trying to reproduce the thrown error in the unit test but
it can't be used in this case. The shutdown handler puts the warning
directly into the error_log and it is not guaranteed where such messages
go (depending on the PHP configuration). And we do not even raise it
during the unit test execution (presumably due to noise it would
produce) anyway.
I have broken up the single query that was doing multiple joins on the
messaging and user tables. It no longer does any joins and will instead
query each data set individually.
This may cost more in terms of PHP processing but it will mean that
standard database tunings should be able to handle larger data sets.
For example this function was taking a long time to run on moodle.org
and was causing the MySQL join buffer to overflow.
- No longer use the Fibonacci sequence for delaying the timeout.
It is too aggressive.
- The backoff_timer AMD module now expects the callback AND the
backoff function to be passed to the constructor.
- Added ability to specify polling frequency in config.php.
- Added helper function to return the cache key.
- Reworded the parameters for clarity.
Remove the HTML tags from any message in the message area when updating
the last message on the contact otherwise the styling breaks and also
allows <script> tags to be added to the page.
Stop the message area header and footer from being rendered if there is
no other user being messaged, otherwise notices are generated and the
messages fail to send.
Also -
1) Made note of the deprecation as well as the functions and
files that were removed earlier in upgrade.txt.
2) Added new functions to api.php to replace the deprecated ones
that were being used in unit tests.
3) Removed files that are no longer being used.
Also -
- Highlight a conversation when there are unread messages.
- Update the number in the message menu when conversation
containing unread messages is selected.
Messages allows anyone to find anyone on the site - even if they don't share any permissions
in a course. So we need to make at least their name and id discoverable.