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'];
Files: 
CommentFileSizeAuthor
#16 views-drupal-lib-remove-global-user-2061921-16.patch3.15 KBm1r1k
PASSED: [[SimpleTest]]: [MySQL] 58,734 pass(es).
[ View ]
#14 views-drupal-lib-remove-global-user-2061921-14.patch7 KBm1r1k
PASSED: [[SimpleTest]]: [MySQL] 58,406 pass(es).
[ View ]
#11 drupal8.views-module.2061921-11.patch3.56 KBsergeypavlenko
PASSED: [[SimpleTest]]: [MySQL] 58,081 pass(es).
[ View ]
#9 drupal8.views-module.2061921-9.patch3.15 KBsergeypavlenko
FAILED: [[SimpleTest]]: [MySQL] 58,395 pass(es), 0 fail(s), and 3 exception(s).
[ View ]
#1 2061921-1.patch3.67 KBalweb
FAILED: [[SimpleTest]]: [MySQL] Invalid PHP syntax in core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php.
[ View ]

Comments

alweb’s picture

Status:Active» Needs review
StatusFileSize
new3.67 KB
FAILED: [[SimpleTest]]: [MySQL] Invalid PHP syntax in core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php.
[ View ]
alweb’s picture

Issue summary:View changes

Updated issue summary.

alweb’s picture

Issue summary:View changes

Updated issue summary.

alweb’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.

alweb’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!

alweb’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
StatusFileSize
new3.15 KB
FAILED: [[SimpleTest]]: [MySQL] 58,395 pass(es), 0 fail(s), and 3 exception(s).
[ View ]

Status:Needs review» Needs work

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

sergeypavlenko’s picture

Status:Needs work» Needs review
StatusFileSize
new3.56 KB
PASSED: [[SimpleTest]]: [MySQL] 58,081 pass(es).
[ View ]
m1r1k’s picture

For easy tracking

joelpittet’s picture

Assigned:alweb» 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
StatusFileSize
new7 KB
PASSED: [[SimpleTest]]: [MySQL] 58,406 pass(es).
[ View ]

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
StatusFileSize
new3.15 KB
PASSED: [[SimpleTest]]: [MySQL] 58,734 pass(es).
[ View ]

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.