? Success

User tests: Successful: Unsuccessful:

avatar infograf768
infograf768
10 May 2015

On a multilanguage site, if "Automatic Language Change" is set to Yes and the user logs in on a page which is not using his default site language, the redirect is always to the Home page of the language set for the user, even when it is a Register to Read More link which is displayed in another language than the user site language.
This patch solves this issue by checking which language is used in the page proposing the Register to Read More link, and change the redirection to that language (and article) in case it is necessary.

Test:
Set "Automatic Language Change" to "Yes" in the languagefilter system plugin parameter.
Set the registered user site language to another language than the global site default language.

Create an article with Access set to Registered tagged to a different language than the user default site language
Toggle editor and paste this in the text area (as it the Read More button is broken for now in staging)

<p>some text before read more</p>
<hr id="system-readmore" />
<p>some other text</p>

Create a category blog menu item displaying the category of that article and make sure the article is displayed on the first page (that is just to make it easier to check) in a different language than the user default site language
Make sure that Options->Show Unauthorised Links is set to Yes.

Load the page containing the menu item (it is a different language than the user default site language
Click on the menu item
=> The article will display with a "Register to Read More" button.
Click on the button
=> the login fields are displayed
Login
=> The user is redirected to the home page for his site language.

Logout, patch and retest;
The user is now correctly redirected to the article in full in language of the article.

avatar infograf768 infograf768 - open - 10 May 2015
avatar zero-24 zero-24 - change - 10 May 2015
Labels Added: ?
avatar zero-24 zero-24 - change - 10 May 2015
Labels Added: ?
avatar zero-24 zero-24 - change - 10 May 2015
Category Multilanguage
avatar zero-24 zero-24 - change - 10 May 2015
Status New Pending
avatar infograf768
infograf768 - comment - 11 May 2015

@smz @dgt41
Please test.

avatar fontanil
fontanil - comment - 11 May 2015

@test: patch works fine. Thanks!

avatar zero-24 zero-24 - alter_testresult - 11 May 2015 - fontanil: Tested successfully
avatar Bakual
Bakual - comment - 11 May 2015

Can't you use JInput to check for the return or view parameter? Looks really wrong to directly access the $_SERVER variable.

avatar Bakual
Bakual - comment - 11 May 2015

Ah crap, I missed you check the referrer.
Honestly, that sounds quite messy to me. Code should behave the same no matter where we come from.

avatar infograf768
infograf768 - comment - 11 May 2015

The issue is that a "normal" login (whether it comes from a direct login menu item or the login module) does not contain the return url. This is the only difference with what we get from the Read More.
Therefore our only way to decide about the language to display after login depends of this parameter.

avatar infograf768
infograf768 - comment - 11 May 2015

Don't know how to use JInput for that.

avatar Fedik
Fedik - comment - 11 May 2015

is there HTTP_REFERER different from current URL?
I not sure, but in theory if you submit the form, then should be same
And then in this case can use

$url = JUri::getInstance();
if ($url->hasVar('return') && $url->getVar('view') === 'login' )
...
...

just theory

avatar mbabker
mbabker - comment - 11 May 2015

The issue is that a "normal" login (whether it comes from a direct login menu item or the login module) does not contain the return url.

The login module and com_users login view both support the return param, so I don't think it's fair to base the check on the existence of that.

avatar infograf768
infograf768 - comment - 11 May 2015

(Anyway when sef on AND there is a login menu item, view=login is not in the referrer, just tested...)
So I change that part and let's try to find something else... :)

avatar Bakual
Bakual - comment - 11 May 2015

Why should it make a difference whether we come from a login page or the requested page (article view) is directly entered. In all cases it shouldn't redirect the user to the homepage but instead it should stay on the language and item requested by the URL.
Maybe that is the real bug? It just shouldn't redirect to the homepage at all after a login. If the URL already defines a language, that should have precedence over the default setting by the user.

avatar infograf768
infograf768 - comment - 12 May 2015

I do not agree, @Bakual.
The whole point is that "Automatic Language Change" was specially introduced to redirect the user to its default site language home page (or the associated item in his language, if exists) when login , and I try to solve the "Register to Read More" special case.
That is the ONLY use for the user site language in multilingual.

avatar infograf768
infograf768 - comment - 12 May 2015

@Fedik
HTTP_REFERER is different from current URL when login.
The current url does not contain the return but only ?task=user.login

avatar joomdonation
joomdonation - comment - 12 May 2015

Maybe we should respect return url if it is passed in the login form and only process "Automatic Language Change" if no return url is passed. Something like this:

$return = $this->app->input->post->get('return', '', 'BASE64'); 
if ($this->app->isSite() && $this->params->get('automatic_change', 1) && empty($return))
{

}
avatar joomdonation
joomdonation - comment - 12 May 2015

Ah, sorry. I think I am wrong. It will defeat the purpose of having "Automatic Language Change" when there return param is passed in the login module. So please ignore my comment.

avatar infograf768
infograf768 - comment - 12 May 2015

yeah, tricky... What makes the Register to Read More specific is what we look for.

avatar joomdonation
joomdonation - comment - 12 May 2015

Infact, I don't think it is "Register to Read More specific". As a third party extension developer, in my extensions, I also have code:

  • Redirect users to login page with return variable passed in the URL.
  • Or has a login form within my extension to allow users to login before continue the process. In that form, I have return as hidden variable to ask Joomla to redirect users back to that page to continue the process

In this case, I would expect Joomla to respect the return url which I passed instead of redirect user to homepage in case no association found. I think I agree with @Bakual. Maybe in case no association is found and there is return url passed from login form, we should redirect users back to that URL instead of redirect to home language.

avatar Bakual
Bakual - comment - 12 May 2015

Codewise there is no difference if a user enters the URL manually, followed a link or clicked the readmore button (and went to login and back). It's all the exact same URL and should actually behave the same.
If you need a different behavior for readmore, you should add a parameter to the URL which says so. &readmore=1 or &fixedlanguage=1 or something like that.
Then it's easy to write code for it.

avatar infograf768
infograf768 - comment - 13 May 2015

wrong comment

avatar infograf768
infograf768 - comment - 13 May 2015

My mistake, deleted former comment.

avatar infograf768
infograf768 - comment - 16 May 2015

The new code solves the issue by redirecting to the user site language Home page ONLY when login from the Home page.
It keeps redirecting to the associated menu item if logging from a page with such menu item.
Therefore it is B/C and redirect url set in the login module (except when the url is to another language menu item which should anyway never be done!) is now respected when NOT on the home page instead of always redirecting to the Home page.

Thanks @joomdonation . This was a 3 days collaboration work!

avatar joomdonation
joomdonation - comment - 16 May 2015

The behavior is now correct:

  1. If an association of the active menu item is found, the the system will redirect to that association menu item

  2. If no association is found and users login from homepage, he will be redirected to homepage of his language.

  3. Otherwise, he will be redirected to the return URL (passed in the request)

This PR not only fixes the issue described in description but also fix wrong behavior before (always redirect to home page of user language if no association is found)

So @test success from me.

3a9b3fb 16 May 2015 avatar infograf768 cs
avatar infograf768
infograf768 - comment - 16 May 2015

@smz @dgt41
need testers here :)

