? ? Success

User tests: Successful: Unsuccessful:

avatar wilsonge
wilsonge
17 Sep 2014

This feature allows the setting of the Http status code in com_redirect. This has many SEO related benefits as you may well wish to redirect with a non-301 code (a 501 or something crazy like that even).

It also gives much greater flexability to the redirect method in JApplication in order to do this. As that only allowed a redirect with a 301 or 303.

As this is an advanced option and should only be used by those who actually know what their doing I've dumped it in an advanced options parameter for the component. I've also built it in such a way that we can add more things into the advanced section in the future if we want. If the user has this turned off (which he will by default) then they will continue to redirect with a 301

Testing Instructions

Apply the patch and also apply the database change found at https://github.com/wilsonge/joomla-cms/blob/redirect-upgrade/administrator/components/com_admin/sql/updates/mysql/3.4.0-2014-09-16.sql

Go into the backend and navigate to com_redirect (make sure you have the relevant plugin enabled).

Check that the component still works exactly the same as currently - we don't want to scare anyone off with new options :P

Now we'll test the new feature - go into component options and enable the advanced mode (under advanced options tab). In the edit form for a given link this will give you the extra option to set a HTTP redirect number - this is any valid HTTP code. If you set a 3xx code then we redirect as usual. If you choose a non-3xx code then it will display the generic error page in Joomla with the selected error code.

avatar wilsonge wilsonge - open - 17 Sep 2014
avatar jissues-bot jissues-bot - change - 17 Sep 2014
Labels Added: ?
avatar wilsonge
wilsonge - comment - 17 Sep 2014

I know it needs postgres and sql server changes to be made but I'll do that when this is all good and ready to go so if we change things around on review I have to change 2 files not 6 :P

avatar b2z
b2z - comment - 24 Sep 2014

Any test cases? ;)

This comment was created with the J!Tracker Application at http://issues.joomla.org/.

avatar zero-24
zero-24 - comment - 26 Sep 2014

@wilsonge are you sure with the @since tags like 1.0 or 1.6? I think we should use 3.4 for it?

avatar zero-24 zero-24 - change - 26 Sep 2014
Category Administration Components Language & Strings Libraries
avatar wilsonge
wilsonge - comment - 8 Oct 2014

Hullo - thanks for comments both. Sorry for lack of responses but had feedback elsewhere I needed to sort out first before testing.

@zero-24 changed the @since tags - you were quite right about that.
@b2z About to add testing instructions

avatar wilsonge wilsonge - change - 8 Oct 2014
The description was changed
avatar infograf768
infograf768 - comment - 9 Oct 2014

Could you add _LABEL when it fits?
For example in :
COM_REDIRECT_FIELD_REDIRECT_STATUS_CODE

avatar roland-d
roland-d - comment - 10 Oct 2014

@test: The redirect works when setup. One thing I miss though is that the Apache log doesn't show the redirect. It only shows the 200 status for the target URL. I am not sure if that is an Apache setup issue or an issue with this code. From what I could find is that Apache logs 301 redirects out of the box.

| If you choose a non-3xx code then it will display the generic error page in Joomla with the selected error code.

I cannot reproduce that, the page is still redirected to the destination URL. Like the 301 also a 500 error is not logged in the Apache log.

screen shot 2014-10-10 at 16 18 09

The selector is too small, make it wider for better readability.

avatar wilsonge
wilsonge - comment - 10 Oct 2014

Fixed the lang strings JM

avatar roland-d
roland-d - comment - 10 Oct 2014

@test: The redirect works as expected, it was a case of aggresive browser caching by FireFox. Picking another test URL and it works.

Only left issue is the width of the dropdown.

avatar roland-d roland-d - test_item - 10 Oct 2014 - Tested successfully
avatar wilsonge
wilsonge - comment - 10 Oct 2014

Thanks so much for the feedback Roland! Fixed the width of the select elements as requested :)

avatar RCheesley
RCheesley - comment - 12 Oct 2014

Having some issues with testing this patch on the latest development build 3.3.7-dev, when I try to force a 404 in order to redirect (rather than manually creating it from scratch) I'm unable to save it to the database.

The error message received:

1054 Unknown column 'header' in 'field list' SQL=SELECT `new_url`,`header`,`published` FROM `llr4k_redirect_links` WHERE `old_url` = 'http://local.joomlatestsites/j3/index.php/most-read-blah-2' LIMIT 0, 1 

Furthermore, the destination URL appears to be mandatory wheras it does not have an asterisk next to the label which, in my view as a user, would suggest that it was not a required field. Indeed with some error codes such as 410 (Gone) there is no need to redirect anywhere - it should just provide that error code as the page no longer exists.

avatar roland-d
roland-d - comment - 12 Oct 2014

@RCheesley To be able to save the change to the database you will need to manually execute the SQL file.

ALTER TABLE `#__redirect_links` ADD header smallint(3);
avatar RCheesley
RCheesley - comment - 12 Oct 2014

Thanks @roland-d - @wilsonge can you add that to testing instructions please?

Point still stands about the destination URL

avatar RCheesley
RCheesley - comment - 12 Oct 2014

@test successful with correct code being output in live headers, I have suggestions/comments for improvements

  • When the code is different (e.g. 410) the page title & description remains the same (e.g. category not found) - should this be changed? Not found is appropriate for 404 error codes, but maybe not for other error codes.

  • A destination URL is mandatory, however with some errors (e.g. 410 - Gone) no redirect occurs. While this should only be used by advanced SEO specialists, the fact you are required to specify a destination URL could be confusing. Perhaps where a status code is being used where no redirect would/should occur, the destination URL should be fixed as the original URL or be unavailable? From a UI perspective this is poor, because specifying the error code is at the last step. Perhaps we need to move it to the first step if you've got advanced turned on, or immediately below the original URL?

avatar wilsonge
wilsonge - comment - 13 Oct 2014

Updated description to add about the database change. Apologies for not making that clear.

The destination URL should not be mandatory in advanced mode will investigate that as that is a bug.

The location of the field is deliberate. Whilst there is only this 1 advanced field at the moment, the code has been written in such a way that infinitely more can be added by just adding them to the XML file. With that in mind it made sense for any of the admin fields to be added at the end at the current list. The other option was to create a new tab - but that made little sense for what is currently one field.

avatar wilsonge wilsonge - change - 13 Oct 2014
The description was changed
avatar wilsonge
wilsonge - comment - 13 Oct 2014

Destination URL bug being compulsory is now fixed. Thanks for the feedback on that!

avatar RCheesley
RCheesley - comment - 14 Oct 2014

@test successful - can now set an error code without requiring a destination URL.

A couple of issues:

  • If you use a code which requires a destination URL, it should be mandatory - example being 301, which is a 'moved permanently' message - if you don't provide the destination this is confusing.

  • Noticed while testing a batch-update feature below the list of entries, it's not clear what this is or how it's used (figured it out though) but this does not allow you to set the error code, is it supposed to? Also It seems to default to a 301 which, without the setting of a destination URL, would break things - see comment above about making the field mandatory with error codes requiring a destination.

Suggest that if this feature is implemented it has some

avatar nicksavov nicksavov - change - 16 Oct 2014
Labels Added: ?
avatar wilsonge
wilsonge - comment - 17 Oct 2014

Added the extra check for the destination url when in a 3xx request. Batch functionality not given because I don't plan on implementing it in this PR. It's a nice to have for the future. But imo outside the scope of this feature.

avatar anibalsanchez
anibalsanchez - comment - 17 Oct 2014

@test OK

However, Advanced Mode is too hidden! The feature can be just enabled by default.

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

avatar wilsonge
wilsonge - comment - 17 Oct 2014

I'm worried the average person won't know enough about http codes and do seo suicide on their site tbh :P that's why it's a bit hidden

avatar wilsonge wilsonge - change - 19 Oct 2014
Status Pending Ready to Commit
avatar wilsonge
wilsonge - comment - 19 Oct 2014

Thanks for testing everyone! Setting RTC.

avatar Bakual Bakual - change - 19 Oct 2014
Labels Added: ?
avatar jissues-bot jissues-bot - change - 19 Oct 2014
Labels Added: ?
avatar Bakual
Bakual - comment - 19 Oct 2014

Needs obviously the SQL files for PostgreSQL and MSSQL.

avatar wilsonge
wilsonge - comment - 19 Oct 2014

Fixed the sql files. As we've been talking about default values, I took the opportunity to also add the 301 default value into the database tables to try and avoid any issues there

avatar zero-24
zero-24 - comment - 20 Oct 2014

@wilsonge i think we need also for mssql and postgres a update sql file or I'm wrong?
Like the file: administrator/components/com_admin/sql/updates/mysql/3.4.0-2014-09-16.sql

avatar wilsonge
wilsonge - comment - 20 Oct 2014

Thanks for the spot! They were written - just missed them out of the commit!

avatar zero-24
zero-24 - comment - 20 Oct 2014

:+1: The dates / names of the file gets fixed by the comitter with the commit date i guess. (3.4.0-2014-09-XX).

avatar wilsonge
wilsonge - comment - 20 Oct 2014

I would assume so too. The date is when I wrote the initial mysql file. I just kept the name consistent

