Problem/Motivation

From #2551907: Follow-up for #2483183: make the Breadcrumb value object use composition instead of inheritance :

@yched :

CacheableMetadata trips me up each time as implying that it is "metadata that you can cache". Rather, it's the metadata describing the "cacheability of something" --> CacheabilityMetadata would be more accurate ?

@Wim Leers :

Dear god thank you yes!!!!!!!
I discussed this with catch almost 2 months ago and he agreed we should rename CacheableMetadata to Cacheability. I fear it's too late now though :(

@yched :

Yeah :-/ Given the importance render cache has in D8 (currently and even more after SmartCache), and the fact that it's ... complex enough ;-) (see the discussions in #2556889: [policy, no patch] Decide if SmartCache is still in scope for 8.0 and whether remaining risks require additional mitigation), I'd think not having misleading names add to the complexity is worth the disruption. I'll create the issue and ask for release manager feedback.

In short :
The render cache and "things providing the right cacheability information" is shaping up to be one of the critical concepts to grasp in D8. Yet our central class for that, "metadata about the cacheability of something", has a name that gives you the wrong idea about what it is. That doesn't really help building and keeping a good mental model, since you have to mentally translate whenever you read / write code dealing with those :-)

Proposed resolution

Rename CacheableMetadata to
- CacheabilityMetadata
- just Cacheability ?

That is late for a BC breaking API change, obviously. Not sure whether how large the potentially impacted code might be though.

Alternatively, we could keep a legacy/deprecated "CacheableMetadata extends [NewBetterName]" around for BC, and move our onternal code to the more accurate [NewBetterName] ?

Remaining tasks

Release manager feedback needed

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue category Bug : class is a central piece of the API, but its name describes it for what it's not
Issue priority Major : major DX bug in a critical API
Disruption Breaks code, obviously, but not sure what would be the exact extent
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

yched created an issue. See original summary.

yched’s picture

Filed as major for now, I'd argue that, as a "major/critical DX issue within a critical API", it could qualify as critical.

Personal thoughts for the name :
I guess Cacheability works, it kind of feels incomplete somehow :-)
I find CacheabilityMetadata clearer and easier to use in sentences / code comments / discussions.
No biggie - and, yes, guilty : https://twitter.com/yched/status/638735993219235840

yched’s picture

Issue summary: View changes

without messing the beta evaluation table

yched’s picture

Issue summary: View changes
Wim Leers’s picture

Component: render system » cache system

@yched++

Quoting a new comment I just posted: #2551907-26: Follow-up for #2483183: make the Breadcrumb value object use composition instead of inheritance:

#25: The sole reason CacheableMetadata exists as its own thing, is to do calculations with cacheability metadata. I.e. for internal uses. Perhaps it should've been marked as @internal. (Perhaps we can do that in #2561773?)

So yes, every class should implement CacheableDependencyInterface, and no, you should generally not ever interact with CacheableMetadata.

The main purpose of CacheableMetadata is for computing the cacheability of various different CacheableDependencyInterface objects (access results, renderables, Entities, Contexts, et cetera) after they have been combined in some way to compute something else.

Wim Leers’s picture

Status: Active » Needs review
FileSize
1.48 KB

catch and I prefer Cacheability.

My reasoning: the "metadata" suffix is unnecessary, because "cacheability" already implies metadata: a value object capturing "cacheability" cannot have any other meaning, purpose or interpretation than "metadata". So, including the "Metadata" suffix would make it a pleonasm IMO.


Attached is the minimally viable patch.

yched’s picture

Thanks for the explanation Wim. That makes sense and helps understanding that area, although it is indeed not too clear to me by looking at the code / API.

But then :

- if "you should generally not ever interact with CacheableMetadata", then it means the BC break impact of a rename is likely to be small ?

- If CacheableMetdata is "later, internal step in the pipeline", then for the "public API" side I guess it's more CacheableDependencyInterface I struggle with :-) I have a hard time mentally understanding "I am a 'cacheable dependency' " as "I have cacheability metadata that you want to take into account".
I guess it's the "dependency" bit, I don't see how "being cacheable / having cacheability info" makes me a "dependency" (of what ?), can't really map that to, for example, what config dependencies are.

