Issue #2061927 by joelpittet, InternetDevels, m1r1k: Remove references to global in History module.

8.0.x
webchick 2013-12-10 22:51:13 -08:00
parent 6819e5e0d6
commit c33c50beeb
3 changed files with 5 additions and 10 deletions

View File

@ -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()) {

View File

@ -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');

View File

@ -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;
}