?
avatar qoolman21
qoolman21
27 Sep 2017

Steps to reproduce the issue

  1. Create menu item of category (should contain some artcles with tags assigned) with blog layout and set filter by custom tag
  2. Create menu item of category (should contain some artcles with no tags assigned) with blog layout and don't set filter by any tag (default setting)
  3. Go to front view of category blog created in step 1.
  4. Next go to front view of category blog created in step 2.

Expected result

See articles based on menuitem settings in both category views

Actual result

See no articles in category with no tags as tag filter remembers flter state form previously visited category with tag filter set in menuitem options

System information (as much as possible)

Any Joomla! 3.8

Additional comments

Solution:
/components/com_content/models/articles.php

Original:
line 509: $tagId = $this->getState('filter.tag');

Correct:
line 509: $tagId = JFactory::getApplication()->input->get('filter_tag', 0, 'uint');

Votes

# of Users Experiencing Issue
2/2
Average Importance Score
4.00

avatar qoolman21 qoolman21 - open - 27 Sep 2017
avatar joomla-cms-bot joomla-cms-bot - labeled - 27 Sep 2017
avatar franz-wohlkoenig franz-wohlkoenig - change - 27 Sep 2017
Priority Critical Medium
Status New Discussion
avatar joomla-cms-bot joomla-cms-bot - edited - 27 Sep 2017
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 27 Sep 2017

Can't confirm.

Setting both Menus as stated above.

  • In Menu "Blog and Tags" Articles are shown using Tag.
  • In Menu "Blog without Tags" Articles are shown if they have a Tag or not. So setting Tag to "None" means "ignore if a Tag is set or not". Try: Set in Menu a not used Tag > no Article is shown.
    This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/18138.
avatar Hurmeli
Hurmeli - comment - 28 Sep 2017

I can confirm.

Same exact problem after updating from 3.7.5 to 3.8.0.

This should be fixed ASAP as it renders category blog with tag filtering useless.


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

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 28 Sep 2017

@Hurmeli can you make a Pull Request? This is needed as first Step to fix ASAP.

avatar mbabker
mbabker - comment - 28 Sep 2017

The fix is not valid as it means this value cannot be passed through the model state but only through the request data (so it breaks other programmatic uses of the model, i.e. in modules). By default, this particular state value is set from the request data in the same way for this model, so that alone is not the problem.

Category views use the category model on the frontend, and the category model uses the articles model to load data. The category model uses a manner to populate this state value that also uses the active user session. So the fix that is needed is to expand the state keys in a way that allows for multiple active contexts. And this isn't a problem isolated to this particular view or configuration.

avatar csthomas
csthomas - comment - 28 Sep 2017

I have not tested, line 117 in populateState, replace:
$value = $this->getUserStateFromRequest($this->context . '.filter.tag', 'filter_tag', 0, 'int');
by
$value = $app->input->getInt('filter_tag', 0);

avatar mbabker
mbabker - comment - 28 Sep 2017

No. Again, that removes being able to programmatically set the user state outside the model and forces the value to only be readable from the request. Additionally, some state values are stored to the session so that when you navigate away from a filtered view you return with the same set of filters active.

Again, the problem is not the fact that the state is in use. The problem is in the fact there is not enough uniqueness between state keys for the behavior to work consistently.

avatar csthomas
csthomas - comment - 28 Sep 2017
	protected function populateState($ordering = null, $direction = null)
	{
		$app = JFactory::getApplication('site');
		$pk  = $app->input->getInt('id');

		$this->setState('category.id', $pk);

		//$value = $this->getUserStateFromRequest($this->context . '.filter.tag', 'filter_tag', 0, 'int');
		$value = $app->input->getInt('filter_tag', 0);
		$this->setState('filter.tag', $value);

IMO for programmatically set we use ignore_request that do not call populateState in category model

avatar Hurmeli
Hurmeli - comment - 28 Sep 2017

@franz-wohlkoenig

I'm not aware of any fix. I was simply confirming that the problem exists.

avatar mbabker
mbabker - comment - 28 Sep 2017

Right, for programatic configuration you would pass that flag. But for the default behavior when state is autopopulated, you are breaking more than you are fixing IMO by removing the ability to read and persist the value with the session, and again to fix that requires that the key that is used be more unique than what is basically right now com_content.category.filter.tag. We have the PK a few lines above that, it is not hard to change the key to basically be com_content.category.filter.$pk.tag so that the persisted filter states do not apply to everything using the model but only to that specific category ID. If you look later in the function, we are already doing this type of filtering with the menu item ID.

avatar csthomas
csthomas - comment - 28 Sep 2017

OK, you solution is better. It looks like a search form that should remember the last searched fields per category.

avatar danielmreck
danielmreck - comment - 4 Oct 2017

I can also confirm this problem occurs in version 3.8.1.

avatar csthomas
csthomas - comment - 5 Oct 2017

@qoolman21 @Hurmeli @danielmreck You can test patch at #18248

avatar joomla-cms-bot joomla-cms-bot - change - 5 Oct 2017
Closed_By franz-wohlkoenig joomla-cms-bot
avatar joomla-cms-bot joomla-cms-bot - close - 5 Oct 2017
avatar franz-wohlkoenig franz-wohlkoenig - change - 5 Oct 2017
Status Discussion Closed
Closed_Date 0000-00-00 00:00:00 2017-10-05 17:01:59
Closed_By franz-wohlkoenig
avatar joomla-cms-bot
joomla-cms-bot - comment - 5 Oct 2017
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 5 Oct 2017

closed as having Pull Request #18248

Add a Comment

Login with GitHub to post a comment