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

Command icon 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

nlisgo created an issue. See original summary.

nlisgo’s picture

Title: Publish workflow errors when no destination query parameter is set » WorkspacePublishForm $redirectDestination parameter appears not to be used
Issue summary: View changes
nlisgo’s picture

I 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

nlisgo’s picture

Status: Active » Needs review

nlisgo’s picture

I've added a test for the publish content of a workflow which exposes the bug at least for the publish form.

smustgrave’s picture

Status: Needs review » Needs work

So 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.

nlisgo’s picture

Status: Needs work » Needs review

I've added the test to the main MR. Apologies.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Confirmed the bug in the IS
MR 4448 solves the issue.
4449 shows the test case is showing the problem.

amateescu’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: -destination

The 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 RedirectDestinationTrait so that issue should have used $this->getDestinationArray() instead of trying to inject the redirect destination service. Let's correct that properly in this issue :)

larowlan’s picture

Confirmed 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 ++

nlisgo’s picture

Thanks for the review everyone. I have addressed the feedback from @amateescu.

nlisgo’s picture

Status: Needs work » Needs review
amateescu’s picture

Status: Needs review » Reviewed & tested by the community

Looks great now :)

  • larowlan committed 917678cf on 11.x
    Issue #3376293 by nlisgo, smustgrave, amateescu: WorkspacePublishForm $...

  • larowlan committed 3dc86aa6 on 10.1.x
    Issue #3376293 by nlisgo, smustgrave, amateescu: WorkspacePublishForm $...
larowlan’s picture

Version: 11.x-dev » 10.1.x-dev
Status: Reviewed & tested by the community » Fixed

Committed 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.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.