Skip to content

[6.2] Fix: Empty categories displaying due to future-published items#48011

Open
hiteshm0 wants to merge 4 commits into
joomla:6.2-devfrom
hiteshm0:empty_category_list
Open

[6.2] Fix: Empty categories displaying due to future-published items#48011
hiteshm0 wants to merge 4 commits into
joomla:6.2-devfrom
hiteshm0:empty_category_list

Conversation

@hiteshm0

@hiteshm0 hiteshm0 commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Pull Request resolves #47976

  • I read the Generative AI policy and my contribution is either not created with the help of AI or is compatible with the policy and GNU/GPL 2 or later.

Summary of Changes

This PR fixes an issue where categories containing exclusively future-published items (or items with an expired publish_down date) are incorrectly counted as having active items, causing them to be improperly displayed in frontend category lists and modules

[Edit] Scope of the PR was improved to include a fix wherein the heading 'Subcategories' was displayed category blogs/list modules even if there was no valid subcategory to display.

Implementation:

  1. Added a new check_dates opt-in parameter to the core Joomla\CMS\Categories\Categories::_load() method. When enabled, the item-counting subquery strictly enforces publish_up and publish_down window conditions.
  2. Enabled $options['check_dates'] = true; in the Category service constructors for com_content, com_contact, com_banners, and com_newsfeeds, as these core components actively utilize scheduled publishing dates.

Testing Instructions

  1. Create a Parent category and its child category.
  2. Create one more articles that belong to child category but have their publishing date somewhere in the future.
  3. Create a menu item of type 'Category Blog' or 'Category List' for the Parent category.
  4. Go into the Parent Categories blog/list.

Actual result BEFORE applying this Pull Request

The category with the not yet published articles is displayed in the subcategories list
image
image

Expected result AFTER applying this Pull Request

The category with the not yet published articles is not displayed in the subcategories list and the heading subcategories is not present either.
image

Link to documentations

Please select:

  • Documentation link for guide.joomla.org:

  • No documentation changes for guide.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

@brianteeman

Copy link
Copy Markdown
Contributor

It's good that you used this in all components that use categories but it's probably not needed in banners as I don't think there is any scenario where that would happen

@hiteshm0

Copy link
Copy Markdown
Contributor Author

@brianteeman should i remove the changes made to the banner component?
although letting it be would make things more consistent with negligible performance overhead.

@brianteeman

Copy link
Copy Markdown
Contributor

Consistency is good. I just wondered if the fix could be made earlier so it doesn't have to be repeated but if not then this is fine.

@HLeithner
HLeithner changed the base branch from 6.1-dev to 6.2-dev June 24, 2026 11:13
@HLeithner HLeithner changed the title [6.1]Fix: Empty categories displaying due to future-published items [6.2]Fix: Empty categories displaying due to future-published items Jun 24, 2026
@HLeithner

Copy link
Copy Markdown
Member

Thanks for you pr, I rebased this to 6.2 since it might not be expected behaviour I think doing this change in a patch release is an unexpected output change and would like to not do such things in a patch version.

@richard67 richard67 changed the title [6.2]Fix: Empty categories displaying due to future-published items [6.2] Fix: Empty categories displaying due to future-published items Jun 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

Comment thread components/com_newsfeeds/src/Service/Category.php
Comment thread libraries/src/Categories/Categories.php
Comment thread libraries/src/Categories/Categories.php Outdated
@drmenzelit

Copy link
Copy Markdown
Contributor

This PR solves #47976 only partially. The category with an article to be published in the future doesn't appear in the list of categories (List All Categories in an Article Category Tree), but in the module "Articles - Categories" is still there.
In a category blog it doesn't show either, but the heading "Subcategories" alone looks odd.

@gioacchino54

Copy link
Copy Markdown

I have tested this item 🔴 unsuccessfully on 9de434d

I was unable to reproduce the problem.
The Patch Tester does not contain PRs J6.2


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

@hiteshm0

hiteshm0 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

@drmenzelit

In a category blog it doesn't show either, but the heading "Subcategories" alone looks odd.

and

but in the module "Articles - Categories" is still there.

are both expected behavior if im not wrong ( or rather not caused by a yet to be published article in said category)
( even if said category does not contain any articles , the category is still displayed in those places )

Should we extend the scope of this PR to fix those bugs too?

@drmenzelit

Copy link
Copy Markdown
Contributor

For me it is not expected behavior, and if we are correcting it for the list of categories, it should be corrected for the list of categories in the module too.

@hiteshm0

Copy link
Copy Markdown
Contributor Author

@drmenzelit
Included the fix to avoid displaying 'Subcategories' when there is no valid subcategory to display in category blog/list modules. Please take a look ( necessary changes have been made to the testing instructions aswell)

<?php endif; ?>

<?php if ($this->maxLevel != 0 && !empty($this->children[$this->category->id])) : ?>
<?php

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In my opinion this code doesn't belong in the view. Normally you find such code in the model or a helper. And it doesn't follow the DRY rule (you need to repeat the code in the other view too).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

you're right, i'll move that logic to a seperate function and call the same function in both places.

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.

9 participants