• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Fixed Deleting media not properly updating the counter?

imthebest

Well-known member
#1
Hi,

I had an album with 2 media. I removed the media and then the album or maybe I removed the entire album including the media, I don't remember. The thing is that right now I have 0 albums and 0 media however on my profile I see this: Albums: 0 / Media: 1.

If I enable myself to see deleted albums/media I can see that in fact the album and the 2 media are deleted.

On the Gallery Statistics block I see:

Albums: 0
Media: 1
Disk Usage: 45.3KB

Maybe this is related to this? I don't know.

Thanks,
Super120
 

Chris D

XenForo developer
Staff member
#2
Technically speaking, although you may (soft) delete an album containing media, the media itself isn't deleted. It becomes in accessible unless you have various permissions, but its state, in the database at least, is 'visible'.

We don't change the media counts downwards unless the state changes to deleted or moderated (from visible) or unless the media is hard deleted.

If an album is hard deleted then the media is hard deleted in which case that would affect the various counts.

My guess from what you've mentioned above is that you deleted one media, left the other visible, then deleted the album.

That would potentially leave the statistics and counts reading Albums 0, Media 1.
 

imthebest

Well-known member
#5
Okay technically speaking it might be fine for you and me because we understand what is going, however for newbies on my forum who created an album and then uploaded 3 media inside and then deleted the entire album, they will soon or later reach me to report that issue as a bug. Other more paranoid people will blame me and might claim that my forum keeps deleted media and is against privacy...

So I think that when soft deleting an album you should also soft delete its contents, this way the media counter will always get updated.

What happens when you have a thread with 3 replies and then you soft delete the thread? If I'm not mistaken, the replies aren't soft deleted just the thread itself however the post counter of those affected people gets properly updated (again, if I'm not mistaken).
 

Chris D

XenForo developer
Staff member
#6
I do understand your point but there are so many things that can skew the counts as it is. Private albums and media inside private albums are counted (just as they can be inside private nodes).

Deletion is a little bit more clear cut, I guess as technically they aren't viewable by most at that point, but I still don't particularly see it as wrong.

I'll give it some more thought, though.
 

imthebest

Well-known member
#7
Well since you're going to review this, I'll spot another thing related to album/media counters.

For example when you visit the profile of a member, the system says "Albums: 3" however when you click on the number in order to see the albums you end seeing nothing because those albums are restricted to followers only or specific members.

While technically speaking this might be correct, it results very confusing for newbies who might end up reporting that as a bug.
 

Chris D

XenForo developer
Staff member
#8
The good news about newbies is, they don't stay newbies for very long. And, as much as I agree that if you were paying attention, it could look confusing, you have to understand a lot of these behaviours aren't exclusive to XFMG.

To directly compare your most recent example to a behaviour in XenForo:

Imagine a newbie coming to a site where there is a forum, just like we have here (Off Topic and Test Messages) where posts are not counted. They will make posts and their post counts won't increase. Potentially confusing. Conversely, imagine having a private forum, a user has posted 4 messages, 3 of which in a private forum. Their post count increases, but when you search for the content, it's not there. Note my message count is 4, but only 1 result is returned.

upload_2015-4-15_19-44-19.png

Chances are we resolve the initial concern, simply because there's never a situation where we count content that is practically deleted.

However, adjusting counts for all the permutations of privacy settings is just not going to be possible or even any more accurate by counting them.
 

Chris D

XenForo developer
Staff member
#9
We've implemented some changes surrounding the counting of visible media in invisible albums.

An album is deleted, we adjust each member's media count for each visible media item in the album. If it is undeleted, we do the reverse.

Likewise, Gallery statistics and user rebuilds will now only count media in the same way (visible and in a visible album).
 

imthebest

Well-known member
#10
So the problem exposed on my post #1 will get automatically resolved after upgrading to the next version or will it require a rebuild?
 

imthebest

Well-known member
#14
Just to be safe, it isn't going to be needed to also run "Rebuild XenForo Media Gallery User Media Quota"? Remember that on the "Your Statistics" block at /media I see:

Albums: 0
Media: 1
Disk Usage: 45.3KB
If media is goint to be 0, isn't "Disk Usage" also going to be 0?
 

imthebest

Well-known member
#16
He Chris,

If for this bug you're now rebuilding the required stuff as part of the upgrade process for 1.0.5 (excellent decision) don't you think that it might be a good idea to also rebuild media counts and user quota (when needed) during the upgrade, too?

Imho, you should do your best effort to make sure that every bug fixed also works retroactively and if it requires a rebuild then you should do it during the upgrade or at least let your customers know (in the announcement/release notes) that they need to run rebuilds manually (already suggested).

Thanks,
Super120
 

Chris D

XenForo developer
Staff member
#17
Slightly different ball game.

The retroactive fix there is relatively small, and simple, and won't take very long.

You're proposing that we trigger an automatic rebuild of all user counts and quotas for an issue that some may not even care about or may not even affect some.

On a big board, going through tens/hundreds of thousands of users will take a long time - it seems only right that the admin should make the decision to do that if they wish to, or not if they don't wish to.
 

imthebest

Well-known member
#18
(...) it seems only right that the admin should make the decision to do that if they wish to, or not if they don't wish to.
Okay in this case please mention on the announcement/release notes that a rebuild is needed. I already know and will do that after upgrading to 1.0.5 but I think other admins might not have the time to review each bug thread so better to let them know.

For example when I upgraded from 1.0.2 to 1.0.3 I wasn't aware that a rebuild was needed (in fact you don't even mentioned it in the bug thread). That leads to confusion.

Sorry for keep bothering you but I just want to help you to make XFMG a better product for everyone :)
 

imthebest

Well-known member
#19
On the Gallery Statistics block I see:

Albums: 0
Media: 1
Disk Usage: 45.3KB
I updated to XFMG 1.0.5 and ran the following rebuilders:

Rebuild XenForo Media Gallery User Album Counts (this one was ran by error)
Rebuild XenForo Media Gallery Album Media Count
Rebuild XenForo Media Gallery User Media Quota

And now I have the following:

Albums: 0
Media: 1
Disk Usage: 0 bytes
I even tried manually running the cron entries "Update XenForo Media Gallery Statistics" and "XenForo Media Gallery Clean Ups" however I'm still getting "Media: 1" when in fact I have no media.

The facts:
  • I have one soft-deleted album with 2 pictures.
  • Picture 1 says "Media is part of an album which has been removed from public view".
  • Picture 2 says "Media is part of an album which has been removed from public view" and "Media has been removed from public view".
So it could be any of these:
  • You didn't properly fix this bug.
  • Your rebuilder "Rebuild XenForo Media Gallery Album Media Count" isn't working.
Please check.
 

Chris D

XenForo developer
Staff member
#20
So it could be any of these:
  • You didn't properly fix this bug.
  • Your rebuilder "Rebuild XenForo Media Gallery Album Media Count" isn't working.
Please check.
There are potentially more options than that. As I said earlier, make sure you've run the correct rebuilds; specifically as this is the Gallery Statistics block, then make sure the Cron entry has run.

If there's still something left over, I cannot reproduce the issue with the scenario you mentioned here:

The facts:
  • I have one soft-deleted album with 2 pictures.
  • Picture 1 says "Media is part of an album which has been removed from public view".
  • Picture 2 says "Media is part of an album which has been removed from public view" and "Media has been removed from public view".
Therefore, we need to explore some other possibilities but if you can check those basics first we'll go from there.