? ? Pending

User tests: Successful: Unsuccessful:

avatar roland-d
roland-d
16 Jun 2017

Summary of Changes

This pull requests makes it possible to use the redirect form field when editing an item to allow the user to be redirected to the given URL after closing the item. For example when you have a link to a Joomla article within your own extension, you can set the return URL and after saving the article the user is redirected back to where he/she came from.

This change doesn't only affect Joomla articles but anybody implementing the return feature can use it.

Testing Instructions

  1. Open an article by pasting this URL into the URL field of the browser http://joomla.dev/administrator/index.php?option=com_content&task=article.edit&id=89&return=aW5kZXgucGhwP29wdGlvbj1jb21fYmFubmVycw==
  2. Replace joomla.dev with your own domain name and the 89 with an existing article ID
  3. Open the article and notice that the return field remains empty. You can find the field by right clicking on the page and choose Inspect element.
    image
  4. This happens because Joomla redirects to another URL to edit the article and the return argument gets dropped.
  5. Apply the patch
  6. Open the article again with the corrected URL as done in step 1 and 2
  7. Check the return field and see that it is filled now
    image
  8. Save and close the article
  9. You are now redirected to com_banners (had to choose something :P)
  10. The redirect works

Expected result

The expected result is that when the return value is set in the URL, it is applied to the form.

Actual result

The supplied return URL is not set in the form.

Documentation Changes Required

None

avatar roland-d roland-d - open - 16 Jun 2017
avatar roland-d roland-d - change - 16 Jun 2017
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 16 Jun 2017
Category Libraries
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 16 Jun 2017

where to find the return Field of Step 3?

avatar hans2103
hans2103 - comment - 16 Jun 2017

@franz-wohlkoenig inspect element and search for aW5kZXgucGhwP29wdGlvbj1jb21fYmFubmVycw I guess

avatar hans2103 hans2103 - test_item - 16 Jun 2017 - Tested successfully
avatar hans2103
hans2103 - comment - 16 Jun 2017

I have tested this item successfully on f3d3fc5

Patch works as expected. Before patch applied I will not return to given page (com_banners) and after the patch I do return to the given page.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/16718.

avatar roland-d roland-d - change - 16 Jun 2017
The description was changed
avatar roland-d roland-d - edited - 16 Jun 2017
avatar roland-d
roland-d - comment - 16 Jun 2017

@franz-wohlkoenig @hans2103 is correct. You can do Inspect Element from your browser to find the field. I update the instructions accordingly.

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 16 Jun 2017

thanks for Hints. Cant find in DevTools aW5kZXgucGhwP29wdGlvbj1jb21fYmFubmVycw or <input name="task" or <textarea like shown in Screenshot.

avatar roland-d
roland-d - comment - 16 Jun 2017

@franz-wohlkoenig Here are some more screenshots, hope that helps.

Before:
image

After:
image

I guess you should scroll down to almost the end of the document to see this.

avatar Bakual
Bakual - comment - 16 Jun 2017

Honestly I doubt this is a good idea.
If I remember right, we do some checks on redirect URLs to make sure you can't be redirected to an external URL this way. Someone from JSST should at least have a look at it to make sure we don't introduce issues. @SniperSister

avatar brianteeman
brianteeman - comment - 16 Jun 2017

at a minimum i would think we would need to ensure that the redirect is an internal url

avatar roland-d roland-d - change - 16 Jun 2017
Labels Added: ?
avatar roland-d
roland-d - comment - 16 Jun 2017

@brianteeman Good point about the internal check. I have added the check to make sure the redirect URL is internal.

@Bakual The same functionality exists in the frontend, so I fail to see how this is worse than having it in the frontend.

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 16 Jun 2017

@roland-d thanks for helping, but no Luck.

avatar roland-d
roland-d - comment - 16 Jun 2017

@franz-wohlkoenig What if you just look at the source of the page? You can right click the page and select View Page Source. On that tab that opens you can search for name="return". Does that work for you?

avatar Bakual
Bakual - comment - 16 Jun 2017

The same functionality exists in the frontend, so I fail to see how this is worse than having it in the frontend.

If you check and only allow internal URLs, then it should be fine I guess. But then I don't understand your comment, this is a library controller class. That one is used both in frontend and backend.

The only place I found where we currently use that code is \ContentControllerArticle::getReturnPage and there we check if it is internal as well.

If we add this to JControllerForm, shouldn't the frontend ContentControllerArticle class then be adjusted? The current code seems to be redundant then to me as it does the same the parent class already will do after this PR?

avatar franz-wohlkoenig franz-wohlkoenig - test_item - 16 Jun 2017 - Tested successfully
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 16 Jun 2017

I have tested this item successfully on 589d565

@roland-d Source Code works. Tooks Time to understand where to look.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/16718.
avatar roland-d
roland-d - comment - 16 Jun 2017

@Bakual

If we add this to JControllerForm, shouldn't the frontend ContentControllerArticle class then be adjusted?

I don't see why because it routes differently. The getReturnPage() has a hardcoded redirect to JUri::base() if no return is set. This is not what you want in the backend if you ask me.

The current code seems to be redundant then to me as it does the same the parent class already will do after this PR?

This method already calls the parent but redirects in other ways than the parent does.

The only thing I see that is weird is this piece of code which is unrelated to my change:

$return = base64_encode('index.php?Itemid=' . $menuitem . $lang);

			// If ok, redirect to the return page.
			if ($result)
			{
				$this->setRedirect(JRoute::_(base64_decode($return)));
			}

Why are we even encoding? ?

avatar Bakual
Bakual - comment - 16 Jun 2017

I don't see why because it routes differently. The getReturnPage() has a hardcoded redirect to JUri::base() if no return is set. This is not what you want in the backend if you ask me.

Ah true. Makes sense.

Why are we even encoding?

I gave up trying to understand all our code after I saw com_tags ?

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 16 Jun 2017

PR ready for RTC?

avatar joomla-cms-bot joomla-cms-bot - change - 16 Jun 2017
Category Libraries Front End com_content Libraries
avatar Bakual
Bakual - comment - 16 Jun 2017

Fine from me.

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 16 Jun 2017

2 new Tests, @Bakual?

avatar Bakual
Bakual - comment - 16 Jun 2017

There was only one test after he added the internal check, and there was another commit after that one as well (allthought that one is safe for sure). So by our rules we would need at least one more test.

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 16 Jun 2017

@hans2103 can you please retest?

avatar hans2103 hans2103 - test_item - 16 Jun 2017 - Tested successfully
avatar hans2103
hans2103 - comment - 16 Jun 2017

I have tested this item successfully on 752415e

I can confirm the I get the actual result without the patch and the expected result with the patch.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/16718.
avatar franz-wohlkoenig franz-wohlkoenig - change - 16 Jun 2017
Status Pending Ready to Commit
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 16 Jun 2017

RTC after two successful tests.

avatar slibbe
slibbe - comment - 19 Jun 2017

I have tested this succesfully.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/16718.

avatar slibbe slibbe - test_item - 19 Jun 2017 - Tested successfully
avatar slibbe
slibbe - comment - 19 Jun 2017

I have tested this item successfully on 752415e


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/16718.

avatar slibbe
slibbe - comment - 19 Jun 2017

I can confirm that the return argument is not included, while it is included when the patch has been applied.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/16718.

avatar rdeutz rdeutz - change - 21 Jun 2017
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2017-06-21 18:37:37
Closed_By rdeutz
Labels Added: ?
avatar rdeutz rdeutz - close - 21 Jun 2017
avatar rdeutz rdeutz - merge - 21 Jun 2017

Add a Comment

Login with GitHub to post a comment