J3 Issue ?
avatar pixxelfactory
pixxelfactory
9 Jan 2018

Steps to reproduce the issue

1.) Create a menu type "Menu Item Alias", point it to another menu item, preferably to one of its direct submenus, for instance:

  • agency
    • team
    • contact us

Point "agency" to "team", wich is a standard single-article menu item

2.) The Menu path in this case would be for instance:
www.yourdomain.com/en/agency/team

3.) Now open this:
www.yourdomain.com/en/agency

Expected result

Redirect to www.yourdomain.com/en/agency/team with a 301 code

Actual result

Shows statistics about number of articles in different categories

System information (as much as possible)

Joomla 3.8.x

Additional comments

avatar pixxelfactory pixxelfactory - open - 9 Jan 2018
avatar joomla-cms-bot joomla-cms-bot - change - 9 Jan 2018
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 9 Jan 2018
avatar swap-nil7
swap-nil7 - comment - 9 Jan 2018

Hi I am new to opensource and want to contribute. Can I work on this issue?

avatar Quy
Quy - comment - 9 Jan 2018

This is a community developed software. You don't have to get permission. Contribute if/when you can so go for it.

avatar Rmkrishan
Rmkrishan - comment - 10 Jan 2018

I am not able to find articles when logged into admin panel of joomla website. Can anyone find the reasons and give solution to this problem?


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/19340.
avatar infograf768
infograf768 - comment - 10 Jan 2018

@Rmkrishan
Please use the forums. This concerns joomla coding. Thanks!

avatar infograf768
infograf768 - comment - 10 Jan 2018

@pixxelfactory
I cannot reproduce your issue here.
screen shot 2018-01-10 at 08 59 58

Both /en/agency and /en/agency/team display the article concerned.

You may have another menu/extension creating this problem

Note: this is evidently on a multilingual site.

avatar Rmkrishan
Rmkrishan - comment - 10 Jan 2018

What is the solution to this problem?

avatar Quy
Quy - comment - 10 Jan 2018

@Rmkrishan Your issue appears not to be a bug in the core software. Please post your question to the Joomla forums.

avatar andrepereiradasilva
andrepereiradasilva - comment - 11 Jan 2018

Hi folks. At least some part seems a bug in the Core. A non cached 301 redirect should exist. else you have two different URLs for one page which shouldn't exist, also note the breadcrumb is different, which probably means the menu assigment (ex: modules) will not be respected Unless you assign to both menu items.

Example of a non cached 301 redirect https://github.com/joomla/joomla-cms/blob/staging/plugins/system/languagefilter/languagefilter.php#L454

avatar pixxelfactory
pixxelfactory - comment - 11 Jan 2018

As for the statistics, in our case it probably was some joomla-update error or some thing like it, because we tried to reinstall the core files via joomla-update, it now shows the target article.
But it does not perform a 301 redirect to the target url, wich is not the best solution (duplicate urls, different breadcrumbs and module assignments as mentioned).
I wrote a small plugin that performs the redirect if the current menu is a menu alias, code, also made sure that the redirect is not cached as mentioned by @andrepereiradasilva and used the code from the language-filter plugin. What do you think about this approach as temporary solution?

<?php
/**
 * @package   System Plugin - Small redirect plugin for menu aliases
 * @version   0.0.1 Alpha
 * @author    Alex Franzelin
 * @copyright (C) 2018 - Alex Franzelin
 * @license   GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 **/

// no direct access
defined('_JEXEC') or die();


/**
 * Plugin redirects user to target menu if the current menu item is an alias
 **/
class plgSystemAlias extends JPlugin
{
	/**
	 * @param $subject
	 * @param $config
	 */
	public function __construct(&$subject, $config)
	{
		parent::__construct($subject, $config);
	}
	
	/**
	 *	Perform menu-check after routing
	 **/
	public function onAfterRoute()
	{
		$app = JFactory::getApplication();
		
		// Only on the frontend
		if($app->isSite())
		{
			$active = $app->getMenu()->getActive();
			$params = $active->params;
			
			// If current menu is alias..
			if($active->type == 'alias')
			{
				// ..do not cache this redirect like mentioned in the github thread..
				$app->setHeader('Expires', 'Wed, 17 Aug 2005 00:00:00 GMT', true);
				$app->setHeader('Last-Modified', gmdate('D, d M Y H:i:s') . ' GMT', true);
				$app->setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0', false);
				$app->setHeader('Pragma', 'no-cache');
				$app->sendHeaders();
				
				// ..get the target menu-id and redirect user
				$target = $params->get('aliasoptions');
				$route = JRoute::_('index.php?Itemid='.$target);
				$app->redirect($route);
			}
		}
	}
}
avatar andrepereiradasilva
andrepereiradasilva - comment - 11 Jan 2018

