Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
This issue deals with #2494695: [meta] Deprecate dependency setters and getters on interfaces for \Drupal\language\LanguageNegotiatorInterface
.
Comment | File | Size | Author |
---|---|---|---|
#9 | drupal_2494703_9.patch | 746 bytes | Xano |
#9 | interdiff.txt | 836 bytes | Xano |
Issue fork drupal-2494703
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #1
XanoComment #2
jhodgdonSecond line should be indented the way we do on @throws and other tags.
Comment #3
XanoYou're right, thanks!
Comment #5
XanoForgot to commit the change locally before making the patch...
Comment #6
jhodgdonThanks! Tthe formatting looks good to me now.
But I cannot comment on whether the methods should be deprecated, so I think I'll leave the RTBC to someone else... and this is probably not really just Documentation: deprecating a function is not really a docs issue.
Comment #7
Mile23Coding standards say: https://www.drupal.org/coding-standards/docs#deprecated
Should say "@deprecated in 8.1.x for removal before Drupal 9.0.x. Inject the current account using the constructor."
Also, we need an issue to add the constructor parameter.
Comment #9
XanoThanks for the review, @Mile23! I updated the comment, and included a to-do to the newly created follow-up issue as per #7.
Comment #10
Mile23Patch still applies.
Ossum.
Comment #11
xjmI think this makes sense to deprecate in 8.2.x for removal in 9.x, to not pollute the API with setters for things that should never be changed after the object is constructed.
When we do deprecations, we should document what usages exist in core, to ensure they are not "wishful deprecations". For this method, based on a grep, it looks to be:
(Other references appear to be a similarly named method on other objects.) So that's two cases where it's being set by other code, the main implementation itself, and its tests.
Looking at those two usages, in
LanguageRequestSubscriber
:That's not actually part of the constructor for
LanguageRequestSubscriber
, even thoughLanguageRequestSubscriber::__construct()
receives both the current user and the negotiator. Why is it being set during a particular method call?Similarly looking at
PathProcessorLanguage
:That one is on construction, so we are good there.
I also think the deprecation needs an example or a slight clarification. I assume this means that
LanguageNegotiatorInterface
implementations should be defined with the current user as a parameter for their constructors. Can we spell that out a bit more clearly, and possibly give/reference an example?Finally, I tagged #2494695: [meta] Deprecate dependency setters and getters on interfaces for framework manager review, so we should probably wait on that signoff to proceed with this. (Makes sense to me, but I'm not a framework manager.)
Thanks all!
Comment #12
XanoThanks for taking the time to explain this and for including examples. I'll await the framework manager response in the other issue.
Enjoy your weekend! :)
Comment #25
alexpottWe now have deprecation procedures that involve triggering a silenced E_USER_DEPRECATED notice and removing all usages in core apart from legacy testing. So there's work to do here.
I think the idea of removing unnecessary API and unnecessary setters is correct.