MDL-45242 Lib: Replace calls to deprecated functions

In all cases changes have been kept to a minimum while not making
the code completely horrible. For example, there are many instances
where it would probably be better to rewrite a query entirely, but
I have not done that (in order to reduce the risk of changes).
This commit is contained in:
sam marshall
2021-03-10 10:58:09 +00:00
parent 5b7b1b9a06
commit 0919a04311
152 changed files with 612 additions and 394 deletions
+9 -5
View File
@@ -111,8 +111,9 @@ class api {
global $DB;
// Get the user fields we want.
$ufields = \user_picture::fields('u', array('lastaccess'), 'userfrom_id', 'userfrom_');
$ufields2 = \user_picture::fields('u2', array('lastaccess'), 'userto_id', 'userto_');
$userfieldsapi = \core\user_fields::for_userpic()->including('lastaccess');
$ufields = $userfieldsapi->get_sql('u', false, 'userfrom_', '', false)->selects;
$ufields2 = $userfieldsapi->get_sql('u2', false, 'userto_', '', false)->selects;
// Add the uniqueid column to make each row unique and avoid SQL errors.
$uniqueidsql = $DB->sql_concat('m.id', "'_'", 'm.useridfrom', "'_'", 'mcm.userid');
@@ -1022,7 +1023,8 @@ class api {
debugging('\core_message\api::get_contacts_with_unread_message_count is deprecated and no longer used',
DEBUG_DEVELOPER);
$userfields = \user_picture::fields('u', array('lastaccess'));
$userfieldsapi = \core\user_fields::for_userpic()->including('lastaccess');
$userfields = $userfieldsapi->get_sql('u', false, '', '', false)->selects;
$unreadcountssql = "SELECT $userfields, count(m.id) as messagecount
FROM {message_contacts} mc
INNER JOIN {user} u
@@ -1063,7 +1065,8 @@ class api {
debugging('\core_message\api::get_non_contacts_with_unread_message_count is deprecated and no longer used',
DEBUG_DEVELOPER);
$userfields = \user_picture::fields('u', array('lastaccess'));
$userfieldsapi = \core\user_fields::for_userpic()->including('lastaccess');
$userfields = $userfieldsapi->get_sql('u', false, '', '', false)->selects;
$unreadcountssql = "SELECT $userfields, count(m.id) as messagecount
FROM {user} u
INNER JOIN {messages} m
@@ -1885,7 +1888,8 @@ class api {
public static function get_blocked_users($userid) {
global $DB;
$userfields = \user_picture::fields('u', array('lastaccess'));
$userfieldsapi = \core\user_fields::for_userpic()->including('lastaccess');
$userfields = $userfieldsapi->get_sql('u', false, '', '', false)->selects;
$blockeduserssql = "SELECT $userfields
FROM {message_users_blocked} mub
INNER JOIN {user} u