Comments

Hardik_Patel_12 created an issue. See original summary.

hardik_patel_12’s picture

StatusFileSize
new1.23 KB

Kindly review a patch.

hardik_patel_12’s picture

Assigned: hardik_patel_12 » Unassigned
Status: Needs work » Needs review
hardik_patel_12’s picture

StatusFileSize
new3.55 KB

Kindly review a new patch.

alexpott’s picture

+++ b/core/lib/Drupal/Core/Cache/Context/UserCacheContextBase.php
@@ -20,14 +21,24 @@
-  public function __construct(AccountInterface $user) {
+  public function __construct(AccountInterface $user, ModuleHandlerInterface $module_handler) {

+++ b/core/modules/node/node.services.yml
@@ -42,7 +42,7 @@ services:
   cache_context.user.node_grants:
     class: Drupal\node\Cache\NodeAccessGrantsCacheContext
-    arguments: ['@current_user']
+    arguments: ['@current_user', '@module_handler']
     tags:

We shouldn't update the Base class constructor. We need to add a constructor to \Drupal\node\Cache\NodeAccessGrantsCacheContext()

Also there is the question of scope here. There a lot of \Drupal:: usage in Node classes that is not covered here. Plus we need to make these changes in a way that deprecates the old code path.

xjm’s picture

Status: Needs review » Closed (duplicate)

Thanks everyone for your contributions so far!.

I am closing this as a duplicate of #2729597: [meta] Replace \Drupal with injected services where appropriate in core. You can use the work in the patches from this and similar issues as starting points for new issues scoped by concept.