fix(symfony): allow null $data in PlaceholderAction#8359
Open
soyuka wants to merge 2 commits into
Open
Conversation
Allows defining JSON-LD namespace prefix entries (e.g. `dct: http://purl.org/dc/terms/`) directly on ApiResource/HttpOperation, which get merged into the generated `@context` output. Closes api-platform#767
In event-listener mode a POST with input:false (and no read) never sets the "data" request attribute, so Symfony's argument resolver fails with "Could not resolve argument $data". Default the argument to null, mirroring the non-listener state-machine flow. Closes api-platform#8354
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.
Bug
In event-listener mode (
use_symfony_listeners: true), aPOSToperation withinput: falseand a custom processor returns a 500:Root cause
The
datarequest attribute is set by eitherReadProviderorDeserializeProvider:ReadProviderskips whencanRead()is false — auto-false forPOST(no URI variables, unsafe method).DeserializeProviderskips wheninput: false→canDeserialize()is false.With both skipped the attribute is never set, so Symfony's argument resolver cannot fill the untyped, no-default
$dataparameter ofPlaceholderAction. The non-listenerMainControllerpath is unaffected because it runs the state machine with$data = null.Fix
Default
PlaceholderAction::__invoke($data = null)so the argument resolver suppliesnullwhen the attribute is absent — matching the non-listener flow where the processor receivesnull.Tests
InputOutputDtoTest::testCreateNoInputResourcewas previously skipped in listener mode with the marker"PlaceholderAction cannot resolve $data when input:false in event-listener mode.". The skip is removed and the test now passes in both modes (USE_SYMFONY_LISTENERS=1and off).Closes #8354