New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix mod_login not considering Itemid when redirecting #6542
Conversation
@test success Thanks @Erftralle This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/6542. |
@test success |
RTC Thanks! This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/6542. |
Hi, just tested this as possible solution for my issue #6549 but there is still a 'glitch': |
@Ruud68 Are you sure that this is the fault of Joomla and not some third party code that messes around in the routing code? Can you post the URL of your site? |
Hi @Hackwar , when reverting to a restore (Joomla 3.4) it works, when applying 3.4.1 it stops working (on multiple sites). The conclusion that I have is then that it is because of the patch :) If you need anything please let me know :) |
@Ruud68 the question isn't wether 3.4.1 is "broken" in that regard or not. The question is, if the fix that is provided in this PR fixes the issue. So far you've only said that 3.4.1 is broken, not that this PR does not fix your issues. |
Hi @Hackwar problem was introduced with 3.4.1. reverting to 3.4 fixes it. Implementing your patch on 3.4.1 does alter the outcome of the resulting url (different), but problem is still there: please look at two provided testsites > you can create an account on both of the to see what happens. To be short: patch does NOT fix problem :( |
Although it solves some of the issues here, the url obtained by the redirect are not the same as the url obtained by using directly the menu item targetted. and I get when redirected: So, same issue as stated above by @Ruud68 and no specific extension in the way. |
Let me add that reverting #6034 solves the issue here. |
@Hackwar Compare the code in old version (3.4.0) I can see that something wrong:
My quick merge code in both versions return this:
This is just based on my code review. Maybe it could help. |
Hmm. I wonder why in case "Stay on the same page", we cannot get the return url use: $url = JUri::getInstance()->toString(); Then the code of the method getReturnURL can be:
It seems work well (with my test). |
public static function getReturnURL($params, $type)
{
$app = JFactory::getApplication();
$menu = $app->getMenu();
$item = $menu->getItem($params->get($type));
if ($item && $item->link)
{
$url = 'index.php?Itemid=' . $item->id;
}
else
{
// Stay on the same page
$url = JUri::getInstance()->toString();
}
return base64_encode($url);
} is the same |
@Hackwar Yes, it is the same. Maybe @Erftralle can update your PR with the new code? |
does work OK here. No more &view= etc. |
Done, with some minor modifications. Thanks. |
works but it will not if redirecting to an alias menu item as we would get a 404. What do you think? |
Thanks for testing!
That would be acceptable for me. |
No, it is not possible (without modifying the data directly in the DB) to select an alias as the target for an alias. |
Can't confirm that. I've just tested it (without modifying the data directly in the DB) with the current staging branch. Maybe it would be a good idea to prevent that. |
The other types of menu item which would give a 404 are maybe the solution would be to prevent these types of menu from being proposed in the "menuitem" dropdown? |
Hi, really want to help by testing. But I am unsure what changes to implement looking at all the snippets of code above. there is the risk that I will be testing the wrong code :( So if we have something that I can test, can somebody summarize the changes that need to be implemented to ensure the testing of the correct code? |
@infograf768 If that's the case, then Yes, we should do that. However, to simply the work, I think you can simply disable the menu items so that users cannot choose it. Right now, only separator menu item type is disabled(See https://github.com/joomla/joomla-cms/blob/staging/modules/mod_login/mod_login.xml#L45), you can modify it to disable="separator,alias,link,heading" . Same for logout redirect url as https://github.com/joomla/joomla-cms/blob/staging/modules/mod_login/mod_login.xml#L54 |
I propose to use this PR as it is for the helper + changing mod_login.xml to prevent proposing menu types which should not be used to redirect, i.e.
This will grey-out the unwanted types: |
heh, looks like we had the same idea... |
@infograf768 You are so fast :D. |
@Ruud68 If you know how to edit code on your site, then you can follow the instruction below to test it:
I believe it will solve your issue. Then you can update the modified files to your live site while waiting for 3.4.2 released. |
@infograf768 @joomdonation : Thanks for your help, modified PR according to your proposals. |
Hi, just to confirm that proposed changes to helper.php and mod_login.xml worked on multiple sites. |
I guess this can be merged now. :) |
RTC based on tests also here: #6549 This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/6542. |
Hi, just encountered a 'small' issue :( it is possible to select an unpublished menu entry as the redirect page resulting in unexpected behaviour. Probably adjust the mod_login.xml a little more? |
Do you mean to grey out unpublished menu items as well? That would make not much sense as it would always be possible to unpublish a menu item after selecting a redirect page in the module options.
Have to correct myself. I personally would expect the site administrator to select a published redirect page and would expect him to check if the redirect is working as expected, but what do others think about that? |
I agree. However, I think only show published menu items will help admin of the site find and select the menu item he wants easier. I made small PR to your branch, just merge it and I think it would be OK. |
As I already stated above this makes not much sense for me because it is always possible to unpublish a menu item after a redirect has already been selected in the module options. |
@test success |
Fix mod_login not considering Itemid when redirecting
Steps to reproduce the issue
Expected result
Pages redirected to should show the modules belonging to the menu item
Actual result
Pages redirected to don't show the correct modules
System information (as much as possible)
Joomla! 3.4.1
Additional comments
Due to the changes in #6034 now the Itemid is missing when calculating the redirection URL.
The patch should correct that.