Needs work
Project:
Drupal core
Version:
main
Component:
cache system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
13 Apr 2016 at 19:48 UTC
Updated:
22 Aug 2023 at 11:33 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
dawehnerMh, so
\Drupal\Core\Menu\MenuParentFormSelector::parentSelectOptionsTreeWalkcalls out towhich is not on the interface, is this really what we want?
In generla having a BC layer aka. an old instance of the class seems totally worth it, and doesn't cause issues for people, so I don't get why breaking interfaces here is okay.
Comment #3
wim leers#2: Because we should typehint to interfaces, not implementations.
Comment #4
dawehner@Wim Leers
Sure, but to be honest CacheableMetadata is a value object for me, so additional implementations don't make that much sense.
Comment #5
wim leersNote that callers of this code won't have to change anything. Only implementations (of which likely zero exist at this time) would have to be updated.
Comment #6
wim leersAlso, once those two are removed, we'll have zero typehints to
CacheableMetadataleft! The only remaining ones then are in test coverage/ internals.This is again shows that typehinting to those concrete classes was simply a mistake, an oversight, a bug. This fixes that. Everything else typehints to
(Refinable)CacheableDependencyInterface. For a very similar example, see\Drupal\Core\Menu\LocalTaskManagerInterface::getTasksBuild().Comment #7
wim leersComment #8
dawehnerI still don't see why we freak out ..., for the static method
and other reasons we need to BC when we rename anyway.You know, we promised the BC. I think we should break if just if there is an actual benefit.
Comment #9
dawehnerI don't disagree with that, but that is simply not my point here.
Comment #10
effulgentsia commentedNot really. From https://www.drupal.org/core/d8-bc-policy:
Interfaces follow a similar pattern as above with respect to @api, @internal, or neither. However, in case of neither tag, the interface is treated as an API for callers but not for implementors.
Well, how do we rename a concrete class per #2561773: CacheableMetadata is misnamed? Should
NewClassName extends OldClassNameorOldClassName extends NewClassName? If the former, then contrib module 1 cannot change its typehints toNewClassNamebecause contrib module 2 might still be passing in objects of typeOldClassName. If the latter, then neither core nor contrib modules can retain typehints toOldClassName, because most likelyNewClassNameobjects are being passed. So essentially, any typehint to a concrete class name (as opposed to an interface) prevents the renaming of that class name.Comment #11
effulgentsia commentedI downgraded priority in #10, because the Major priority was an artifact of me cloning from the parent issue. If we end up not doing this issue, we might be able to solve the parent issue via #2561773-52: CacheableMetadata is misnamed, which is less ideal, but possible, so therefore, this issue should be prioritized on its own merits, not as a hard blocker.
Comment #12
dawehnerOh yeah both directions are just horrible. What about using https://secure.php.net/manual/en/function.class-alias.php ? (see https://3v4l.org/Ntu7n it runs perfectly)
In general renaming classes feels really painfull.
Comment #13
wim leersWoah! Mind=blown.
@dawehner++
@dawehner++
So, then would you agree with NOT doing this issue, and doing this in the parent issue (#2561773: CacheableMetadata is misnamed)?
CacheableMetadatatoCacheabilitymerge()as deprecated, to be removed in 8.2 (edited)Comment #14
dawehnerSO yeah for the alias you afaik put a
class_alias()call into the file which would have contained the former class.@Wim Leers
I'm confused about your point 3, there are like a gazillion amount of calls to
merge()Comment #15
wim leersToo late now. Moving to 8.2, removing RC target triage tag.
However, I still think the patch in #7 makes sense, even independently of #2561773: CacheableMetadata is misnamed. Per the first paragraph of #10 that is okay.
Comments #10-paragraph-2, #11, #12, #13 and #14 actually belong on #2561773: CacheableMetadata is misnamed.
Comment #29
smustgrave commentedThis issue is being reviewed by the kind folks in Slack, #need-reveiw-queue. We are working to keep the size of Needs Review queue [2700+ issues] to around 200, following Review a patch or merge require as a guide.
Wondering after 7 years for Drupal10.1 if this is still relevant?
Comment #31
catchI think between changing the type hints to the interface and using class_alias() that would allow us to do the other issue without breaking bc, so still seems valid.
Comments on the patch:
I doubt anyone is subclassing this, but I think we should probably remove the entire parameter from the interface in Drupal 10, add a commented out one to indicate it's going to be added back with the new type hint, then change the type hint in Drupal 12. Pretty sure this allows an implementation to update their own type hint in Drupal 10, see example 3 on #3050720: [Meta] Implement strict typing in existing code.
And the same here.