Closed (fixed)
Project:
Drupal core
Version:
11.x-dev
Component:
user.module
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
12 Mar 2019 at 10:23 UTC
Updated:
28 Dec 2024 at 23:19 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
lamp5Comment #3
lamp5Comment #8
ranjith_kumar_k_u commentedRe-rolled #2 for 9.4.
removed following code from the patch because the change is already there.
Comment #11
smustgrave commentedThis issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.
Couldn't find the meta but this would fall under replacing service calls with dependency injections one.
Comment #12
alexpottThis should use property promotion and also needs to do a deprecation dance... something like this
Note a change record will need to be put in place.
Comment #13
sahil.goyal commentedAddressed #12 as per that updating patch and attaching the inter_diff along.
Comment #14
ranjit1032002Addressed #12 as per that updating patch and attaching the inter_diff along.
Comment #15
ranjit1032002attaching the inter_diff
Comment #17
krzysztof domański@Ranjit1032002 try
Comment #18
Abhisheksingh27 commentedComment #19
Abhisheksingh27 commentedAdding updated #14 patch after change record.
Comment #20
smustgrave commentedNeeds the change record to review now.
Comment #21
krzysztof domańskiChange record https://www.drupal.org/node/3347878
Still needs work. Change link
https://www.drupal.org/node/TBD.+ @trigger_error('Calling' . __CLASS__ . '::__construct() without the $currentUser argument is deprecated in drupal:10.1.0 and is removed in drupal:11.0.0. See https://www.drupal.org/node/TBD', E_USER_DEPRECATED);Comment #22
krzysztof domański1/ Naming conventions should be consistent throughout the code. Change $currentUser to $current_user.
public function __construct(array $configuration, $plugin_id, $plugin_definition, AccountProxyInterface $currentUser = NULL) {2/ It should be more descriptive.
Comment #23
tanuj. commentedUpdated the patch as per #21 & #22, please review.
*interdiff is with #19
Comment #24
krzysztof domański'Calling' . __CLASS__ . '::__construct() without the $currentUser argumentOne more $currentUser to change to $current_user.
Comment #25
krzysztof domańskiComment #26
tanuj. commentedUpdated according to #24. please review.
Comment #27
smustgrave commentedWill need a simple deprecation test to ensure the message is returned correctly
Comment #29
drupgirl commentedThis patch was working great, but it no longer applies to 10.3.1 resulting in the following error that prevents the upgrade.
Fatal error: Could not check compatibility between Drupal\user\Plugin\views\argument_default\CurrentUser::create(Drupal\user\Plugin\views\argument_default\ContainerInterface $container, arr
ay $configuration, $plugin_id, $plugin_definition) and Drupal\views\Plugin\views\PluginBase::create(Symfony\Component\DependencyInjection\ContainerInterface $container, array $configuration
, $plugin_id, $plugin_definition), because class Drupal\user\Plugin\views\argument_default\ContainerInterface is not available in .../web/core/modules/user/src/Plugin/views/argument_default/CurrentUser.php on line 53
Comment #30
drupgirl commentedOh so the only part of the patch that is needed for 10.3 is this. Once applied the update works.
diff --git a/core/modules/user/src/Plugin/views/argument_default/CurrentUser.php b/core/modules/user/src/Plugin/views/argument_default/CurrentUser.php
index 251d47198b..b0c11febe4 100644
--- a/core/modules/user/src/Plugin/views/argument_default/CurrentUser.php
+++ b/core/modules/user/src/Plugin/views/argument_default/CurrentUser.php
@@ -4,7 +4,9 @@
use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\CacheableDependencyInterface;
+use Drupal\Core\Session\AccountProxyInterface;
use Drupal\views\Plugin\views\argument_default\ArgumentDefaultPluginBase;
+use Symfony\Component\DependencyInjection\ContainerInterface;
Comment #31
nikolay shapovalov commentedThat's great I found this issue, because I wasn't sure if DI should be used here.
I will update patch, update message, add deprecation test and move from patch to MR approach.
Comment #33
nikolay shapovalov commentedMark
$current_userargument as nullable.MR is ready for review.
Comment #34
nikolay shapovalov commentedComment #35
smustgrave commentedLeft some comments on the MR.
Comment #36
nikolay shapovalov commentedThanks for feedback. I will update MR.
Comment #37
nikolay shapovalov commentedThanks again for your feedback. I made changes, MR is ready for review.
Introduce return type hinting for create() is better at #3050720: [Meta] Implement strict typing in existing code.
Comment #38
nikolay shapovalov commentedI update deprecation test, because after changing currentUser to property promotion unit test failed.
Should we add type hinting for property or skip for now and add only at D12?
Comment #39
nikolay shapovalov commentedI hide all patch files.
MR updated: move deprecation test to user module.
Comment #40
smustgrave commentedWill agree with the static return.
Rest of the feedback appers to be addressed.
Comment #41
alexpottI removed the test because we do not require tests for constructor changes like this.
Committed 6728ca1 and pushed to 11.x. Thanks!
Comment #43
nikolay shapovalov commentedGreat job, thanks for merging.
It looks like we forgot to change argument name at deprecation message.
But at construct
Comment #44
alexpott@nikolay shapovalov I committed a quick follow-up to fix this.