IMHO a change like that should be done at core Router level, not at plugin level - since the menu system is a part of the core.

Also since the Admin app also as the alias menu item in it's menu system it should be done for the SiteRouter and the AdministratorRouter.

Not sure, because i don't fully understand the routing system, but probably at the end of the parse route method . Example, adding in the "SiteRouter" https://github.com/joomla/joomla-cms/blob/staging/libraries/src/Router/SiteRouter.php#L139

// If it's a alias menu item type do a non cached 301 redirect to the real menu item.
$active = $this->menu->getActive();

if ($active !== null && $active->type === 'alias')
{
	$this->app->setHeader('Expires', 'Wed, 17 Aug 2005 00:00:00 GMT', true);
	$this->app->setHeader('Last-Modified', gmdate('D, d M Y H:i:s') . ' GMT', true);
	$this->app->setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0', false);
	$this->app->setHeader('Pragma', 'no-cache');
	$this->app->sendHeaders();
	$this->app->redirect(\Joomla\CMS\Router\Route::_('index.php?Itemid=' . $active->params->get('aliasoptions', $this->menu->getDefault()), false), 301);
}

Basic tests seems to work. Of course would need to be fully reviewed and checked for someone who understands the core router system better than i do. ex: @csthomas :)

avatar pixxelfactory
pixxelfactory - comment - 12 Jan 2018

Yeah, i just wrote the plugin as temporary solution (since i need to fix this bug today, because the client is not amused ;-) ).

avatar franz-wohlkoenig franz-wohlkoenig - change - 14 Jan 2018
Status New Discussion
avatar franz-wohlkoenig franz-wohlkoenig - change - 14 Jan 2018
Category com_content
avatar lenusch
lenusch - comment - 25 Jan 2018

@pixxelfactory - how do i use or insert your Plugin?
I tried but .... no clue :-D

avatar pixxelfactory
pixxelfactory - comment - 25 Jan 2018

@lenusch
Hi, simple:
create a directory inside plugins/system named "alias"
In there place three files:

  • index.html (empty html-file)
  • alias.php (paste the above code inside)
  • alias.xml (Use the following xml-code for instance):

<?xml version="1.0" encoding="utf-8"?> <extension version="3.0" type="plugin" group="system" method="upgrade"> <name>plg_system_alias</name> <author>pixxelfactory</author> <creationDate>January 2018</creationDate> <copyright>(C) 2018 pixxelfactory</copyright> <license>GNU General Public License v3; see LICENSE.txt</license> <authorEmail></authorEmail> <authorUrl>www.pixxelfactory.net</authorUrl> <version>0.0.1</version> <description>PLG_SYSTEM_ALIAS_XML_DESC</description> <files> <file plugin="alias">alias.php</file> <filename>index.html</filename> </files> <languages> <language tag="en-GB">language/en-GB/en-GB.plg_system_alias.sys.ini</language> </languages> <config> <fields name="params"> <fieldset name="basic"> </fieldset> </fields> </config> </extension>
After that, inside the Joomla-Administration go to:
Extensions/Manage/Discover and click the Discover-Button, check the alias plugin, install and afterwards activate it.
That's it
Best regards
pixxelfactory

avatar lenusch
lenusch - comment - 25 Jan 2018

@pixxelfactory thank you! before I used my plugin installer Script and generated a zip. it was installed correctly but i can't see where the File was placed :-D

worked good - thanks!

avatar brianteeman brianteeman - change - 25 Mar 2018
Labels Added: J3 Issue
avatar brianteeman brianteeman - labeled - 25 Mar 2018
avatar Quy Quy - change - 28 Sep 2018
Status Discussion Closed
Closed_Date 0000-00-00 00:00:00 2018-09-28 21:11:03
Closed_By Quy
avatar joomla-cms-bot joomla-cms-bot - close - 28 Sep 2018
avatar joomla-cms-bot
joomla-cms-bot - comment - 28 Sep 2018

Set to "closed" on behalf of @Quy by The JTracker Application at issues.joomla.org/joomla-cms/19340

avatar Quy
Quy - comment - 28 Sep 2018

Please test PR #22432


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

Add a Comment

Login with GitHub to post a comment