Skip to content

[5.4] Fix expired articles appearing in frontend category view#46637

Open
RudraHingu001 wants to merge 1 commit into
joomla:5.4-devfrom
RudraHingu001:fix-5.4-dev
Open

[5.4] Fix expired articles appearing in frontend category view#46637
RudraHingu001 wants to merge 1 commit into
joomla:5.4-devfrom
RudraHingu001:fix-5.4-dev

Conversation

@RudraHingu001

@RudraHingu001 RudraHingu001 commented Jan 7, 2026

Copy link
Copy Markdown

Pull Request for Issue #46614

Summary

Fixes an issue where expired articles were displayed in frontend category views.

Problem

Frontend category listings did not apply publish date constraints, allowing
expired articles to appear and affect article counts.

Solution

Enforced publish date filtering when retrieving articles in the category model.

Result

  • Expired articles are no longer shown
  • Correct article counts in category listings

Fixes #46614

@richard67

Copy link
Copy Markdown
Member

@RudraHingu001 When creating a pull request please stick with our pull request template, which suggests the reference to the issue to be in the first line (I have just fixed that for youz) and which provides headings for testing instructions and for checkboxes if documentation is required or not.

@richard67 richard67 changed the title Fix expired articles appearing in frontend category view [5.4] Fix expired articles appearing in frontend category view Jan 7, 2026
@webmasterab

webmasterab commented Jan 7, 2026

Copy link
Copy Markdown
Contributor

I have tested this item 🔴 unsuccessfully on a9f8d81

I applied the patch to my site using the Yootheme template.
pullrequest

I created a category with three articles.
One is expired; it's displayed in the category overview as green with "1" as published, which is incorrect.
categorie
artikelen

yootheme1

The others are red and disabled.
They don't count.

categorie

With this setting.
1 item expired.
You'll see this message on a basic template.

With Yootheme, this is counted as 1 item.
And it shouldn't be.
An expired item shouldn't be counted.
cassiopeia

It appears that an article in an expired category is still counted as a published article.


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

@brianteeman

Copy link
Copy Markdown
Contributor

An expired article is still published. The state of an article does not change when the publish date is either in the future or in the past

@richard67

Copy link
Copy Markdown
Member

An expired article is still published. The state of an article does not change when the publish date is either in the future or in the past

@brianteeman Does that mean that this PR is wrong, and the referenced issue #46614 should have been closed as expected behavior?

@brianteeman

Copy link
Copy Markdown
Contributor

From my perspective yes but thats just my opinion

@richard67

Copy link
Copy Markdown
Member

From my perspective yes but thats just my opinion

@brianteeman From my perspective, too. But the issue was labeled as but by @chmst .

@brianteeman

Copy link
Copy Markdown
Contributor

If you use core joomla content and test a blog category layout then it correctly counts the number of visible (puublished and current) articles. I have never used anything from yootheme and nor will I ever use anything from yootheme but if yootheme is not counting correctly then its because they are not counting correctly

@webmasterab

webmasterab commented Jan 8, 2026

Copy link
Copy Markdown
Contributor

Thanks for the replies.

Yootheme correctly says, see the link in the first message in the ticket there, that it's in Joomla.
https://yootheme.com/support/question/172237#answer-561640
Yootheme's ticket also refers to this closed pull #40172

It's also strange that an expired article is counted.

But as I understand it from the replies, this is 'normal' Joomla behavior.

How does Joomla check this and calculate that there are no articles in Cassiopea?
It indicates that there are no articles if there is one expired article.
Is this handled in Cassiopea's own code?

@brianteeman

Copy link
Copy Markdown
Contributor

No it is nothing to do with cassiopeia it is in the model for the content component which clearly yootheme ignores. yootheme is NOT just a template it does its own thing regarding selecting content and clearly it is wrong/incomplete!!

// Filter by start and end dates.
if (
!(is_numeric($condition) && $condition == ContentComponent::CONDITION_UNPUBLISHED)
&& !(\is_array($condition) && \in_array(ContentComponent::CONDITION_UNPUBLISHED, $condition))
) {
$query->where(
[
'(' . $db->quoteName('a.publish_up') . ' IS NULL OR ' . $db->quoteName('a.publish_up') . ' <= :publishUp)',
'(' . $db->quoteName('a.publish_down') . ' IS NULL OR ' . $db->quoteName('a.publish_down') . ' >= :publishDown)',
]
)
->bind(':publishUp', $nowDate)
->bind(':publishDown', $nowDate);
}

@webmasterab

Copy link
Copy Markdown
Contributor

@brianteeman Thanks for the response, I will pass this on in the ticket at Yootheme

@michaelmaass

Copy link
Copy Markdown

@webmasterab

I installed a plain vanilla Joomla 6.0.2, installed sample content, created a parent category, moved the sample content categories into that. Then I set the "Finish Publishing" date of 2 of the "Blog" category's articles to a date in the past (but left them at Status: Published), set 1 of the 4 articles to Status: Unpublished.

With "Cassiopeia" a "Category List" menu item for the parent category, set to # Articles in Category: Show displays the count 3 in the public frontend.

article-count-cassiopeia-category-list-menu-item

Then I installed YOOtheme Pro, used Dynamic Content, and mapped a field to the "Blog" category's "Article Count". In the preview and in a private/incognito window the count was also 3.

article-count-yootheme-pro-dynamic-content

As far as I can see the count is fully consistent regardless of the template, and — in my test — the very same "3" in Cassiopeia and in YOOtheme Pro.

