Problem/Motivation

In #3397522: Fork Symfony's ContainerAwareTrait and ContainerAwareInterface into core we are trying to reduce the use of ContainerAwareTrait as Symfony has deprecated it.

CacheTagsInvalidator is container aware because it needs to retrieve all cache bins by ID.

Instead of injecting the entire container we can inject the bins via a service collector method.

Steps to reproduce

Proposed resolution

Add service collector tags to CacheTagsInvalidator.

We already use service collectors for the invalidator services.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork drupal-3415940

Command icon 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

longwave created an issue. See original summary.

longwave’s picture

Status: Active » Needs review
longwave’s picture

Status: Needs review » Needs work
longwave’s picture

Status: Needs work » Needs review
spokje’s picture

Status: Needs review » Needs work

PHPCS upset about now-useless use statement.

longwave’s picture

Status: Needs work » Needs review
spokje’s picture

FWIW: One nitpick, one question and a general "I don't fully grok the test before nor after, but I'm pretty sure it's testing the same thing in both cases.".

longwave’s picture

Thanks for reviewing. I addressed the feedback.

Regarding the test: Previously the getInvalidatorCacheBins() looped through both non-memory and memory cache parameters, and then could handle services that do and don't implement CacheTagsInvalidatorInterface, so four cases in total. Now we don't need the parameters or cache bin types, the test only needs to check services that do and don't implement that interface, so there are only two cases - the memory-specific ones are redundant.

spokje’s picture

Status: Needs review » Reviewed & tested by the community

Thanks @longwave, I kinda sorta figured that about the test, all other feedback is addressed: => RTBC.

kristiaanvandeneynde’s picture

Status: Reviewed & tested by the community » Needs work

We cannot mix cache bins and memory cache bins as the latter do not 100% behave as a cache bin. For more info, see #3402850: Fix MemoryCache discovery and DX

longwave’s picture

Status: Needs work » Needs review

Thanks for reviewing. I get why they need to be separated in the cache factory, but not in the invalidator; as long as they implement the interface normal bins and memory bins are invalidated in the same way.

kristiaanvandeneynde’s picture

Status: Needs review » Needs work

As I mentioned in the review, will ask for a second opinion on whether we need to be this strict with keeping the two separated. Still NW because of the property typehint suggesting something that may not be true.

kristiaanvandeneynde’s picture

Status: Needs work » Needs review

Sorry, in my latest review comment I misread a few lines. The property can be typehinted as such as you check for the interface when the service is collecting the tagged services.

kristiaanvandeneynde’s picture

Status: Needs review » Reviewed & tested by the community

To be fair, now that I've taken a closer look and that you're checking the tagged services for the invalidator interface, I'm less fussed about it. The code makes it clear that you're not interested in the cache backends as caches, but rather as services that might implement the cache tags invalidator interface.

Just poked @catch on Slack and he also seems to be fine with it under the circumstances presented here. Sorry about the previous noise but seeing the two types of cache backends mixed together in one property automatically raised a red flag with me. After further review, it's actually quite OK the way you implemented it.

RTBC

longwave’s picture

No worries, I appreciate thoughtful reviews that take time to question what I did and why, especially when it might have side effects elsewhere.

Applied the comment improvement, leaving at RTBC.

  • catch committed 8bc5040e on 11.x
    Issue #3415940 by longwave, kristiaanvandeneynde, Spokje: Convert...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Agreed that for tag invalidation we don't need to make the persistent/memory distinction. Committed/pushed to 11.x, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.