summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgnuget2019-03-13 02:58:54 (GMT)
committerDavid Valdez2019-03-13 02:58:54 (GMT)
commite8ae6c7fde5cf86ce8b4ce1cf7da602d5fcccac2 (patch)
tree53a451682fd9b13cc46e40f157a695360f5cf321
parentc348208245926998b7876f92f45d7fe998a1a9d1 (diff)
Issue #2853436 by gnuget, Pavan B S: Remove deprecated codeHEAD8.x-1.x
-rw-r--r--comment_notify.inc36
-rw-r--r--comment_notify.module8
2 files changed, 22 insertions, 22 deletions
diff --git a/comment_notify.inc b/comment_notify.inc
index 105f8e6..65e01e9 100644
--- a/comment_notify.inc
+++ b/comment_notify.inc
@@ -27,7 +27,7 @@ function comment_notify_get_user_notification_setting($uid) {
$users[0] = comment_notify_get_default_notification_setting();
}
else {
- $setting = db_select('comment_notify_user_settings', 'cnus')
+ $setting = \Drupal::database()->select('comment_notify_user_settings', 'cnus')
->fields('cnus')
->condition('uid', $uid)
->execute()
@@ -64,7 +64,7 @@ function comment_notify_get_default_notification_setting() {
* TRUE if the preferences were removed correctly, FALSE if weren't removed.
*/
function comment_notify_delete_user_notification_setting($uid) {
- return (bool) db_delete('comment_notify_user_settings')
+ return (bool) \Drupal::database()->delete('comment_notify_user_settings')
->condition('uid', $uid)
->execute();
}
@@ -131,11 +131,11 @@ function comment_notify_set_user_notification_setting($uid, $entity_notification
$fields['comment_notify'] = $comment_notification;
}
if (comment_notify_get_user_notification_setting($uid)) {
- $query = db_update('comment_notify_user_settings');
+ $query = \Drupal::database()->update('comment_notify_user_settings');
$query->condition('uid', $uid);
}
else {
- $query = db_insert('comment_notify_user_settings');
+ $query = \Drupal::database()->insert('comment_notify_user_settings');
}
return (bool) $query
->fields($fields)
@@ -159,7 +159,7 @@ function comment_notify_set_user_notification_setting($uid, $entity_notification
*/
function comment_notify_add_notification($cid, $notify, $notify_hash, $notified) {
// Check if comment already exist.
- $results = db_select('comment_notify', 'cn')
+ $results = \Drupal::database()->select('comment_notify', 'cn')
->fields('cn', ['cid'])
->condition('cn.cid', $cid)
->execute()
@@ -167,7 +167,7 @@ function comment_notify_add_notification($cid, $notify, $notify_hash, $notified)
// Update comment if exist.
if ($results) {
- return (bool) db_update('comment_notify')
+ return (bool) \Drupal::database()->update('comment_notify')
->fields([
'notify' => $notify === NULL ? 0 : $notify,
'notify_hash' => $notify_hash,
@@ -179,7 +179,7 @@ function comment_notify_add_notification($cid, $notify, $notify_hash, $notified)
// Create new entry.
else {
- return (bool) db_insert('comment_notify')
+ return (bool) \Drupal::database()->insert('comment_notify')
->fields([
'cid' => $cid,
'notify' => $notify === NULL ? 0 : $notify,
@@ -200,7 +200,7 @@ function comment_notify_add_notification($cid, $notify, $notify_hash, $notified)
* TRUE if all the notifications were removed correctly.
*/
function comment_notify_remove_all_notifications($cid) {
- return (bool) db_delete('comment_notify')
+ return (bool) \Drupal::database()->delete('comment_notify')
->condition('cid', $cid)
->execute();
}
@@ -217,7 +217,7 @@ function comment_notify_remove_all_notifications($cid) {
* TRUE if the notification was updated correctly.
*/
function comment_notify_update_notification($cid, $notify) {
- return (bool) db_update('comment_notify')
+ return (bool) \Drupal::database()->update('comment_notify')
->fields([
'notify' => $notify === NULL ? 0 : $notify,
])
@@ -235,7 +235,7 @@ function comment_notify_update_notification($cid, $notify) {
* Return the notification type.
*/
function comment_notify_get_notification_type($cid) {
- return db_select('comment_notify', 'cn')
+ return \Drupal::database()->select('comment_notify', 'cn')
->fields('cn', ['notify'])
->condition('cid', $cid)
->execute()
@@ -254,13 +254,13 @@ function comment_notify_get_notification_type($cid) {
* A list of comment entities.
*/
function comment_notify_get_watchers($entity_id, $comment_type) {
- $cids = db_query("SELECT c.cid FROM {comment_field_data} c INNER JOIN {comment_notify} cn ON c.cid = cn.cid LEFT JOIN {users_field_data} u ON c.uid = u.uid WHERE c.entity_id = :entity_id AND c.comment_type = :comment_type AND c.status = :status AND cn.notify <> :notify AND (u.uid = 0 OR u.status = 1)", [
+ $cids = \Drupal::database()->query("SELECT c.cid FROM {comment_field_data} c INNER JOIN {comment_notify} cn ON c.cid = cn.cid LEFT JOIN {users_field_data} u ON c.uid = u.uid WHERE c.entity_id = :entity_id AND c.comment_type = :comment_type AND c.status = :status AND cn.notify <> :notify AND (u.uid = 0 OR u.status = 1)", [
':entity_id' => $entity_id,
':comment_type' => $comment_type,
':status' => CommentInterface::PUBLISHED,
':notify' => COMMENT_NOTIFY_DISABLED,
])->fetchCol();
- return \Drupal::entityManager()->getStorage('comment')->loadMultiple($cids);
+ return \Drupal::entityTypeManager()->getStorage('comment')->loadMultiple($cids);
}
/**
@@ -277,7 +277,7 @@ function comment_notify_mark_comment_as_notified($comment) {
$comment->notified = 1;
// Next, store this fact in the DB as well.
- return (bool) db_update('comment_notify')
+ return (bool) \Drupal::database()->update('comment_notify')
->fields([
'notified' => 1,
])
@@ -312,7 +312,7 @@ function comment_notify_unsubscribe_by_email($mail) {
return FALSE;
}
- $update_query = db_update('comment_notify');
+ $update_query = \Drupal::database()->update('comment_notify');
$update_query->fields(['notify' => 0]);
$update_query->condition('cid', $comment_query->execute(), 'IN');
@@ -331,7 +331,7 @@ function comment_notify_unsubscribe_by_email($mail) {
* Returns TRUE if the comment was unsubscribed correctly, FALSE otherwise.
*/
function comment_notify_unsubscribe_by_hash($hash) {
- $query = db_select('comment_notify', 'cn');
+ $query = \Drupal::database()->select('comment_notify', 'cn');
$query->join('comment_field_data', 'cf', 'cn.cid = cf.cid');
$query->condition('cn.notify_hash', $hash)
->condition('cn.notify', COMMENT_NOTIFY_DISABLED, '!=')
@@ -347,7 +347,7 @@ function comment_notify_unsubscribe_by_hash($hash) {
// If this notification is at the entity level and the commenter has a Drupal
// account, delete all notifications for this entity.
if (COMMENT_NOTIFY_ENTITY == $notification->notify && $notification->uid) {
- $result = db_query("SELECT cid FROM {comment_field_data} WHERE entity_id = :entity_id AND entity_type = :entity_type AND uid = :uid", [
+ $result = \Drupal::database()->query("SELECT cid FROM {comment_field_data} WHERE entity_id = :entity_id AND entity_type = :entity_type AND uid = :uid", [
':entity_id' => $notification->entity_id,
':entity_type' => $notification->entity_type,
':uid' => $notification->uid,
@@ -355,7 +355,7 @@ function comment_notify_unsubscribe_by_hash($hash) {
$cids = $result->fetchCol();
// Update all comment notifications to be disabled.
- return (bool) db_update('comment_notify')
+ return (bool) \Drupal::database()->update('comment_notify')
->fields([
'notify' => 0,
])
@@ -364,7 +364,7 @@ function comment_notify_unsubscribe_by_hash($hash) {
}
else {
// Update this notification to be disabled.
- return (bool) db_update('comment_notify')
+ return (bool) \Drupal::database()->update('comment_notify')
->fields([
'notify' => 0,
])
diff --git a/comment_notify.module b/comment_notify.module
index 5f8ca98..cdb8623 100644
--- a/comment_notify.module
+++ b/comment_notify.module
@@ -231,7 +231,7 @@ function comment_notify_form_user_form_alter(&$form, FormStateInterface &$form_s
// entities.
$bundles = FALSE;
foreach (_comment_notify_get_comment_enabled_bundles() as $entity_type => $bundle) {
- if (\Drupal::entityManager()->getAccessControlHandler($entity_type)->createAccess($bundle)) {
+ if (\Drupal::entityTypeManager()->getAccessControlHandler($entity_type)->createAccess($bundle)) {
$bundles = TRUE;
break;
}
@@ -332,7 +332,7 @@ function comment_notify_remove_user_settings($uid) {
*/
function comment_notify_comment_load($comments) {
// Load some comment_notify specific information into the comment object.
- $query = db_select('comment_notify', 'cn');
+ $query = \Drupal::database()->select('comment_notify', 'cn');
$query->join('comment_field_data', 'c', 'c.cid = cn.cid');
$query->leftJoin('users_field_data', 'u', 'c.uid = u.uid');
$query->condition('c.cid', array_keys($comments), 'IN');
@@ -379,7 +379,7 @@ function _comment_notify_mailalert(CommentInterface $comment) {
}
/** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
- $entity = \Drupal::entityManager()->getStorage($entity_type)->load($entity_id);
+ $entity = \Drupal::entityTypeManager()->getStorage($entity_type)->load($entity_id);
// No mails if this is not an enabled content type.
$enabled_types = $config->get('bundle_types');
@@ -464,7 +464,7 @@ function _comment_notify_mailalert(CommentInterface $comment) {
// Trim the trailing / off the thread, if present.
$alert_thread = rtrim((string) $alert->getThread(), '/');
- $relevant_thread = Unicode::substr($thread, 0, Unicode::strlen($alert_thread));
+ $relevant_thread = mb_substr($thread, 0, mb_strlen($alert_thread));
if ($alert->notify == COMMENT_NOTIFY_COMMENT && strcmp($relevant_thread, $alert_thread) != 0) {
continue;
}