[5.4] Add publishing checks to banner item retrieval#46881
[5.4] Add publishing checks to banner item retrieval#46881nielsnuebel wants to merge 9 commits intojoomla:5.4-devfrom
Conversation
### 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.
|
How can inactive banners get cklicks? |
from a page cache? |
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:
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. |
|
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). |
HLeithner
left a comment
There was a problem hiding this comment.
You don't need to provide the same parameter twice.
Co-authored-by: Harald Leithner <leithner@itronic.at>
Co-authored-by: Harald Leithner <leithner@itronic.at>
Co-authored-by: Harald Leithner <leithner@itronic.at>
Co-authored-by: Stefan Wendhausen <stefan.wendhausen@tec-promotion.de>
|
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. |
Requested changes have been implemented.
|
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. |
|
RTC This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/46881. |
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
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