[9.x] Map integer parameter to parameter name when resolving binding field #42571
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.
Fixes #42541
First of all, I'm really sorry about all the issues the initial PR has caused 😞
Summary
This PR reverts most of the changes of the original PR (#42425) while still fixing the bug described in the PR. The only method that was changed was the
bindingFieldFor
method of theRoute
class. All changes toImplicitRouteBinding
andRouteUri
were reverted.To fix the bug described in the original PR, we now resolve the parameter index to the parameter name by looking it up in the route's
parameterNames
array.This means that we no longer have to change the structure of the
bindingFields
array itself like in the original PR. The bug described in the related issue (#42541) was due to the fact that theResourceRouteRegistrar
also filled the route's binding fields withnull
values, just like my change in the original PR. The problem with that is that both of these implementations usednull
to signal the exact opposite of each other. My PR usednull
to mean "don't scope this parameter", whereas theResourceRouteRegistrar
used it to mean "scope this parameter but default to the model's route key name".I left in all the additional tests I added since all the problems that got reported due to my original PR were not covered by any existing tests.