Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

DeserializeProvider calls PartialDenormalizationException::getErrors(), deprecated in Symfony 8.1

已关闭 适合新手
#8,650 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
76/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
php, symfony
领域
api, backend

调研方向

从 issue 中指出的第 110 行附近的调用处开始检查 src/State/Provider/DeserializeProvider.php。确认项目如何同时支持 Symfony Serializer 7.4 和 8.1,然后运行使用 collect_denormalization_errors: true 处理无效输入的相关测试。完成标准是这些测试通过,且没有 Symfony 8.1 弃用警告,同时继续支持 Symfony 7.4。

由索引模型根据 Issue 内容生成。

描述

API Platform version(s) affected: 4.3.21 and the current head of 4.4 (5.0 is not affected)

Symfony 8.1 deprecates PartialDenormalizationException::getErrors() in favour of getNotNormalizableValueErrors(). The 4.4 branch still calls it: https://github.com/api-platform/core/blob/4.4/src/State/Provider/DeserializeProvider.php#L110

Since symfony/serializer 8.1: The "Symfony\Component\Serializer\Exception\PartialDenormalizationException::getErrors()" method is deprecated, use "Symfony\Component\Serializer\Exception\PartialDenormalizationException::getNotNormalizableValueErrors()" instead.

Every 422 caused by a denormalization error goes through this line, so with collect_denormalization_errors: true it shows up in each test that sends invalid input. 5.0 no longer has the call, but it went away with the rewrite in #8211, which won't be backported.

Possible solution

In Symfony 8.1 getErrors() only returns getNotNormalizableValueErrors(), so the swap is exact. 4.4 also supports symfony/serializer ^7.4, which doesn't have that method, so the fallback would be needed. Yet the fix seems as trivial as

$errors = method_exists($e, 'getNotNormalizableValueErrors')
    ? $e->getNotNormalizableValueErrors()
    : $e->getErrors();

foreach ($errors as $exception) {
    ...
主要语言
PHP
星标
2.6k
派生
989
平均合并
2 天 4 小时
30 天内合并 PR
90

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

api-platform/core 的其他 Issue

查看 api-platform/core 的全部 Issue

相似的 Issue

更多 PHP Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。