Part of #2047951: [META] Remove calls to deprecated global $user and $GLOBALS['user']

All places in views module should be fixed

core/modules/views/lib/Drupal/views/Plugin/views/cache/CachePluginBase.php:

global $user;

core/modules/views/lib/Drupal/views/Plugin/views/cache/CachePluginBase.php:

global $user;

core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php:

global $user;

core/modules/views/lib/Drupal/views/Plugin/views/filter/FilterPluginBase.php:

global $user;

core/modules/views/lib/Drupal/views/ViewExecutable.php:

$account = $GLOBALS['user'];
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

alphawebgroup’s picture

Status: Active » Needs review
FileSize
3.67 KB
alphawebgroup’s picture

Issue summary: View changes

Updated issue summary.

alphawebgroup’s picture

Issue summary: View changes

Updated issue summary.

alphawebgroup’s picture

Issue summary: View changes

Updated issue summary.

dawehner’s picture

Is there any reason why the request object is not injected?

dawehner’s picture

Thanks this is looking quite fine!

Is there any reason why the request object is not injected?

Status: Needs review » Needs work

The last submitted patch, 2061921-1.patch, failed testing.

alphawebgroup’s picture

@dawehner
Hi!
really don't have any reason...
I'll try to re-make that patch with injecting of request object
will back soon

dawehner’s picture

Thank you very much!

alphawebgroup’s picture

Lets separate that issue on plugin-based approach.. just to simplify and to get clear imagination for the scope of work

core/modules/views/lib/Drupal/views/Plugin/views/cache/CachePluginBase.php
#2062169: Remove calls to deprecated global $user in views plugin CachePluginBase.php of views module

core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php
#2062227: Remove calls to deprecated global $user in views plugin DisplayPluginBase.php of views module

core/modules/views/lib/Drupal/views/Plugin/views/filter/FilterPluginBase.php
#2062261: Remove calls to deprecated global $user in views plugin FilterPluginBase.php of views module

core/modules/views/lib/Drupal/views/ViewExecutable.php
#2062421: Remove calls to deprecated global $user in ViewExecutable.php of views module

andypost’s picture

Suppose it's not clear in which cases to use Drupal::currentUser() and $request..._account

+++ b/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php
@@ -2529,8 +2529,7 @@ public function renderArea($area, $empty = FALSE) {
-      global $user;
-      $account = $user;
+      $account = \Drupal::request()->attributes->get('_account')

Drupal::currentUser()

sergeypavlenko’s picture

Status: Needs work » Needs review
FileSize
3.15 KB

Status: Needs review » Needs work

The last submitted patch, drupal8.views-module.2061921-9.patch, failed testing.

sergeypavlenko’s picture

m1r1k’s picture

Issue tags: +blocked-by-request-scope

For easy tracking

joelpittet’s picture

Assigned: alphawebgroup » Unassigned
Status: Needs review » Needs work
Issue tags: +Novice, +Needs reroll

Patch doesn't apply anymore. Needs re-roll.
https://drupal.org/patch/reroll

m1r1k’s picture

Status: Needs work » Needs review
FileSize
7 KB

Rerolled

joelpittet’s picture

Status: Needs review » Needs work

@m1r1k the bottom of the file looks like extra stuff got added to the reroll some how doubling the patch size. Could you re-roll again?

m1r1k’s picture

Status: Needs work » Needs review
FileSize
3.15 KB

Oh, my fault. Fixed version:

joelpittet’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Novice, -Needs reroll

This looks ready to go, passes testbot and very straight forward changes.

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.x, thanks!

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

Updated issue summary.