Problem/Motivation
#2984964-12: JSON API + hook_node_grants() implementations: accessing /jsonapi/node/article as non-admin user results in a cacheability metadata leak caused me to look at consumer_image_styles, which led me to \Drupal\consumer_image_styles\Normalizer\ImageEntityNormalizer::buildVariantValues().
There are at least two cacheability bugs there:
- It's not catching bubbled cacheability from building the file URL. (This is what #2984964-12: JSON API + hook_node_grants() implementations: accessing /jsonapi/node/article as non-admin user results in a cacheability metadata leak reported.)
- It's not adding the cacheability for the used image styles.
Proposed resolution
Fix both.
Remaining tasks
User interface changes
None.
API changes
None.
Data model changes
None.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 2985403-2.patch | 1.37 KB | wim leers |
Comments
Comment #2
wim leersThis fixes point 2.
Point 1 still needs to be fixed. Tests are also missing.
Comment #3
wim leersI think #2927782: Some derivatives are randomly missing may be a consequence of this bug.
Comment #4
madeltoro commentedThanks you alot. This issue goes to make me crazy!!! Just in time :)
Comment #5
pwolanin commentedThanks Wim - will test it out.
Comment #6
pwolanin commentedThis patch didn't fix the error I'm seeing, so might be another place (or another in addition).
Comment #7
wim leersThat's point 1 in the IS, which #2 says it did not yet fix.
Comment #8
e0ipsoThanks @Wim Leers! The patch looks great so far. Hopefully we can get completion on the rest of the issue as described in #2 and highlighted on #6.
Comment #9
littletiger commentedHi all, not sure what the meaning is of catching bubbled cacheability.
So the bug or issue I experienced just now might or might not be related.
JSONAPI output didn't show any
meta.derivatives, where there should be some. Neither in the browser nor in my angular front-end app.In the browser, as the documentation says, I then added
_consumer_id=.... I had to refresh the cache, then themeta.derivativesshowed up.If I then remove the
_consumer_id=...and clear the cache again, themeta.derivativesare still there.So I'm confused. One part seems to be caching acting a bit weirdly, or in a way i don't understand :)
The other part is... do I need to somehow supply the consumer id as a url parameter with all requests, despite already using it with
/oauth/token? (This is a separate question... so feel free to ignore that :)Comment #10
dremy commentedI am seeing the same issue as "#2927782: Some derivatives are randomly missing" - where all derivatives just disappeared after a "drush cache-rebuild"
So I attempted to apply the patch "2985403-2.patch" but it fails on Drupal 8.6.2 and consumer_image_styles 8.x-2.0-rc6
Comment #11
pieterdt commentedI'm having the same problem: testing 50 nodes of a single content type, all have the image field filled in. 20 of of 50 will not return derivatives when queried with jsonapi/consumer_image_styles.
They will return the regular image field info about the image file, but no derivatives (hence I know for sure they image is attached).
A cache rebuild didn't improve the result, however, saving the node again, did help. After saving (tried with one) it, the imageDerivatives were set correctly. Maybe this gives a hint in where to fix this.
Comment #12
e0ipsoClosing. Hopefully we can focus on 8.x-3.x instead.