Skip to content
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

ContentHelperRoute::getCategoryRoute -> minor bug in categories URLs #20527

Closed
joomlabeat opened this issue May 22, 2018 · 6 comments
Closed

Comments

@joomlabeat
Copy link
Contributor

joomlabeat commented May 22, 2018

Steps to reproduce the issue

I noticed a minor issue in mod_articles_categories module, for the Categories URLs, because of the way ContentHelperRoute::getCategoryRoute handles the $layout from $jinput.
Not sure if this bug appears anywhere else where ContentHelperRoute::getCategoryRoute is called, but for the mod_articles_categories we get URLs like below in cycles, depending from where we view the categories and when there is no menu-item for those categories to define a layout.

index.php?option=com_content&view=category&id=12&layout=&Itemid=119
index.php?option=com_content&view=category&id=12=&Itemid=119

Notice that the layout param in the first occasion is just empty, which with SEF on it ends up to URLs like below:
/blog/nature/16-animals?layout=
/blog/nature/16-animals

To reproduce this, create an articles categories module for a category tree e.g. you have a blog category and subcategories. Create menu items for the parent categories and just let the children without menu items. Place the module in all pages (articles, featured items and even other component), so to make sure there isn't a $layout for the categories view defined.
Start clicking on your module's categories links from your various pages and you will notice the non-constant URLs.

Expected result

Categories URLs should be the same for the same categories.

Actual result

Categories URLs toggles as described above, depending on the $layout param.

System information (as much as possible)

Joomla 3.8.7

Additional comments

The issue appears to be in the way ContentHelperRoute::getCategoryRoute deals with the layout param from $jinput

/components/com_content/helpers line 82 - 88:

$jinput = JFactory::getApplication()->input;
			$layout = $jinput->get('layout');

			if ($layout !== '')
			{
				$link .= '&layout=' . $layout;
			}

At line 85, it does a strict comparison for $layout !== '' and if it's not, then it appends it to the URL. But this is not always the case, as I don't know about other cases, in those that I tested it out, $layout came back as null. So the $layout !== '' results to true.

I think that unless we are expecting a layout to equals to "0", we could go with:

if (!empty($layout))

@joomlabeat joomlabeat changed the title ContentHelperRoute::getCategoryRoute -> minor bug in categories URLs due ContentHelperRoute::getCategoryRoute -> minor bug in categories URLs May 22, 2018
@joomlabeat
Copy link
Contributor Author

Also - not sure about this - but what about in the case of a missing $layout for a category to default to the categories/global params?

@infograf768
Copy link
Member

I think we already have a PR for this, can't remember which one

@joomla-cms-bot joomla-cms-bot changed the title ContentHelperRoute::getCategoryRoute -> minor bug in categories URLs ContentHelperRoute::getCategoryRoute -> minor bug in categories URLs May 22, 2018
@ghost
Copy link

ghost commented May 22, 2018

closed as fixed by #20229

@joomla-cms-bot
Copy link

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

@infograf768
Copy link
Member

Thanks folks... my memory is not what it was... ;)

@joomlabeat
Copy link
Contributor Author

I searched for this, but didn't find anything at first place. Now reading #20229
Have a good day!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants