fix(symfony): register property_info fallback when not provided by Symfony#7969
Open
guillaumedelre wants to merge 1 commit into
Open
Conversation
Contributor
Author
Member
|
it looks like test failures are related |
Contributor
Author
PHPUnit failuresFixed in the latest push. Two issues were addressed:
Laravel E2E installation failureThis failure is unrelated to this PR. The |
dd1a058 to
ada0650
Compare
3 tasks
…mfony When symfony/framework-bundle has property_info disabled (the default on full-stack Symfony unless explicitly opted-in), the prependExtensionConfig fallback in ApiPlatformExtension::prepend() can be overridden by user configuration, resulting in "service not found" errors at container compile time. Add a PropertyInfoPass compiler pass that registers a minimal PropertyInfoExtractor backed by ReflectionExtractor when the property_info service is absent, ensuring API Platform never requires it to be explicitly enabled. Fixes api-platform#7876 Signed-off-by: Guillaume Delré <delre.guillaume@gmail.com>
ada0650 to
7de085f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When
symfony/framework-bundlehasproperty_infodisabled (the default on full-stack Symfony unless explicitly opted-in), theprependExtensionConfig()call inApiPlatformExtension::prepend()can be overridden by user configuration. This results in a container compilation error:This was reported in #7723 and confirmed via api-platform/docs#2262, where @soyuka noted that a code-level fix was the right approach.
Fix
Add a
PropertyInfoPasscompiler pass (running atTYPE_BEFORE_OPTIMIZATIONwith priority 200, before any alias resolution) that checks whetherproperty_infois registered in the container. If not, it registers a minimal fallback: aPropertyInfoExtractorbacked byReflectionExtractorwith the standardproperty_info.*tags.This ensures
api_platform.property_info(aliased toproperty_infoinapi.php) always resolves, without requiring users to explicitly enableproperty_infoin their framework configuration.Impact on docs PR
api-platform/docs#2262 adds a troubleshooting section documenting this error as a workaround. With this fix, the root cause is resolved and that PR becomes obsolete.