Problem/Motivation
In \Drupal\hal\LinkManager\LinkManagerBase
we reference a constant in \Drupal\rest\EventSubscriber\ResourceResponseSubscriber
, but Hal module doesn't depend on Rest module, so it may not be available.
The issue was introduced in #2864816: HAL LinkManager doesn't add 'url.site' cache context when needed.
It causes is issues with modules such as default_content which depends on Hal, and Multiversion / Relaxed which does a lot of serialization.
Proposed resolution
Switch to a constant defined in Hal or a core component.
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#20 | 2931765-20.patch | 12.22 KB | Wim Leers |
#17 | 2931765-17.patch | 12.15 KB | timmillwood |
#17 | 2931765-17.txt | 1.16 KB | timmillwood |
Comments
Comment #2
Wim LeersDarn, good catch :(
Comment #3
Wim LeersThis really means
\Drupal\rest\EventSubscriber\ResourceResponseSubscriber::SERIALIZATION_CONTEXT_CACHEABILITY
should be moved out ofrest.module
intoserialization.module
. Darn.Fortunately, that was newly introduced in 8.5, so we can move it without having to worry about BC, because 8.5 is not even in beta yet.
The best place in existing code for that constant to live is
\Drupal\serialization\Normalizer\NormalizerBase
, but that feels wrong too, because that's a base class, not an interface. OTOH, we kind of really want you to use that base class for all normalizers anyway… so maybe it's okay.Alternatively to that, we should add
\Drupal\serialization\Normalizer\CacheableNormalizerInterface
, which would look like this:Thoughts?
Comment #4
Wim LeersComment #5
timmillwoodI guess we should check with @damiankloip.
Adding a new interface sounds good to me though.
Comment #6
timmillwoodHere's the initial patch.
Comment #8
Wim LeersJust discussed in IRC:
Comment #9
timmillwoodFixing failing tests.
Comment #11
timmillwoodHelps if I look for the constant in the correct cacheable interface.
Comment #13
Wim LeersPut a breakpoint in
\Drupal\Core\Cache\Cache::mergeTags
and debug while running the test: that should allow you to figure out why fewer cache tags are being bubbled with this patch.Comment #15
timmillwoodThere are two other issues reporting this, so bumping to critical for 8.5.x:
#2928869: Class ResourceResponseSubscriber not found in LinkManagerBase causes fatal error
#2931765: Regression: \Drupal\hal\LinkManager\LinkManagerBase implicitly depends on REST module
Comment #16
tstoecklerMinor, but this could use
static::
now, I think.Comment #17
timmillwoodFixing failing tests and the minor point from #16.
Comment #18
manuel.adan#17 works for me, I tested it with the fixed_block_content module that depends on HAL+serialization but not on the rest module.
Comment #19
Wim Leers@manuel.adan Interesting, I didn't know that module! Thanks for posting feedback here, and testing the patch!
s/cacheable normalizers/normalizers producing cacheable results/
This also needed to update the CR: https://www.drupal.org/node/2918937 — did that.
Comment #20
Wim LeersFixed the docs nit in #19.
Comment #21
Wim LeersComment #22
catchCommitted/pushed to 8.6.x and cherry-picked to 8.5.x. Thanks!