Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
/**
* Implements \Symfony\Component\Serializer\Normalizer\NormalizerInterface::normalize().
*/
public function normalize($object, $format = NULL, array $context = array()) {
$attributes = array();
foreach ($object as $name => $field) {
$attributes[$name] = $this->serializer->normalize($field, $format);
}
return $attributes;
}
The child items that are iterated over do not get the context passed in. I would guess this is an artefact of just a missed parameter when the serializer component was updated to pass a $context parameter.
Proposed resolution
Add $context to the normalize() calls for each field.
Remaining tasks
Tests, Add the variablle, done
User interface changes
None
API changes
None
Data model changes
None
Beta phase evaluation
Issue category | Bug, because its a missing parameter |
---|---|
Issue priority | Normal, because its just one special bit of the code flow. |
Disruption | No disruption |
Comment | File | Size | Author |
---|---|---|---|
#11 | interdiff-2566335-11.txt | 1.44 KB | damiankloip |
#11 | 2566335-11.patch | 4.34 KB | damiankloip |
#9 | interdiff-2566335-9.txt | 678 bytes | damiankloip |
#8 | interdiff-2566335-8.txt | 1.68 KB | damiankloip |
#8 | 2566335-8.patch | 4.51 KB | damiankloip |
Comments
Comment #2
damiankloip CreditAttribution: damiankloip at Tag1 Consulting commentedComment #3
damiankloip CreditAttribution: damiankloip at Tag1 Consulting commentedComment #6
dawehnerWhy is $context not always a required parameter? Odd world
Let's just go with @covers ::supportsNormalization and skip the human words
Do we really want to check the order of the execution of the serialization? Seems to limit our implementation a bit.
Ah great, pass in two values, this is not a bad idea to test.
Comment #7
damiankloip CreditAttribution: damiankloip at Tag1 Consulting commented1. Yeah.. I think because it was introduced and needed BC
2. Yeah! c&p fail
3. Not sure what you mean, I would think we would like to know that each item is passed in? We know what the items will be from the TestComplexData class
4. KISS
Comment #8
damiankloip CreditAttribution: damiankloip at Tag1 Consulting commentedWith prophecy.
Comment #9
damiankloip CreditAttribution: damiankloip at Tag1 Consulting commentedUgh, and with the @covers
Comment #10
dawehnerNot needed anymore
Can we use Serializer::class ? its way nicer
Comment #11
damiankloip CreditAttribution: damiankloip at Tag1 Consulting commentedThanks!
Comment #12
dawehnerThank you!
Comment #13
alexpottCommitted 7461ba2 and pushed to 8.0.x. Thanks!