Skip to content

Comments

[5.4] Add publishing checks to banner item retrieval#46881

Open
nielsnuebel wants to merge 9 commits intojoomla:5.4-devfrom
nielsnuebel:nielsnuebel-patch-46880
Open

[5.4] Add publishing checks to banner item retrieval#46881
nielsnuebel wants to merge 9 commits intojoomla:5.4-devfrom
nielsnuebel:nielsnuebel-patch-46880

Conversation

@nielsnuebel
Copy link
Contributor

@nielsnuebel nielsnuebel commented Feb 12, 2026

Pull Request resolves #46880

Summary of Changes

This PR enhances the getItem method in com_banners to include state and publishing date validation. By adding these conditions to the database query, we ensure that banner data (including the click URL) is only retrieved if the banner is currently active.

Technical Changes:

Added $nowDate using Factory::getDate()->toSql() for precise timing.

Extended the WHERE clause to check for state = 1.

Added logic to respect publish_up and publish_down fields (including NULL checks).

Testing Instructions

  1. Identify a banner ID that is currently unpublished or expired.
  2. Attempt to trigger a click via the standard routing: index.php?option=com_banners&task=click&id=[ID].
  3. Before PR: The system still retrieves the banner object and increments the click counter.
  4. After PR: The getItem method returns no result for inactive banners, effectively preventing the click-tracking task from executing.
  5. Verify that published banners within their date range continue to track clicks correctly.

Actual result BEFORE applying this Pull Request

The getItem method retrieves banner details regardless of the publication status, allowing the click-tracking logic to increment counters for inactive ads. This results in "ghost clicks" visible in reporting tools like Looker Studio, where clicks are recorded despite 0 impressions.

Expected result AFTER applying this Pull Request

Banner data is only returned if the banner is published and within the valid date range. Inactive banners will no longer have their clicks tracked.

Link to documentations

  • No documentation changes for guide.joomla.org needed
  • No documentation changes for manual.joomla.org needed

### Description
This PR addresses the issue where clicks are incorrectly counted for banners that are unpublished or outside their publishing date range. 

As discussed in joomla#46880, the `BannerModel::click()` method previously performed an unconditional update on the clicks counter. This led to "ghost clicks" from bots or cached links on inactive banners.

### Changes
Modified `components/com_banners/src/Model/BannerModel.php`:
- Added a check for `state = 1` in the update query.
- Added checks for `publish_up` and `publish_down` to ensure the click falls within the valid timeframe.

### Testing Instructions
1. Create a banner and note its ID.
2. Unpublish the banner.
3. Manually trigger a click via URL: `index.php?option=com_banners&task=click&id=[YOUR_ID]`.
4. Observe that the `clicks` count in the database no longer increments.
5. Publish the banner again and verify that clicks are counted correctly.

Fixes joomla#46880
Removed unnecessary extendWhere conditions for banner query.
@tecpromotion tecpromotion changed the title Add publishing checks to banner item retrieval #46880 [5.4] Add publishing checks to banner item retrieval Feb 12, 2026
@chmst
Copy link
Contributor

chmst commented Feb 13, 2026

How can inactive banners get cklicks?

@brianteeman
Copy link
Contributor

How can inactive banners get cklicks?

from a page cache?

@nielsnuebel
Copy link
Contributor Author

How can inactive banners get cklicks?

The primary issue is automated traffic from bots or crawlers (like Google or specialized bots) that still have old click-URLs in their index. Here is an example from my server logs:

13/Feb/2026:00:12:03 +0100] "GET /component/banners/click/288 HTTP/1.1" 404 5527 "-" "Mozilla/5.0 (compatible; FleebsBot/1~w; +https://fleebs.com/bot)" www.domain.tld

Why this fix is necessary:

Data Integrity: Currently, Joomla counts these as valid clicks if the ID exists, even if the banner is unpublished or expired. This leads to "ghost clicks" that skew reporting data.

Correct Response: With my fix, the system correctly validates the state and publishing dates within the getItem method. As seen in the log, the server now appropriately returns a 404 instead of processing an invalid interaction.

Returning a 404 is the correct technical response for a resource that is no longer "active" for the public, ensuring clean statistics and better resource management.

@tecpromotion
Copy link
Contributor

Bug confirmed: The change fixes incorrect behavior where inactive banners were still processed (e.g., click tracking continued even when a banner was unpublished or expired).

Copy link
Member

@HLeithner HLeithner left a comment

Choose a reason for hiding this comment

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

You don't need to provide the same parameter twice.

nielsnuebel and others added 5 commits February 13, 2026 13:31
Co-authored-by: Harald Leithner <leithner@itronic.at>
Co-authored-by: Harald Leithner <leithner@itronic.at>
Co-authored-by: Harald Leithner <leithner@itronic.at>
Copy link
Contributor

@tecpromotion tecpromotion left a comment

Choose a reason for hiding this comment

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

Co-authored-by: Stefan Wendhausen <stefan.wendhausen@tec-promotion.de>
@ThomasFinnern
Copy link
Contributor

I have tested this item ✅ successfully on 0fd57ff


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

@beni71
Copy link
Contributor

beni71 commented Feb 19, 2026

I have tested this item ✅ successfully on 0fd57ff


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

@richard67
Copy link
Member

RTC


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

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Feb 20, 2026
@richard67 richard67 added this to the Joomla! 5.4.4 milestone Feb 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug PR-5.4-dev RTC This Pull Request is Ready To Commit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prevent click counting for inactive banners in com_banners

10 participants