[crosspost : fine with Cacheability :-) ]

yched’s picture

And class Cacheability implements RefinableCacheableDependencyInterface,
i.e : "a Cacheability is a (refinable) cacheable dependency" confuses me the same way :-)

Would s/CacheableDependencyInterface/HasCacheabilityMetadataInterface be accurate ?
Or even CacheabilityInterface ?
(leaving aside "feasibility and impact of such a rename at this point" - just trying to see if I get the concepts and model right)

Wim Leers’s picture

The name CacheableDependencyInterface was selected after extensive debate in #2444231: Fix CacheableInterface so it makes sense (was: "Make Config objects & Entities implement CacheableInterface + add BubbleableMetadata::createFromCacheableObject()").

The reasoning is: this object can be a dependency of another object (or some computation), and it's not a pseudo-random object, no, it is an object that, if it is a dependency of something, is cacheable, i.e. it does not prevent caching.

(First it was called CacheableInterface, but we decided that made no sense in #2444231-22: Fix CacheableInterface so it makes sense (was: "Make Config objects & Entities implement CacheableInterface + add BubbleableMetadata::createFromCacheableObject()"), -23, -26 and -27.

RefinableCacheableDependencyInterface is a more recent addition (also selected after extensive debate, in #2512718: EntityManager::getTranslationFromContext() should add the content language cache context to the entity), and is layered on top of the above reasoning. Its reasoning: this object that is a cacheable dependency also has variants (think entity translations, it's always the same underlying entity, but just with the data it contains being different); which variant it is depends on external factors. It is then refinable so you can add cache contexts/tags, so the loaded object can itself contain the reason why that specific variant (e.g. entity translation) was loaded (e.g. the "negotiated content language" cache context).

Also, this is all documented over at https://www.drupal.org/developing/api/8/cache/cacheable-dependency-inter... :)


Would s/CacheableDependencyInterface/HasCacheabilityMetadataInterface be accurate ? (leaving aside "feasibility and impact of such a rename at this point" - just trying to see if I get the concepts and model right)

Theoretically that could work, but it takes a slightly different world view.

With CacheableDependencyInterface, we say that an object that implements it, and when that object is used as a dependency in some computation, that it allows that computation's result to be cached. This is the entire point of cache tags, contexts and max-age. That cacheability metadata is inherent to the object in question (think a Node entity's node:5 cache tag).

With HasCacheabilityMetadataInterface, we say that an object has a value object that contains cacheability metadata. The same things are possible. But it's not as strong a connection: it does not communicate the inherent nature, nor does it communicate the point of this metadata. It almost seems like a "oh, by the way, I have this pile of metadata too".

Status: Needs review » Needs work

The last submitted patch, 6: rename_cacheablemetadata-2561773-6.patch, failed testing.

yched’s picture

Thanks @Wim. I still find it a bit backwards to couple the name after the use intent ("I can be passed to the addCacheableDependency() method of some other object") rather than by what the standalone object is ("I have cacheability info, deal with it"). Also, just like CacheableMetadata, CacheableDependency seems to qualify those objects as "cacheable", while this is not about caching *them*.

But well, looks like that ship has sailed after intensive debate that I didn't bother take part in :-). Sorry for reopening that, never mind.

Regarding just the CacheableMetadata rename then :
Actually, the real understandability win would be to rename the various getCacheableMetdata() methods accordingly...
It's code like $response->getCacheableMetdata() that is actually the most misleading to read - as if this was about caching something else than the $response.

AFAICT that affects CacheableResponseInterface and CacheContextInterface - the latter of which has many implementations :-/, but maybe not that much in contrib yet ?

borisson_’s picture

Status: Needs work » Needs review
FileSize
10.66 KB

Patch in #6 did not apply, attached a reroll. I'm also +1 to renaming to Cacheability.

Wim Leers’s picture

CacheableDependency seems to qualify those objects as "cacheable", while this is not about caching *them*.

Hah! That's actually exactly why it's called cacheable dependency interface, and not cacheable interface! Because it's not about caching them, but they may be a dependency of something that we end up caching! That's what I tried to explain earlier but clearly did not succeed.
Does that make sense now?
Can you think of a better way to explain it?
Great discussion :)

