Problem/Motivation

#2940342: Cacheability metadata on an entity fields' properties is lost added this @todo:

    // @todo Use the constant \Drupal\serialization\Normalizer\CacheableNormalizerInterface::SERIALIZATION_CONTEXT_CACHEABILITY instead of the 'cacheability' string when JSON API requires Drupal 8.5 or newer.

Proposed resolution

JSON API 2.x requires Drupal >=8.5.4, so we can now do this.

Remaining tasks

User interface changes

API changes

Data model changes

Comments

Wim Leers created an issue. See original summary.

wim leers’s picture

wim leers’s picture

Status: Active » Needs review
StatusFileSize
new2.17 KB
wim leers’s picture

StatusFileSize
new5.52 KB
new7.66 KB

I just realized that we're only doing this for FieldItemNormalizer, i.e. for properties on fields that are not entity references. In case of entity references, properties are normalized directly in \Drupal\jsonapi\Normalizer\EntityReferenceFieldNormalizer::normalize().

This went unnoticed so far because no EntityReferenceItem subclasses exist in Drupal core that have properties with cacheability.

Status: Needs review » Needs work

The last submitted patch, 4: 3008544-4.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

wim leers’s picture

Status: Needs work » Needs review
StatusFileSize
new547 bytes
new7.94 KB
gabesullice’s picture

In confused. I thought you went through a lot of effort to get rid of this altogether, using normalizer value objects to carry cacheability. What am I missing?

wim leers’s picture

That is still the case. But it's only the case for @EntityType-level and @FieldType-level data. It's not the case for @DataType-level ("field property level") data.

gabesullice’s picture

Status: Needs review » Reviewed & tested by the community

Ah, makes sense. Looks good.

  • gabesullice committed d8170ac on 8.x-2.x authored by Wim Leers
    Issue #3008544 by Wim Leers, gabesullice: Use \Drupal\serialization\...
gabesullice’s picture

Status: Reviewed & tested by the community » Fixed

Boom.

Status: Fixed » Closed (fixed)

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