Problem/Motivation

When trying to abort a job, edit a value or related in the job form, the changes are not applied.

Proposed resolution

This error in the job form might be due to a wrong redirection. Solve the redirection and add tests to assert the changes.

have a look at the redirects and solve the issue.

Remaining tasks

create patch, Review and commit.

User interface changes

Data model changes

Original report by [username]

Comments

juanse254 created an issue. See original summary.

juanse254’s picture

Issue summary: View changes
juanse254’s picture

Status: Active » Needs review
Issue tags: +Needs tests
StatusFileSize
new678 bytes

So far this seems to do the trick, but tests needed.

juanse254’s picture

Issue summary: View changes
Status: Needs review » Active
juanse254’s picture

Status: Active » Needs review
StatusFileSize
new1.9 KB
new1.85 KB

Okay, tests added.

Status: Needs review » Needs work

The last submitted patch, 5: Redirect_tmgmt_fix-2557263-5-TEST-ONLY.patch, failed testing.

juanse254’s picture

Status: Needs work » Needs review
berdir’s picture

Status: Needs review » Needs work
Issue tags: -Needs tests
  1. +++ b/src/Tests/TMGMTUiTest.php
    @@ -677,6 +677,32 @@ class TMGMTUiTest extends TMGMTTestBase {
    +    // Add item to the job.
    +    $job->addItem('test_source', 'test', 1);
    +    $this->drupalGet('admin/tmgmt/jobs/');
    

    Trailing /. Would have committed, but...

  2. +++ b/tmgmt.module
    @@ -931,7 +931,8 @@ function tmgmt_job_checkout_and_redirect(FormStateInterface $form_state, array $
    -function tmgmt_submit_redirect(array $form, FormStateInterface $form_state){
    +function tmgmt_submit_redirect(array $form, FormStateInterface $form_state) {
    +  \Drupal::request()->query->remove('destination');
    

    Please add a comment that explains why we are doing this.

juanse254’s picture

Status: Needs work » Needs review
StatusFileSize
new955 bytes
new1.99 KB

Changes added :).

LKS90’s picture

Status: Needs review » Needs work
+++ b/tmgmt.module
@@ -931,7 +931,9 @@ function tmgmt_job_checkout_and_redirect(FormStateInterface $form_state, array $
+  // Remove the destination element from the query so the redirection works as expected.

Comment is too long (8 chars too many) and describes what the following lines do, not why they are doing it (I'm not really sure why we have to do it, probably because there is no form for the url with the destination query at the end of the URL)

juanse254’s picture

Status: Needs work » Needs review
StatusFileSize
new1.98 KB
new649 bytes

Edited comment, made it shorter and more descriptive.

mbovan’s picture

Status: Needs review » Needs work
  1. +++ b/src/Tests/TMGMTUiTest.php
    @@ -677,6 +677,32 @@ class TMGMTUiTest extends TMGMTTestBase {
    +    $job->settings = array();
    

    Not needed for the tests?

  2. +++ b/src/Tests/TMGMTUiTest.php
    @@ -677,6 +677,32 @@ class TMGMTUiTest extends TMGMTTestBase {
    +    $aborted = (array)$this->xpath('//table[@class="views-table views-view-table cols-9"]/tbody/tr[1]')[0];
    

    One missing space after (array)

  3. +++ b/tmgmt.module
    @@ -931,7 +931,9 @@ function tmgmt_job_checkout_and_redirect(FormStateInterface $form_state, array $
    +  // Remove destination from the query since there is no form with it at the end.
    

    #10 is still not fixed. 1 character extra. :)

juanse254’s picture

Applied :).

juanse254’s picture

Status: Needs work » Needs review
juanse254’s picture

Ups , this is the right patch.

LKS90’s picture

Status: Needs review » Reviewed & tested by the community

Looks good now, I'd say.

Edit: A real explanation why we have to remove the destination would be really nice though, I'm just curious though. Why is the destination query added to all requests anyway? Is it only the 'destination' element that will break the redirect or will any query elements in the request break the redirect?

The last submitted patch, 13: Redirect_tmgmt_fix-2557263-13.patch, failed testing.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 15: Redirect_tmgmt_fix-2557263-13.patch, failed testing.

juanse254’s picture

Status: Needs work » Reviewed & tested by the community
edurenye’s picture

Status: Reviewed & tested by the community » Needs work

Add a better explanation, the comment has to have less than 80 carachters per line, but you can add more than one line, so split the explanation in more than on line. You should configure your IDE to show these things, is so useful.

edurenye’s picture

Status: Needs work » Reviewed & tested by the community

Take this in mind the next time, you are right maybe this explanation it's enough.

berdir’s picture

Status: Reviewed & tested by the community » Fixed

Comment looks fine to me. Committed.

  • Berdir committed e19edcb on 8.x-1.x authored by juanse254
    Issue #2557263 by juanse254: Fixed redirection on Job Form not working
    

Status: Fixed » Closed (fixed)

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