The click should not be counted because the banner is inactive. The click() method in the model should verify if the banner is currently published and within its publishing date range before incrementing the counter.
The clicks counter is incremented regardless of the banner's state or publishing dates. The current implementation of BannerModel::getItem() performs an unconditional update:
$query->select( [ $db->quoteName('a.clickurl'), $db->quoteName('a.cid'), $db->quoteName('a.track_clicks'), $db->quoteName('cl.track_clicks', 'client_track_clicks'), ] ) ->from($db->quoteName('#__banners', 'a')) ->join('LEFT', $db->quoteName('#__banner_clients', 'cl'), $db->quoteName('cl.id') . ' = ' . $db->quoteName('a.cid')) ->where($db->quoteName('a.id') . ' = :id') //state, publish_up, publish_down CHECK MISSING ->bind(':id', $id, ParameterType::INTEGER); // ... missing state and date checks
Joomla! Version: 5.x (and likely 6.x)
Component: com_banners
Affected File: components/com_banners/src/Model/BannerModel.php
The display of banners (Impressions) correctly respects the state, publish_up, and publish_down fields. However, the click-tracking task is decoupled from these checks.
I am willing to provide a Pull Request that adds a .where($db->quoteName('state') . ' = 1') and potentially date checks to the update query to ensure data integrity in banner statistics.
| Labels |
Added:
No Code Attached Yet
|
||