Problem/Motivation
This is linked to the work to "Inject redirect.destination service". See #3123214. It was apparent that it was linked until the cause of an error was investigated.
The destination query parameter is helpful to override the default redirect after an operation is performed but it's absence should not cause an error unless justified. I see no justification for this.
The error logs indicate the following error is triggered:
NOTICE: PHP message: Uncaught PHP Exception Error: "Call to a member function getAsArray() on null" at /data/app/core/modules/workspaces/src/Form/WorkspacePublishForm.php line 144
{ "timestamp": "2023-07-22T12:31:31+0000", "fields": { "client_ip": "-", "remote_addr": "127.0.0.1", "remote_user": "", "request_uri": "/admin/config/workflow/workspaces/manage/stage/publish", "status": "500", "body_bytes_sent": "0", "request_time": "0.280", "http_referrer": "", "http_user_agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36", "request_id": "-", "cpu": "64.27", "memory": "4194304", "headers": { "Cache-Control": "must-revalidate, no-cache, private"} } }Steps to reproduce
- Enable workspaces module.
- Visit /admin/config/workflow/workspaces/manage/stage/publish and you will see the error message "The website encountered an unexpected error. Please try again later.".
Adding the ?destination query parameter even without a value set will not cause an error: /admin/config/workflow/workspaces/manage/stage/publish?destination
Proposed resolution
Allow the user to be directed to the valid url /admin/config/workflow/workspaces/manage/stage/publish without a query parameter set.
Issue fork drupal-3376293
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
nlisgo commentedComment #3
nlisgo commentedComment #4
nlisgo commentedI think it's possible this could have been caught with an extension to the coverage of Workspaces.
The best location for an extension of tests for '/admin/config/workflow/workspaces/manage/{workspace}/publish' and '/admin/config/workflow/workspaces/manage/{source_workspace}/{target_workspace}/merge' may be Drupal\Tests\workspaces\Functional\WorkspaceTest
Comment #6
nlisgo commentedComment #8
nlisgo commentedI've added a test for the publish content of a workflow which exposes the bug at least for the publish form.
Comment #9
smustgrave commentedSo the test-only MR fails but the tests weren't added to the main MR (4448) to see if they would pass. Can you add those please.
Comment #10
nlisgo commentedI've added the test to the main MR. Apologies.
Comment #11
smustgrave commentedConfirmed the bug in the IS
MR 4448 solves the issue.
4449 shows the test case is showing the problem.
Comment #12
amateescu commentedThe changes done in #3123214: Inject redirect.destination service instead of using \Drupal:: destination() in non-tests were incorrect for the workspace merge and publish forms. They are using
RedirectDestinationTraitso that issue should have used$this->getDestinationArray()instead of trying to inject the redirect destination service. Let's correct that properly in this issue :)Comment #13
larowlanConfirmed the bug through manual testing
Left a review, couple of minor optimisations, fine to self RTBC those changes
edit: crosspost with @amateescu
Yes, agree to his suggestions ++
Comment #14
nlisgo commentedThanks for the review everyone. I have addressed the feedback from @amateescu.
Comment #15
nlisgo commentedComment #16
amateescu commentedLooks great now :)
Comment #19
larowlanCommitted 917678c and pushed to 11.x. Thanks!
Backported to 10.1.x as this is a fatal in a tagged version in the UI and the risk of disruption is low. Additionally, workspaces is still experimental.
I unpublished the old change record.