Actually, the real understandability win would be to rename the various getCacheableMetdata() methods accordingly...

Just to make sure I understood that correctly… you mean renaming them to getCacheability(), right?

AFAICT that affects CacheableResponseInterface and CacheContextInterface - the latter of which has many implementations :-/, but maybe not that much in contrib yet ?

Correct, I don't think there's any yet. It's only necessary for advanced use cases anyway (for every custom thing to vary by). So disruption would be very minimal.

yched’s picture

That's actually exactly why it's called cacheable dependency interface, and not cacheable interface! Because it's not about caching them, but they may be a dependency of something that we end up caching! That's what I tried to explain earlier but clearly did not succeed.

Sure, I got the explanation, but I'm really skeptical that we can force people's brains to understand "CacheableDependencyInterface",
- not as : "a dependency that is cacheable" (which it is not, but is how the name does read IMO)
- but as : "a dependency of something that is cacheable" (which it is) instead

Which is why qualifying those objects as "I have cacheability info" rather than "something cacheable can use me as a dependency" would IMO be easier. Shaping the interface name to qualify the object, rather than the other objects using that object, means you don't need to find ways to convey that some parts of the name qualify the object ("dependency") and some other parts qualify the "other objects using that object" ("cacheable"), which seems quite a grammatical challenge :-)

Just to make sure I understood that correctly… you mean renaming them to getCacheability(), right?

Yep, I meant s/getCacheableMetadata()/getCacheability() :-)

+ Last attempt at defending "CacheabilityMetadata" : consistency with BubbleableMetdata ? Again, no biggie...

Crell’s picture

Shaping the interface name to qualify the object, rather than the other objects using that object, means you don't need to find ways to convey that some parts of the name qualify the object ("dependency") and some other parts qualify the "other objects using that object" ("cacheable"), which seems quite a grammatical challenge :-)

This. That sentence alone summed up all of my confusion about CacheableDependency*. An interface should describe the object, not the relationship of an object to some undefined and arbitrary other object. That some other object happens to use it a certain way is incidental, by design, because different objects can use it in potentially different ways.

Wim Leers’s picture

Sure, I got the explanation, but I'm really skeptical that we can force people's brains to understand "CacheableDependencyInterface",
- not as : "a dependency that is cacheable" (which it is not, but is how the name does read IMO)
- but as : "a dependency of something that is cacheable" (which it is) instead

No, it is a dependency that is cacheable.

You indeed don't know how an object is going to be used. The point is that any object that does implement CacheableDependencyInterface is a cacheable dependency (a dependency that is cacheable). So any object depending on it, if it wants to do caching, then it is possible if and only if it depends if all objects it depends on are cacheable dependencies.

yched’s picture

#13 (emphasis mine)

That's actually exactly why it's called cacheable dependency interface, and not cacheable interface! Because it's not about caching them, but they may be a dependency of something that we end up caching

#17

No, it is a dependency that is cacheable.

Hm - what ? I'm just more confused then :-)

The two statements can only coexist if "cacheable" doesn't mean "something that will possibly be cached - written into a cache store and read back later so that we don't recompute it from scratch" - which I'd think is a reasonable/common understanding of the word ?

It's that same common definition of "cacheable" that led us to conclude that what is currently called CacheableMetdata is not something that is "cacheable", hence the "CacheableMetadata is misnamed" issue title.

So, paraphrasing your sentences about CachebleDependencyInterface objects, I'd think :
- "it's not about caching them" = they are not the "cacheable" things,
- "but they may be a dependency of something that we end up caching" = they are "a dependency of something cacheable", not "a dependency that is cacheable"
- "any object depending on it, if it wants to do caching ..." = "if it wants to be cacheable, it can have dependencies that provide associated cacheability info (but are not themselves being cached/cacheable)"

