Commit c33c50be authored by webchick's avatar webchick

Issue #2061927 by joelpittet, InternetDevels, m1r1k: Remove references to...

Issue #2061927 by joelpittet, InternetDevels, m1r1k: Remove references to global  in History module.
parent 6819e5e0
......@@ -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()) {
......
......@@ -38,8 +38,7 @@ public function usesGroupBy() {
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 @@ public function buildOptionsForm(&$form, &$form_state) {
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 @@ public function render(ResultRow $values) {
// 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');
......
......@@ -60,9 +60,8 @@ protected function valueForm(&$form, &$form_state) {
}
public function query() {
global $user;
// This can only work if we're authenticated in.
if (!$user->isAuthenticated()) {
if (!\Drupal::currentUser()->isAuthenticated()) {
return;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment