User tests: Successful: Unsuccessful:
Pull Request resolves #46751.
Fixes incorrect article counts in the Tags – Popular module when a content item is assigned multiple tags.
The module previously used COUNT(*), which resulted in inflated counts due to row multiplication in the many-to-many join between #__contentitem_tag_map and #__ucm_content.
This change replaces:
COUNT(*)
with:
COUNT(DISTINCT m.core_content_id)
to ensure unique content items are counted per tag.
Tag1 → 4
Tag2 → 2
Counts are inflated when an article has multiple tags.
Tag1 → 3
Tag2 → 1
Each tag correctly reflects the number of unique associated content items.
| Status | New | ⇒ | Pending |
| Category | ⇒ | Modules Front End |
Hi @richard67,
I have verified the change on PostgreSQL 16 locally in addition to MySQL/MariaDB.
To confirm the behavior, I reproduced a duplicate row scenario at the database level by simulating multiple mappings for the same core_content_id. As expected:
COUNT(*) resulted in inflated counts when duplicate mappings were present.
COUNT(DISTINCT core_content_id) correctly returned the number of unique content items per tag.
PostgreSQL fully supports COUNT(DISTINCT ...) under ANSI SQL semantics, and the behavior matches MySQL/MariaDB in this context.
The fix therefore works correctly across both supported database engines.
I have tested this item ✅ successfully on 6b3d62e
postgresql 15.15
| Title |
|
||||||
I have tested this item ✅ successfully on 6b3d62e
| Status | Pending | ⇒ | Ready to Commit |
| Labels |
Added:
bug
PR-5.4-dev
|
||
RTC
| Labels |
Added:
RTC
|
||
✅ Final test before merge using JBT
| Status | Ready to Commit | ⇒ | Fixed in Code Base |
| Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2026-03-05 08:00:33 |
| Closed_By | ⇒ | muhme |
Thank you @adarshdubey03 for your first time contribution. Thanky you @alikon and @brianteeman for testing.
Thank you for the review and merge!
I appreciate the testing and feedback from everyone involved.
Happy to contribute and looking forward to helping with more fixes and improvements.
@adarshdubey03 Have you verified that this works not only for MySQL (or MariaDB) but also for PostgreSQL?