No Code Attached Yet bug
avatar ahahu
ahahu
18 Feb 2023

Steps to reproduce the issue

  • Run Joomla instance in subfolder "/joomla"
  • Create menu items of type "Login" and "Logout"
  • Set "Logout Redirection Page" to any public page of your site
  • Open the frontend on "https://yoursite.com/login.html and login to the frontend
  • Click menu item "Logout"

Expected result

Logout should be successful and redirect to the selected logout redirection page
The /logout.html should redirect to something like /index.php?option=com_users&task=user.logout....&return=...

Actual result

the logout.html redirects to /joomla/index.php?option=com_users&task=user.logout....&return=... which results in a 404 because the /joomla prefix should not be there
The user is not logged out

System information (as much as possible)

Joomla 4.2.8, PHP 8.0.27
Linux ms11720 3.10.0-1160.62.1.el7.x86_64 #1 SMP Tue Apr 5 16:57:59 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Shared Hoster

Additional comments

I was able to fix this by changing the setRedirect in function menuLogout in file joomla/components/com_users/src/Controller/UserController.php from:
$this->setRedirect('index.php?option=com_users&task=user.logout&' . Session::getFormToken() . '=1&return=' . base64_encode($url));
to this
$this->setRedirect(Route::_('index.php?option=com_users&task=user.logout&' . Session::getFormToken() . '=1&return=' . base64_encode($url), false));

avatar ahahu ahahu - open - 18 Feb 2023
avatar joomla-cms-bot joomla-cms-bot - change - 18 Feb 2023
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 18 Feb 2023
avatar brianteeman
brianteeman - comment - 18 Feb 2023

Set RewriteBase to "/joomla" in .htaccess file in folder /joomla

that was wrong and not needed

avatar ahahu ahahu - change - 18 Feb 2023
The description was changed
avatar ahahu ahahu - edited - 18 Feb 2023
avatar ahahu
ahahu - comment - 18 Feb 2023

Ok, I was just stating how the site is setup. I removed the RewriteBase and the error is still the same. So I removed this step in the reproduction description.

avatar brianteeman
brianteeman - comment - 18 Feb 2023

Your problem is that you have installed joomla in a subdirectory but you have the domain name pointing to the parent folder.

Either move the installation to the parent folder or change the server config to point to the correct folder and not to the parent

avatar joomdonation
joomdonation - comment - 19 Feb 2023

I could not re-procedure the issue on my local installation where Joomla is running on a sub-folder, too. However, while it could be wrong setup, we should still use Route::_ to get the redirect URL. Ping @Hackwar for taking a look.

avatar Hackwar Hackwar - change - 22 Feb 2023
Labels Added: bug
avatar Hackwar Hackwar - labeled - 22 Feb 2023
avatar brianteeman
brianteeman - comment - 22 Feb 2023

@joomdonation it seems that its about 50/50 the usage of Route::_ with setRedirect

avatar joomdonation
joomdonation - comment - 23 Feb 2023

@brianteeman I just tried to scan the code and see that most of the url passed to setRedirect call is wrapped with Route::_ already (especially when in is none sef URL with format index.php?option=com_......)

There are some setRedirect calls with Uri:root() or Uri::base(), it does not need to use Route::_ because these are absolute URLs (return site's URL) already.

So @Hackwar please look at the URL here to see if we should uses Route::_ as suggested by the author of this issue.

avatar joomdonation joomdonation - change - 24 Feb 2024
Status New Closed
Closed_Date 0000-00-00 00:00:00 2024-02-24 11:28:26
Closed_By joomdonation
avatar joomdonation joomdonation - close - 24 Feb 2024
avatar joomdonation
joomdonation - comment - 24 Feb 2024

Just checked again and found that the Route::_ call is already applied to the URL, see https://github.com/joomla/joomla-cms/blob/4.4-dev/components/com_users/src/Controller/UserController.php#L206, so the issue is fixed now. I'm closing this.

Add a Comment

Login with GitHub to post a comment