avatar phproberto phproberto - close - 23 Oct 2014
avatar phproberto phproberto - change - 23 Oct 2014
Status Ready to Commit Closed
Closed_Date 0000-00-00 00:00:00 2014-10-23 16:00:47
avatar infograf768
infograf768 - comment - 23 Oct 2014

Too late to get this in 3.4 instead of staging?

avatar phproberto
phproberto - comment - 23 Oct 2014

We are not going to have more 3.3.x series so I think it's ok :sake:

avatar Bakual
Bakual - comment - 23 Oct 2014

We are not going to have more 3.3.x series so I think it's ok

Famous last words? :smile:

avatar wilsonge
wilsonge - comment - 23 Oct 2014

Then you guys get my awesome new feature early :laughing:

avatar JoomliC
JoomliC - comment - 29 Nov 2014

Hi!

I've found a B/C issue in 3.4.0-alpha related to a change done in /libraries/joomla/application/web.php, line 549

                if (!is_int($status) && !isset($this->responseMap[$status]))
                {
                    throw new \InvalidArgumentException('You have not supplied a valid HTTP 1.1 status code');
                }

If a third-party extension is still using $app->redirect($url, $msg) as $msg is not numeric, it will return a error 0 You have not supplied a valid HTTP 1.1 status code

PR with patch: #5247

@wilsonge could you confirm this is fixing the issue ?

avatar JoomliC
JoomliC - comment - 29 Nov 2014

Sorry @wilsonge to have disturbed you, i have close the PR because the issue was not in joomla core, but in a bad practice i've done a long time ago in one of my file, which one was working before 3.4.0-alpha... (in all cases, Thank you for your PR, because i was able to found a very crap code and to fix it in my own code! ) ;-)

avatar wilsonge
wilsonge - comment - 29 Nov 2014

Don't worry man. Glad you got it sorted :)

avatar infograf768
infograf768 - comment - 2 Dec 2014
avatar beat
beat - comment - 2 Dec 2014

My suggestion is to fix the main B/C that I'm seeing with the old B/C API of Joomla 2.5 where second argument of redirect() is a string, and third too:

I commented here that the new statement at this line:
b979c6b#diff-ee867f6f28651cdefd87314f73708ecfR548

Suggesting that instead of is_bool($status) there we could have (! is_int($status)) to clean all non-int status codes, before checking for the fatal error thrown on non-int or illegal codes. That way, if it's not an int, it gets a valid redirect code, and if it's int, it still redirects new way.

Agree ?

avatar beat
beat - comment - 2 Dec 2014

@wilsonge To reproduce the B/C bug and test the proposed simple fix, just install Community Builder from web-installer, publish CB login module, and try logging in or logging out using it in frontend.

avatar infograf768
infograf768 - comment - 2 Dec 2014

what when we used boolean for the 303/301 redirect?

avatar wilsonge
wilsonge - comment - 2 Dec 2014

@infograf768 #5287 this unit test demonstrates your code should work perfectly still with the changes I made. If it is broken then it is not related to the changes I made.

@beat Thanks for code sample. I'll get a PR to fix stuff within the next couple of hours with unit tests

avatar wilsonge
wilsonge - comment - 2 Dec 2014

Beat your issue should be fixed by #5290

If we don't have a valid status code I added in your suggested check and just defaulted to 303 to keep b/c for now. However I think for 4.0 (when b/c can be broken) we still should revert to an invalid argument exception to keep things clean

I'd still advise you move to the non-2.5 way of doing things. Does passing in an empty message not just seem horrifically wrong xD

avatar beat
beat - comment - 2 Dec 2014

@wilsonge Thanks!

PR #5290 works for me too code-wise. Will test and feedback on the 5290 PR.

In Joomla 4.0, the whole B/C "if" part could be removedĀ (which would have been another advantage of fixing the B/C issue in.... the B/C aera lol)

As said above, have added a task to modernize that part of old code :)

But I was worrying about existing sites and existing extensions (for 2 feedbacks here testing off master, probably 200+ would have broken too).

Btw, a redirect without a message to display on top is perfectly legit and ok imho in many situations where the hassle of a confirmation message for an obvious change of state is a UX overkill.

avatar beat
beat - comment - 2 Dec 2014

:+1: Tested and reviewed PR #5290 looks good to me, which closes already the B/C issue raised above! Thanks @wilsonge for fixing it and @JoomliC for your report, feedbacks and tests too. :+1:

avatar JoomliC
JoomliC - comment - 2 Dec 2014

i just wonder if @infograf768 has still language issue ?
b979c6b#commitcomment-8794568

avatar infograf768
infograf768 - comment - 2 Dec 2014

Looks like I now get a 301 instead of the unwanted 303. Merging. Thanks.

avatar zero-24 zero-24 - change - 14 Oct 2015
Labels Removed: ?

Add a Comment

Login with GitHub to post a comment