Symfony 8.2: object mapper probe is a fatal error when symfony/translation is not installed
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 68/100
Línea de trabajo
Read src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php around line 217 and review the condition introduced for #8627. Reproduce the reported failure with Symfony FrameworkBundle 8.2 and no symfony/translation. Change the version gate so it avoids autoloading the FrameworkBundle command with its optional parent; done when the container build succeeds in that setup.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
API Platform version(s) affected: 5.0.2, and main at 23c4876d1726b17826fbc8901791f8f843eadf42
Description
With symfony/framework-bundle 8.2 and without symfony/translation, the container build stops with a fatal error:
PHP Fatal error: Uncaught Error: Class "Symfony\Component\Translation\Command\TranslationExtractCommand" not found in vendor/symfony/framework-bundle/Command/TranslationExtractCommand.php:26
#3 vendor/api-platform/core/src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php(217): class_exists('Symfony\\Bundle\\...')
In FrameworkBundle 8.2, Symfony\Bundle\FrameworkBundle\Command\TranslationExtractCommand extends Symfony\Component\Translation\Command\TranslationExtractCommand. FrameworkBundle 8.2 lists symfony/translation only in require-dev, so the parent class can be absent. class_exists() with autoload then includes the file, and PHP throws an Error instead of returning false.
#8627 (for #8626) checks the Translation class first, but it keeps the FrameworkBundle class as a fallback. When symfony/translation is not installed, the first check returns false, the fallback runs, and the same error occurs.
How to reproduce
composer init -n --name=x/repro --stability=dev
composer config prefer-stable true
composer require symfony/framework-bundle:8.2.x-dev
cat > probe.php <<'PHP'
<?php
require __DIR__.'/vendor/autoload.php';
use Symfony\Component\Translation\Command\TranslationExtractCommand;
use Symfony\Bundle\FrameworkBundle\Command\TranslationExtractCommand as FrameworkTranslationExtractCommand;
var_dump(class_exists(TranslationExtractCommand::class) || class_exists(FrameworkTranslationExtractCommand::class));
PHP
php probe.php
The condition is the one from ApiPlatformExtension on main. The script stops with the fatal error above.
Possible Solution
Do not autoload a FrameworkBundle class whose parent comes from an optional package. The gate needs to know only that FrameworkBundle is 7.3 or later. For example, check the version with Composer\InstalledVersions, or check a class from 7.3 that has no optional parent.
Additional Context
A production install of Maho got 8.2.x-dev and hit this error on every REST request. composer require symfony/translation is a workaround. When Symfony releases 8.2.0, every application without symfony/translation gets this error.
- Lenguaje dominante
- PHP
- Estrellas
- 2.6k
- Forks
- 989
- Merge medio
- 1 d 22 h
- PR fusionados (30 d)
- 100
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de api-platform/core
-
JSON:API: resource schemas (`*.jsonapi`) have `properties` but no `type: object`Posiblemente ocupada @ousamabenyounes la tomó hace 2 días. Abierto
Dificultad 2/5 Menos de una hora Aptitud para principiantes 80/100
api-platform/core#8701 ·
Los mantenedores suelen responder en 1 día
-
JSON:API: `JsonApiCollectionBaseSchemaNoPagination` declares `data` as `type: array` without `items`Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
api-platform/core#8699 ·
Los mantenedores suelen responder en 1 día
-
[Json-Schema] Nested resources lost externalDoc and description dataPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
api-platform/core#8721 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 50/100
api-platform/core#8704 ·
Los mantenedores suelen responder en 1 día
-
JSON:API: request documents with no `data`, no `type` or a wrong `type` are accepted with 201Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 62/100
api-platform/core#8703 ·
Los mantenedores suelen responder en 1 día
Todos los issues de api-platform/core
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
neos/flow-development-collection#3639 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
The PHP version check in prepare.php still allows PHP 7.2 and 7.3Posiblemente ocupada @ekamran la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
WordPress/phpunit-test-runner#359 ·
Los mantenedores suelen responder en 2 días
-
ObjectMapper
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
symfony/symfony-docs#23390 ·
Los mantenedores suelen responder en 2 días
-
sync-en
Dificultad 1/5 1-3 horas Aptitud para principiantes 84/100
Los mantenedores suelen responder en 1 día
-
sync-en
Dificultad 1/5 Menos de una hora Aptitud para principiantes 83/100
Los mantenedores suelen responder en 3 días