At the same time, the native count of 3 seems wrong to me because a public user in the frontend gets the information that there are 3 articles but will never see those that are past their "Finish Publishing" date. Technically, it might be accurate that there are 3 articles with the status "Published".

@brianteeman

Copy link
Copy Markdown
Contributor

The count is a different issue and not expired articles appearing in frontend category view

@webmasterab

Copy link
Copy Markdown
Contributor

But it's precisely the counting that matters.

Because an expired item is counted, the feature doesn't work in Yootheme.

Yootheme then sees one item listed even though it's expired and no longer visible to one user.

The counting is the problem.

@brianteeman

Copy link
Copy Markdown
Contributor

Related Pull Request for the display of the count #44950

@michaelmaass

Copy link
Copy Markdown

@brianteeman The count is a different issue and not expired articles appearing in frontend category view

This is here is absolutely and entirely about the count, the output of the option # Articles in Categoryin the frontend.

It is not about whether or not articles appears in the frontend.

Without testing it, you wrote that YOOtheme Pro displays the wrong count. I tested it and could not confirm it. The number is the same in Cassiopeia and YOOtheme Pro.

@webmasterab

Copy link
Copy Markdown
Contributor

Related Pull Request for the display of the count #44950

This is about the articles that are inaccessible.

So that's correct for that request.

But what I mean is just public articles.
But then one has expired, and that one is still counted.

And the request you're referring to is for Joomla 6.
And I'm still running 5.4.

@webmasterab

Copy link
Copy Markdown
Contributor

I've now created a category with one expired and one disabled item.
I think that should be zero items.
y001
However, the counter says this
y002
At Yootheme it also counts 1
y003
And then this option doesn't work.
Because it keeps counting the 1 of the expired item.
y004

@brianteeman

Copy link
Copy Markdown
Contributor

the confusion is from your previous statements

The articles in the backend are counted correctly, for example, 2 published and 2 unpublished.
In the frontend, 4 are counted, which is incorrect.

and a lack of clarity that this was referring to the count displayed in a category list view

@webmasterab

Copy link
Copy Markdown
Contributor

I've also added the link to the yootheme ticket in my issue at #46614

It was already mentioned there.
It's good that it's clear now and we know where to look.
But I don't know much about Joomla code.
Is it possible to adjust the count?

@brianteeman

Copy link
Copy Markdown
Contributor

#40172 (comment)

For core joomla it can be worked around by chosing not to display the article count in the front end list view

However that will not help you in yootheme as from your screenshots (i've never use yootheme nor will i ever) the count is being used as a condition in the admin. As far as I am concerned the correct fix for yootheme is to update the yootheme code so that it correctly takes into account the publish_up/down fields in the same way that the core of joomla already does when counting the articles in the blog category view (as i have shared previously)

@janschoenherr

Copy link
Copy Markdown
Contributor

@brianteeman The code you quoted here (#46637 (comment)) has nothing todo with the category item count, but instead it filters the articles that are shown. The wrong article count can be replicated on the Category Blog layout in Joomla core.

That being said, I don't think this PR fixes the item count issue. As you pointed out, this would have to be fixed in a similar fashion as #44950.

But again, the issue has nothing to do with YOOtheme Pro and can be replicated in Joomla core.

@brianteeman

Copy link
Copy Markdown
Contributor

I can not replicate this in a category blog. Maybe I am missing something?

@janschoenherr

Copy link
Copy Markdown
Contributor

With Cassiopeia as theme.

Steps to reproduce the issue:

  • Create a category and a subcategory.
  • Assign two articles to the subcategory. Set one to be expired.
  • Create a menu item of type Article > Category Blog to point to the parent category.
  • In the Articles > Category configuration set # Articles in Category to show

If you go to that menu item in the frontend it will show the Article Count of 2 for the subcategory. If you then go to that subcategory, you'll see 1 article.

Bildschirmfoto 2026-01-09 um 14 52 07 Bildschirmfoto 2026-01-09 um 14 52 21

@brianteeman

brianteeman commented Jan 9, 2026

Copy link
Copy Markdown
Contributor

ah - that;s the same count as seen in the list view. My point was that the DISPLAY of articles was correct it is just the DISPLAY of the count that is incorrect and I stand 100% behind my previous comments

@janschoenherr

Copy link
Copy Markdown
Contributor

Yes, this PR references the Issue #46614 about the DISPLAY of the article count, which it does not seem to fix, as far as I can tell.

@RudraHingu001

Copy link
Copy Markdown
Author

Hi all,

I’ve opened a new PR that fixes the category article count issue by excluding
expired articles (respecting publish_up / publish_down dates).

PR: #46653
Fixes: #46614

The issue has been tested on Joomla 5.4 with the Cassiopeia template and
category menu item showing article counts.

Please let me know if a review is needed or if any adjustments are required.
Thanks!
image
image

@webmasterab

Copy link
Copy Markdown
Contributor

Reported here #46653 that I tested it successfully

$model->setState('params', Factory::getApplication()->getParams());
$model->setState('filter.category_id', $category->id);
$model->setState('filter.published', $this->getState('filter.published'));
$model->setState('filter.published', 1);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to break the possibility to set the published filter in the state.

@HLeithner Is that right? And should this PR be moved to 6.1-dev (if fixed)?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks wrong to me tbh, but hadn't a in deep look yet

@HLeithner HLeithner added the bug label Mar 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The number of items is not counted correctly

8 participants