denormalizers are no longer aliased as normalizer in 4.4
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
Start by reviewing commit d36c14c and the service IDs api_platform.jsonld.normalizer.item and api_platform.jsonld.denormalizer.item. Reproduce the issue with the DTO and decorator shown, then verify that decorating the normalizer also affects denormalization as it did in 4.3, without requiring a second decorator.
由索引模型根据 Issue 内容生成。
描述
API Platform version(s) affected: 4.4.0
Description
Commit d36c14c splits normalizer and denormalizer into dedicated ItemNormalizer and ItemDenormalizer. This causes overwritten decorators to no longer work (docs is also still outdated https://api-platform.com/docs/v4.4/core/serialization/#decorating-a-serializer-and-adding-extra-data-for-symfony)
How to reproduce
Create a serializer that decorates only 'api_platform.jsonld.normalizer.item', it no longer decorates during denormalize.
// small DTO to play with:
class Test
{
public bool $test = false;
}
#[AsDecorator('api_platform.jsonld.normalizer.item')]
class ExampleSerializer implements NormalizerInterface, DenormalizerInterface, SerializerAwareInterface
{
public function __construct(
#[AutowireDecorated]
private readonly NormalizerInterface&DenormalizerInterface&SerializerAwareInterface $decorated,
) {
}
public function setSerializer(SerializerInterface $serializer): void
{
$this->decorated->setSerializer($serializer);
}
public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): mixed
{
$result = $this->decorated->denormalize($data, $type, $format, $context);
$result->test = true;
return $result;
}
public function supportsDenormalization(
mixed $data,
string $type,
?string $format = null,
array $context = [],
): bool {
return $this->decorated->supportsDenormalization($data, $type, $format, $context);
}
public function normalize(
mixed $data,
?string $format = null,
array $context = [],
): array|string|int|float|bool|ArrayObject|null {
$result = $this->decorated->normalize($data, $format, $context);
$result['extraProperty'] = true;
return $result;
}
public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool
{
return $this->decorated->supportsNormalization($data, $format, $context);
}
public function getSupportedTypes(?string $format): array
{
return $this->decorated->getSupportedTypes($format);
}
}
Given this setup, I expect normalize to add extraProperty and denormalize to set test to true. In 4.3 this worked, in 4.4 it no longer works and we have to add an extra decorator:
~ #[AsDecorator('api_platform.jsonld.normalizer.item')]
+ #[AsDecorator('api_platform.jsonld.denormalizer.item')]
~ class ExampleSerializer implements NormalizerInterface, DenormalizerInterface, SerializerAwareInterface
Hence why this is a backwards compatibility break on a minor version (4.4).
Possible Solution
d36c14c should be removed from 4.4 and moved to 5.0
Additional Context
- 主要语言
- PHP
- 星标
- 2.6k
- 派生
- 989
- 平均合并
- 1 天 19 小时
- 30 天内合并 PR
- 87
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
api-platform/core 的其他 Issue
-
SkolemIriConverter isn't reset between requests in worker mode (missing kernel.reset tag)可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 1/5 1 小时以内 新手友好度 85/100
api-platform/core#8680 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 54/100
api-platform/core#8664 · 1 条评论 ·
维护者通常 1 天内回复
-
[Metadata] Incorrect api schema for path variable可能已有人在做 @bram123 于 2 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 68/100
api-platform/core#8646 · 1 条评论 ·
维护者通常 1 天内回复
-
DenormalizationViolationFactory crash when GroupSequence is used可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 3/5 1-2 天 新手友好度 64/100
api-platform/core#8639 ·
维护者通常 1 天内回复
-
HTTP cache purgers error handling and performance issues可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 4/5 3-5 天 新手友好度 38/100
api-platform/core#8591 ·
维护者通常 1 天内回复
查看 api-platform/core 的全部 Issue
相似的 Issue
-
feature request
难度 1/5 1 小时以内 新手友好度 88/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
Automattic/blocks-engine#2803 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
hestiacp/hestiacp#5798 · 2 条评论 ·
维护者通常 1 天内回复
-
Bug Component: HTTP Component: Telemetry
难度 2/5 1-3 小时 新手友好度 74/100
-
难度 2/5 1-3 小时 新手友好度 62/100
woocommerce/woocommerce-google-analytics-integration#699 ·
维护者通常 1 天内回复