avatar zero-24 zero-24 - alter_testresult - 16 May 2015 - fontanil: Not tested
avatar zero-24 zero-24 - alter_testresult - 16 May 2015 - joomdonation: Tested successfully
avatar Bakual
Bakual - comment - 16 May 2015

Code looks much better now. Nice work, thanks!

avatar dgt41
dgt41 - comment - 16 May 2015

@test ok acoording to @joomdonation comment #6915 (comment)

avatar fontanil
fontanil - comment - 16 May 2015

@test: new patch works here. Thanks!

avatar zero-24 zero-24 - alter_testresult - 16 May 2015 - dgt41: Tested successfully
avatar zero-24 zero-24 - alter_testresult - 16 May 2015 - fontanil: Tested successfully
avatar zero-24 zero-24 - change - 16 May 2015
Status Pending Ready to Commit
avatar zero-24
zero-24 - comment - 16 May 2015

RTC :+1:


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

avatar zero-24 zero-24 - change - 16 May 2015
Labels Added: ?
avatar zero-24 zero-24 - change - 16 May 2015
Labels Added: ?
avatar smz
smz - comment - 16 May 2015

Sorry, too late, but @test:OK here too...

avatar smz smz - test_item - 16 May 2015 - Tested successfully
avatar zero-24 zero-24 - close - 21 May 2015
avatar Kubik-Rubik Kubik-Rubik - change - 21 May 2015
Status Ready to Commit Closed
Closed_Date 0000-00-00 00:00:00 2015-05-21 08:07:45
Closed_By Kubik-Rubik
avatar Kubik-Rubik Kubik-Rubik - close - 21 May 2015
avatar Kubik-Rubik
Kubik-Rubik - comment - 21 May 2015

Merged. Thank you @infograf768!

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

Add a Comment

Login with GitHub to post a comment