joomla / joomla-cms

Home of the Joomla! Content Management System
https://www.joomla.org
GNU General Public License v2.0
4.73k stars 3.64k forks source link

Unable to delete old statistics of Banner component in Joomla control panel #42700

Closed cmirnow closed 7 months ago

cmirnow commented 8 months ago

This problem is actual to Joomla 3, Joomla 4, and now Joomla 5. If I click the "Delete All" button on the "Banners -> Statistics" tab - I get the notification "2117 records were successfully deleted", but the records (banner usage statistics for 2014) are not deleted.

Steps to reproduce the issue

How to reproduce? Probably need to go back to Joomla 1.5, upgrade to J2.5 using JUpgrade, then step by step come to Joomla 5. I don't know, really...

Expected result

Deleting all statistics records.

Actual result

Statistics are not deleted.

System information (as much as possible)

J3, J4, J5.

Additional comments

I don't know if it's possible to reproduce this again. But I am ready to give full access to the J5 test site affective by this problem to any Joomla maintainer or developer.

Perhaps you can tell me the correct db query syntax if deleting old stats records is not possible from the Joomla web administration panel?

banners1

banner2

chmst commented 8 months ago

@cmirnow could you please test https://github.com/joomla/joomla-cms/pull/42722?

It does not resolve the problem that tracks are not deleted. This happens when no banners are found for existing tracks.

Would be nice to get some opinions here:

Should the system automatically delete all tracks which are not connected to any banners? I think this is ok, because these tracks are useless and would remain forever in the system. Or is it better to have an additional button like "clear tracks"?

cmirnow commented 7 months ago

Hi @chmst . I don't think new buttons are needed. I would like the banner management interface to work. That's enough. But I don't use statistics when displaying banners on my blog. Perhaps someone has a second opinion.

I will tell you what is critical for me. Recently, when publishing banners (images), I was forced to add to the css of the template:

.bannergroup {
    text-align: center;
}

It's not user friendly. Why not add to the component the ability to control the styles of banners or a group of banners? That would really be useful.

chmst commented 7 months ago

Thanks for feedback. Your request for styling banners is not in scope of ths issue / PR. You can open a new issue for that.

joomdonation commented 7 months ago

From your screenshot, I believe the reasons of the error is because these track records belong to delete banners. You can run the following SQL commands to your database to get these records deleted (replace jos_ with database table prefix uses on your site):

  1. If you want to delete all track records
TRUNCATE TABLE jos_banner_tracks;
  1. If you just delete those orphan records, run:
DELETE FROM jos_banner_tracks WHERE banner_id NOT IN (SELECT id FROM jos_banners);

After that, the delete tracks feature will work well on your site again.

As the solution is provided above, I'm closing this issue. We can discuss that delete banner should delete it's track record as well, but that's another discussion. Feel free to re-open the issue if you still have more things to discuss.