In "Entity instanceof CacheableDependencyInterface", it's not the Entity that is cached/cacheable, it's some render output, of which the Entity is a dependency.
Same in "FieldStorgeDefinitionInterface instanceof CacheableDependencyInterface", this is never about caching the field definition.
(those two happen to have their own caches, but that's irrelevant here, and possibly even adds to the confusion...)

Really sorry for the pedantic (and remote :-/) hair splitting at this point. As the discussion shows, names do go a long way clarifying or obscuring the (fairly critical) underlying mental model (what is it that gets cached / what is it that provides cacheability info about that cached thing)

yched’s picture

Also, #2476407: Use CacheableResponseInterface to determine which responses should be cached, where cacheable does mean "will be cached / written into a cache store".
CacheableResponseInterface, CacheableMetadata and CacheableDependency cannot use the same meaning of "cacheable"

Wim Leers’s picture

Assigned: Unassigned » effulgentsia

they are "a dependency of something cacheable", not "a dependency that is cacheable"

No, it is "a dependency that is cacheable".

In "Entity instanceof CacheableDependencyInterface", it's not the Entity that is cached/cacheable, it's some render output, of which the Entity is a dependency.
Same in "FieldStorgeDefinitionInterface instanceof CacheableDependencyInterface", this is never about caching the field definition.
(those two happen to have their own caches, but that's irrelevant here, and possibly even adds to the confusion...)

100% correct.

CacheableResponseInterface, CacheableMetadata and CacheableDependency cannot use the same meaning of "cacheable"

I disagree.

CacheableMetadata is a misnomer: it's not the metadata that is cacheable, it's (a value object containing) metadata describing cacheability. So there, you are right. But that's also why we have this issue to rename it so it makes sense.

CacheableResponseInterface and CacheableDependencyInterface are consistent and have the same meaning. The first says "a responses that can be cached", the second says "a dependency that can be cached".

I think that this issue needs @effulgentsia, who is a native speaker, was instrumental in arriving at the name CacheableDependencyInterface, and is able to explain these things much more clearly than most of us most of the time :)

yched’s picture

Yeah, looks like there's something I'm really not getting, or we're talking past each other somehow (my bad for not being in Barcelona :-/)

CacheableResponseInterface and CacheableDependencyInterface are consistent and have the same meaning. The first says "a responses that can be cached", the second says "a dependency that can be cached".

Yet you agree with :
"Entity instanceof CacheableDependencyInterface is not about caching the entity, FieldStorgeDefinitionInterface instanceof CacheableDependencyInterface is not about caching the field definition, but about caching something else that states it has a dependency on it.

I'm struggling to see how that does not contradict :-) It can be cached, yet it's not what we're interested in caching ?

Is it :
"it's something with cacheability info so we *could* cache it if we wanted, but it so happens that we're not interested in *actually* caching it, we only use the cacheability info to cache something else that uses it as a dependency"
?

Wim Leers’s picture

it's something with cacheability info so we *could* cache it if we wanted, but it so happens that we're not interested in *actually* caching it, we only use the cacheability info to cache something else that uses it as a dependency

Basically, yes.

yched’s picture

@Wim : Thanks :-) Still feels a bit weird to me, being actually cacheable is more than just providing cacheability info, there are implementation concerns if an object is *really* going to be serialized to a persistent storage. But well, I'll shut up now :-)

As for CacheableMetadata, do you think a rename is still doable ?
and for the getCacheableMetadata() methods ?

Wim Leers’s picture

I think a rename is still doable, as long as we keep supporting the old name, and just mark it deprecated.

It is too late (and already was when we opened this issue) to rename the methods I think.

Using this approach, we have zero disruption.

yched’s picture

Status: Needs review » Reviewed & tested by the community

RTBC then ?

