Skip to content
Snippets Groups Projects
Commit 747fcbc5 authored by Meet Bhanvadia's avatar Meet Bhanvadia Committed by Oliver Bethke
Browse files

Issue #3148111 by meet_bhanvadia, Project Update Bot: Automated Drupal 9 compatibility fixes

parent 0593cdc6
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,7 @@ type: module
description: 'Records which user has read which message.'
package: Message
core: 8.x
core_version_requirement: ^8 || ^9
dependencies:
- drupal:history
- message:message
......@@ -55,7 +55,9 @@ function message_history_read_multiple(array $mids = []) {
return $return;
}
$result = db_query('SELECT mid, timestamp FROM {message_history} WHERE uid = :uid AND mid IN ( :mids[] )', [
// TODO: Drupal Rector Notice: Please delete the following comment after you've made any necessary changes.
// You will need to use `\Drupal\core\Database\Database::getConnection()` if you do not yet have access to the container here.
$result = \Drupal::database()->query('SELECT mid, timestamp FROM {message_history} WHERE uid = :uid AND mid IN ( :mids[] )', [
':uid' => \Drupal::currentUser()->id(),
':mids[]' => array_keys($items_to_read),
]);
......@@ -82,16 +84,17 @@ function message_history_write($mid, AccountInterface $account = NULL) {
}
if ($account->isAuthenticated()) {
db_merge('message_history')
// You will need to use `\Drupal\core\Database\Database::getConnection()` if you do not yet have access to the container here.
\Drupal::database()->merge('message_history')
->keys([
'uid' => $account->id(),
'mid' => $mid,
])
->fields(['timestamp' => \REQUEST_TIME])
->fields(['timestamp' => \Drupal::time()->getRequestTime()])
->execute();
// Update static cache.
$history = &drupal_static('message_history_read_multiple', []);
$history[$mid] = \REQUEST_TIME;
$history[$mid] = \Drupal::time()->getRequestTime();
}
}
......@@ -99,7 +102,9 @@ function message_history_write($mid, AccountInterface $account = NULL) {
* Implements hook_cron().
*/
function message_history_cron() {
db_delete('message_history')
// TODO: Drupal Rector Notice: Please delete the following comment after you've made any necessary changes.
// You will need to use `\Drupal\core\Database\Database::getConnection()` if you do not yet have access to the container here.
\Drupal::database()->delete('message_history')
->condition('timestamp', \HISTORY_READ_LIMIT, '<')
->execute();
}
......@@ -129,7 +134,9 @@ function message_history_message_view_alter(array &$build, EntityInterface $mess
* Implements hook_ENTITY_TYPE_delete() for message entities.
*/
function message_history_message_delete(EntityInterface $message) {
db_delete('message_history')
// TODO: Drupal Rector Notice: Please delete the following comment after you've made any necessary changes.
// You will need to use `\Drupal\core\Database\Database::getConnection()` if you do not yet have access to the container here.
\Drupal::database()->delete('message_history')
->condition('mid', $message->id())
->execute();
}
......@@ -140,7 +147,9 @@ function message_history_message_delete(EntityInterface $message) {
function message_history_user_cancel($edit, $account, $method) {
switch ($method) {
case 'user_cancel_reassign':
db_delete('message_history')
// TODO: Drupal Rector Notice: Please delete the following comment after you've made any necessary changes.
// You will need to use `\Drupal\core\Database\Database::getConnection()` if you do not yet have access to the container here.
\Drupal::database()->delete('message_history')
->condition('uid', $account->id())
->execute();
break;
......@@ -151,7 +160,9 @@ function message_history_user_cancel($edit, $account, $method) {
* Implements hook_ENTITY_TYPE_delete() for user entities.
*/
function message_history_user_delete($account) {
db_delete('message_history')
// TODO: Drupal Rector Notice: Please delete the following comment after you've made any necessary changes.
// You will need to use `\Drupal\core\Database\Database::getConnection()` if you do not yet have access to the container here.
\Drupal::database()->delete('message_history')
->condition('uid', $account->id())
->execute();
}
......
......@@ -100,7 +100,7 @@ class MessageHistoryTimestamp extends FieldPluginBase {
'#theme' => 'mark',
'#status' => $mark,
];
return $this->renderLink(drupal_render($build), $values);
return $this->renderLink(\Drupal::service('renderer')->render($build), $values);
}
/**
......
......@@ -78,7 +78,7 @@ class MessageHistoryTimestamp extends FilterPluginBase {
return;
}
$limit = REQUEST_TIME - HISTORY_READ_LIMIT;
$limit = \Drupal::time()->getRequestTime() - HISTORY_READ_LIMIT;
$this->ensureMyTable();
$field = "$this->tableAlias.$this->realField";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment