From c33c50beeb933d07f4337857b8b372db5730773c Mon Sep 17 00:00:00 2001 From: webchick Date: Tue, 10 Dec 2013 22:51:13 -0800 Subject: [PATCH] Issue #2061927 by joelpittet, InternetDevels, m1r1k: Remove references to global in History module. --- core/modules/history/history.module | 3 +-- .../history/Plugin/views/field/HistoryUserTimestamp.php | 9 +++------ .../history/Plugin/views/filter/HistoryUserTimestamp.php | 3 +-- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/core/modules/history/history.module b/core/modules/history/history.module index 0dfad16e187..8aeb74eac14 100644 --- a/core/modules/history/history.module +++ b/core/modules/history/history.module @@ -100,10 +100,9 @@ function history_read_multiple($nids) { * current user. */ function history_write($nid, $account = NULL) { - global $user; if (!isset($account)) { - $account = $user; + $account = \Drupal::currentUser(); } if ($account->isAuthenticated()) { diff --git a/core/modules/history/lib/Drupal/history/Plugin/views/field/HistoryUserTimestamp.php b/core/modules/history/lib/Drupal/history/Plugin/views/field/HistoryUserTimestamp.php index 047e5f0f121..2efd1cb6fae 100644 --- a/core/modules/history/lib/Drupal/history/Plugin/views/field/HistoryUserTimestamp.php +++ b/core/modules/history/lib/Drupal/history/Plugin/views/field/HistoryUserTimestamp.php @@ -38,8 +38,7 @@ class HistoryUserTimestamp extends Node { public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) { parent::init($view, $display, $options); - global $user; - if ($user->isAuthenticated()) { + if (\Drupal::currentUser()->isAuthenticated()) { $this->additional_fields['created'] = array('table' => 'node_field_data', 'field' => 'created'); $this->additional_fields['changed'] = array('table' => 'node_field_data', 'field' => 'changed'); if (module_exists('comment') && !empty($this->options['comments'])) { @@ -69,8 +68,7 @@ class HistoryUserTimestamp extends Node { public function query() { // Only add ourselves to the query if logged in. - global $user; - if ($user->isAnonymous()) { + if (\Drupal::currentUser()->isAnonymous()) { return; } parent::query(); @@ -84,8 +82,7 @@ class HistoryUserTimestamp extends Node { // This code shadows node_mark, but it reads from the db directly and // we already have that info. $mark = MARK_READ; - global $user; - if ($user->isAuthenticated()) { + if (\Drupal::currentUser()->isAuthenticated()) { $last_read = $this->getValue($values); $changed = $this->getValue($values, 'changed'); diff --git a/core/modules/history/lib/Drupal/history/Plugin/views/filter/HistoryUserTimestamp.php b/core/modules/history/lib/Drupal/history/Plugin/views/filter/HistoryUserTimestamp.php index e89f4916f65..1a1c108db96 100644 --- a/core/modules/history/lib/Drupal/history/Plugin/views/filter/HistoryUserTimestamp.php +++ b/core/modules/history/lib/Drupal/history/Plugin/views/filter/HistoryUserTimestamp.php @@ -60,9 +60,8 @@ class HistoryUserTimestamp extends FilterPluginBase { } public function query() { - global $user; // This can only work if we're authenticated in. - if (!$user->isAuthenticated()) { + if (!\Drupal::currentUser()->isAuthenticated()) { return; }