(although : couldn't we similarly add new getCacheability() methods and deprecate the old ones ?)

Wim Leers’s picture

#25: no, that would still change the interface.

catch’s picture

We could add a new interface extending the old interface for that. But probably in a followup?

Wim Leers’s picture

Issue tags: +rc deadline

I think it's indeed better to do that in a follow-up. This issue covers the most visible part.

Wim Leers’s picture

Assigned: effulgentsia » catch

This is a catch issue.

dawehner’s picture

There is the thing of renaming, but can we please also get sane documentation?

+++ b/core/lib/Drupal/Core/Cache/Cacheability.php
@@ -0,0 +1,189 @@
+/**
+ * Defines a generic class for passing cacheability metadata.
+ *
+ * @ingroup cache
+ *
+ */
+class Cacheability implements RefinableCacheableDependencyInterface {

This documentation doesn't tell you much. It should be explained in which causes it should be used for example.

Wim Leers’s picture

Assigned: catch » Wim Leers
Status: Reviewed & tested by the community » Needs work

Totally agreed, doing that now.

Also, repeating what I quoted in #5, and with emphasis added:

#25: The sole reason CacheableMetadata exists as its own thing, is to do calculations with cacheability metadata. I.e. for internal uses. Perhaps it should've been marked as @internal. (Perhaps we can do that in #2561773?)

So yes, every class should implement CacheableDependencyInterface, and no, you should generally not ever interact with CacheableMetadata.

The main purpose of CacheableMetadata is for computing the cacheability of various different CacheableDependencyInterface objects (access results, renderables, Entities, Contexts, et cetera) after they have been combined in some way to compute something else.

Thoughts?

yched’s picture

+1 on bringing that into the phpdoc for Cacheability :-)

Wim Leers’s picture

Assigned: Wim Leers » catch
Status: Needs work » Needs review
FileSize
11.48 KB
1.59 KB

I rewrote and refined this at least five times. I hope you like it.

Fabianx’s picture

+++ b/core/lib/Drupal/Core/Cache/Cacheability.php
@@ -0,0 +1,202 @@
+  public function getCacheMaxAge() {
+    return $this->cacheMaxAge;
+  }
...
+  public function merge(CacheableMetadata $other) {
+    $result = clone $this;

Are we really sure we want to keep an API, which is sometimes immutable and sometimes not.

I (and many others) found this really confusing.

$cacheability->addCacheTags(['foo']);
$cacheability->merge($other_object);

Or even better:

$cacheability->addDependency($other_object);

...

Just some food for thought ...

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Thanks a lot

Wim Leers’s picture

#35: I share your concerns, but that's out of scope here. This is just about renaming. Very few things call this, so *maybe* and *hopefully* we'll be able to still fix that during RC. But we must assume it is too late to change that. We'll see. The reason this rename is possible still is that it doesn't break anything: we keep full BC.

Fabianx’s picture

Status: Reviewed & tested by the community » Needs review

Well, I prefer addDependency() anyway over merge, which is just an addition and way less overloaded in terms of mutability.

And no it is the addition of a new Interface, so we could do changes here - that is why I am asking if we do not want to not copy merge() over and leave merge() just on the old class.

merge() btw. takes only a CacheableMetadata anyway right now, so should that not be Cacheability?

Wim Leers’s picture

That's a great point!

This still keeps full BC.

In doing that, I also noticed that Cacheability/CacheableMetadata still has getCache(Tags|Contexts|MaxAge)() methods, even though those are already provided by the RefinableCacheableDependencyTrait that it uses. So, simply removed those.

Fabianx’s picture

Status: Needs review » Reviewed & tested by the community

Little nits, can be fixed on commit:

+++ b/core/lib/Drupal/Core/Cache/Cacheability.php
@@ -0,0 +1,135 @@
+   * Applies the values of this CacheableMetadata object to a render array.
...
+   * Creates a CacheableMetadata object with values taken from a render array.
...
+   * Creates a CacheableMetadata object from a depended object.

Cacheability

effulgentsia’s picture

Status: Reviewed & tested by the community » Needs review

HEAD still has 300 occurrences of "CacheableMetadata". I don't think we necessarily need to convert all of them in this patch, but I think updating the issue summary with a plan of what we think the eventual end state will be will help us evaluate whether this is a good idea. Is it possible to organize all of HEAD's usages into buckets (e.g., CacheContextInterface::getCacheableMetadata(), usages in \Drupal\Core\Menu, etc.) and figure out how this name change will eventually fit in to those mental models?

Wim Leers’s picture

We could easily convert the vast majority in this patch, but the idea was to keep it as simple as possible here.

Regarding the several getCacheableMetadata() methods: my understanding is that those are frozen, and cannot be changed anymore, see #24 + #25 + #26.

I'm not quite sure what you want me to do here now?

effulgentsia’s picture

In reading some of this issue's comments of people struggling with the concept of "cacheable dependency", I looked at the docs of CacheableDependencyInterface and found:

* All cacheability metadata exposed in this interface is bubbled to parent
* objects when they are cached: if a child object needs to be varied by certain
* cache contexts, invalidated by certain cache tags, expire after a certain
* maximum age, then so should any parent object.

I think this adds to the confusion, because the use of the word "bubbled" here I think means that "parent" refers to parent elements in the render array tree. In which case, these docs belong on CacheableMetadata (or with this patch, Cacheability). And the docs on this interface should not be about bubbling, but about how the information benefits / transfers to dependents (e.g., via ->addCacheableDependency()).

effulgentsia’s picture

Re #42, sure, let's keep getCacheableMetadata() frozen, but change its @return to Cacheability.

And for everywhere where the CacheableMetadata class is still used, let's either convert all of those usages, or if it would simplify this patch, at least ones used in type-hints and docs of non-test code.

effulgentsia’s picture

Also, something we should figure out here (perhaps via a comment from @catch) is whether we're expecting all of contrib to change their type-hints from CacheableMetadata to Cacheability. Because if not, then does that mean that core will need to keep getCacheableMetadata()'s and other @return types as CacheableMetadata? If so, I'm not sure if this patch really improves the mental model. Instead, it makes people have to remember when to use which name.

Wim Leers’s picture

Sounds like this needs a decision or at least input from catch to move forward.

catch’s picture

If Cacheability extended CacheableMetadata then doesn't #45 become a non-issue?

Also where are those contrib type hints? Why can't they type hint on RefineableCacheableDependencyInterface?

joelpittet’s picture

We've passed RC deadline on this one. Is this "rc target" eligible @catch?

effulgentsia’s picture

Issue tags: -rc deadline +rc target triage

Adding the new "rc target triage" tag per https://www.drupal.org/core/d8-allowed-changes#rc so that we triage it on our next triage call.

catch’s picture

#47 still needs an answer to determine how much of a bc break this might or might not end up being.

effulgentsia’s picture

Answering #47:

If Cacheability extended CacheableMetadata then doesn't #45 become a non-issue?

The problem with that would be that the return value from something that returns CacheableMetadata (e.g., all contrib implementations of CacheContextInterface::getCacheableMetadata()) couldn't be passed to something that improved its typehint to Cacheability.

Also where are those contrib type hints? Why can't they type hint on RefineableCacheableDependencyInterface?

I don't know what contrib functions typehint params to CacheableMetadata, but 2 core examples are MenuParentFormSelectorInterface::getParentSelectOptions() and CachePluginBase::alterCacheMetadata(). I don't think either of those examples would make much sense with RefineableCacheableDependencyInterface. There's not a dependency that you're refining (e.g., an entity being refined by a language); there's cache metadata that you're collecting/aggregating. So I'm guessing that there's likely to be some contrib/custom module in a similar situation of having a CacheableMetadata typehint, but I don't know.

Personally, per #45, I think the addition of Cacheability and deprecation of CacheableMetadata should be punted to 8.1 at this point.

effulgentsia’s picture

I suppose one way to make this all BC would be to make Cacheability extends CacheableMetadata and CacheableMetadata implements CacheabilityInterface. Then @param typehints could be narrowed from CacheableMetadata to CacheabilityInterface while Cacheability return values could still be passed to all places that still typehint on CacheableMetadata.

I still think that's a better thing to do for 8.1 than 8.0, but I'm open to counterarguments or @catch deciding otherwise.

Wim Leers’s picture

Pinged @catch about this, so he can decide.

xjm’s picture

Version: 8.0.x-dev » 8.1.x-dev
Issue tags: -Needs release manager review

This definitely needs to be 8.1.x now, and we should also use an approach like #52 so that there is not a BC break. Thanks!

xjm’s picture

Issue tags: -rc target triage

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

cilefen’s picture

+++ b/core/lib/Drupal/Core/Cache/CacheableMetadata.php
@@ -7,83 +7,14 @@
+ * @deprecated in Drupal 8.0.x, will be removed before Drupal 9.0.0. Use
+ *   \Drupal\Core\Cache\Cacheability instead.

The deprecation version needs an update in the next patch.

catch’s picture

Assigned: catch » Unassigned

#52 is the sort of thing I was suggesting for this - so assuming it actually works out as non-breaking that sounds good. Un-assigning.

catch’s picture

Status: Needs review » Needs work
Wim Leers’s picture

The problem with #52 is that we still can't get rid of the merge() method that is defined on CacheableMetadata: Cacheability extends CacheableMetadata means it inherits it!

dawehner’s picture

The problem with that would be that the return value from something that returns CacheableMetadata (e.g., all contrib implementations of CacheContextInterface::getCacheableMetadata()) couldn't be passed to something that improved its typehint to Cacheability.

Could we turn it around and let Cacheability extend CacheableMetadata, and keep the code in the later for now, while still marking CacheableMetadata as deprecated?

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Wim Leers’s picture

Issue tags: +Drupal 9

Let's do this before Drupal 9 ships.

catch’s picture

Issue tags: -Drupal 9

Sorry I'm nuking the Drupal 9 tag - this could happen in any minor release whether Drupal 8 or Drupal 9. Doesn't do any harm to do it sooner than later of course.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Wim Leers’s picture

Issue tags: +Novice, +php-novice

I think this is a great novice issue not to push across the finish line, but to at least get going again. I'd be happy to assist/help!

vacho’s picture

Issue summary: View changes
vacho’s picture

Wim Leers’s picture

Thanks @vacho! Unfortunately it's not passing tests yet.

This seems to have gone under the radar again. I'd still like to see this happen, so assigning to myself. Already created one issue that makes this slightly simpler: #3071572: ContextCacheKeys should implement CacheableDependencyInterface rather than extend CacheableMetadata.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

mradcliffe’s picture

Issue tags: -Novice, -

I am removing the Novice tag from this issue because there isn't anything to do if @Wim Leers is (still?) on the case. Feel free to unassign and promote the issue back though. :-)

Opinions: The patch, at this point, should probably just implement the new class and deprecate the old one for 10.0.0.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

mxr576’s picture

@Wim Leers can you please share your thoughts on #76? What should be the attack plan here?

Wim Leers’s picture

Assigned: Wim Leers » Unassigned

It's been years since I looked at this. I think I agree with the plan @mradcliffe proposes in #76. Except that deprecating in 9.4 for 10 might be too little notice for something like this — but I can't decide that, only release managers can. Perhaps @catch has thoughts?

Unassigning after the stupid self-assigning I did 3 years ago in #73 🙈

catch’s picture

There are about 40 pages of results on http://grep.xnddx.ru/search?text=CacheableMetadata&filename=&page=42, even with some false positives that's quite a lot.

Having said that, it'd be an easy rector rule.

I would probably go for deprecating in Drupal 9.4 for removal in Drupal 11 at this point - but no reason it can't happen in 9.4 with the later removal version.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

catch’s picture

Version: 9.5.x-dev » 10.1.x-dev
Category: Bug report » Task

This is a naming improvement rather than a bug as such, since it'll be a new deprecation, moving to 10.1.x

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

donquixote’s picture

Quick note: We can use class_alias() to reduce the BC impact of renaming a class.
https://3v4l.org/80D6A

It does _not_ help us with renaming methods, but we can find other solutions for that.

andypost’s picture