+++ 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.
Comments
Comment #2
hardik_patel_12 commentedKindly review a patch.
Comment #3
hardik_patel_12 commentedComment #4
hardik_patel_12 commentedCombining with #3106760: \Drupal calls should be avoided in classes, use dependency injection instead in NodeAccessGrantsCacheContext.php
Comment #5
hardik_patel_12 commentedKindly review a new patch.
Comment #6
alexpottWe 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.
Comment #7
xjmThanks 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.