Problem/Motivation
I have a contrib module for commerce that I need to pass the order id as a route parameter for the add page route. But EntityController doesn't pass in all the populated route parameters.
Example route:
* links = {
* "add-page" = "/admin/commerce/orders/{commerce_order}/plan/add",
* "add-form" = "/admin/commerce/orders/{commerce_order}/plan/add/{installment_plan_type}",
commerce_order isn't replaced.
Proposed resolution
Inject current_route_match and add the raw route match parameters to the list of params passed to the redirect from add_page to add_form.
Remaining tasks
User interface changes
n/a
API changes
n/a
Data model changes
n/a
Comments
Comment #2
heddnHere we go.
Comment #3
dawehnerWon't this add every parameter as query string, if its not defined on the route?
Comment #4
heddnThe redirect builds a route and the parameters are route parameters. If there are extra route parameters, they are just ignored. However, if not enough route parameters are provided, then the {commerce_order}, etc doesn't get replaced. So, no it doesn't add every parameter (or any parameter) to a query string. It just route replacements.
Comment #16
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #18
bhanu951 commentedComment #20
bhanu951 commentedComment #21
smustgrave commentedThis issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.
Did not test
But the new parameter will need to default to NULL and have a trigger_error that it will be required in 11.
Tagging for tests and change record.
Comment #22
bhanu951 commentedBC Shim and Test Added.
Comment #23
bhanu951 commentedComment #24
bhanu951 commentedDraft CR Created.
Comment #25
smustgrave commentedSmall tweak I believe the trigger_error needs to point to the change record.
Comment #26
catchThis looks fine, but should we have test coverage for the fixed behaviour?
Comment #28
murilohp commentedHey, I was taking a look here and I think I can help you with the tests part of the fixed behaviour, I've just added a new test entity specific for the add-page/form with multiple parameters, this way I was able to validate the error, here's a test only patch.
Comment #29
murilohp commentedMy bad here with the
2897251-testbranch, I usually create the test only branch locally and I haven't realized I was on this branch before pushing. Anyway, I would like to remove it, but I don't have the permission, so please ignore it. I have update the correct branch and it's ok to move to NR.Comment #30
smustgrave commentedReviewing the changes #25
Tests were added
All threads in MR 3333 have been addressed
Change record exists
New constructor has a trigger_error
Thanks!
Comment #32
catchThe legacy test isn't necessary for constructor bc layers - we only do 'best effort' bc for constructors and that doesn't include test coverage of the deprecations - less code to add then immediately remove in the next release. Added tests for the entity add page look good.
I went ahead and committed the patch to 10.1.x but with the legacy test removed.
Comment #33
bhanu951 commentedPublished CR