Last modified: 2011-10-15 22:02:51 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T32192, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 30192 - Thumbnails of archived images don't get deleted
Thumbnails of archived images don't get deleted
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
File management (Other open bugs)
1.20.x
All All
: Normal normal with 2 votes (vote)
: ---
Assigned To: Nobody - You can work on this!
: need-integration-test, patch, patch-need-review
: 30535 (view as bug list)
Depends on:
Blocks: revdel 29068 30786
  Show dependency treegraph
 
Reported: 2011-08-03 03:11 UTC by Russ Nelson
Modified: 2011-10-15 22:02 UTC (History)
8 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
Patch to purge old thumbnails from localfiles (686 bytes, patch)
2011-08-04 17:22 UTC, Mark A. Hershberger
Details
Uses twill to test filerepo functions. (6.41 KB, text/x-python)
2011-08-16 02:58 UTC, Russ Nelson
Details
Seems to fix the bug (7.90 KB, patch)
2011-08-31 04:25 UTC, Russ Nelson
Details
Whitespace issues fixed (7.96 KB, patch)
2011-09-06 19:04 UTC, Sam Reed (reedy)
Details

Description Russ Nelson 2011-08-03 03:11:10 UTC
Upload an image to a MediaWiki instance.
Replace it with a different image.
The page you get back lists both the current and archived version, and 120px thumbnails for both images.
Delete the archived version.
The original is gone, but the thumbnail remains.
I found this in r84671, but AaronSchulz was able to reproduce it in a current version.
Could this be related to b28613 ?
Comment 1 Ariel T. Glenn 2011-08-03 06:31:30 UTC
Can you reproduce this at will?  I.e. if I follow these steps does the thumbnail always stick around?
Comment 2 Russ Nelson 2011-08-03 13:17:06 UTC
Yes, and on a completely vanilla MediaWiki install. So it has nothing to do with networking and nothing to do with caching. At least this bug anyway. Can't say that about b28613.
Comment 3 Mark A. Hershberger 2011-08-03 16:47:46 UTC
Unless I'm missing something, Bug 28613 doesn't seem to be talking about removing old versions, though.
Comment 4 Saibo 2011-08-03 22:07:17 UTC
A test case: http://de.wikipedia.org/wiki/Datei:Logo_African_Pygmy_Goat.png 

uploaded a new image ("test copyvio") over this file. 

after reverting the second (copyvio) version had the thumburl: http://upload.wikimedia.org/wikipedia/de/thumb/archive/5/51/20110803213020!Logo_African_Pygmy_Goat.png/120px-Logo_African_Pygmy_Goat.png

I also accessed this thumb: http://upload.wikimedia.org/wikipedia/de/thumb/archive/5/51/20110803213020!Logo_African_Pygmy_Goat.png/126px-Logo_African_Pygmy_Goat.png

------ 
then I did revision delete (hide) the file contents of the second version: Both above mentioned thumb URLs still work. → Bug.
Thumb URLs which were not accessed while the file version was visible do not work (example:  http://upload.wikimedia.org/wikipedia/de/thumb/archive/5/51/20110803213020!Logo_African_Pygmy_Goat.png/131px-Logo_African_Pygmy_Goat.png )

Even if I delete the file completely (I did temporarily) the archive thumbs still keep working. →Bug. Only the current version's thumbs do not work.


However, in order to assess the severity of this bug:
An "attacker" needs to know how mediawiki's thumb URLs for archive versions are constructed (those parts: archive , 20110803213020!) since the thumb URL is not anymore on the file's page (also not in file page's source code). And he needs to know the timestamp (easy to find out in the log or file page's html source). And even if a nerd did construct the correct thumb URL he can only access the thumbs which were generated before deletion. Typically this is only the 120px version which is tinytinytiny.  

Conclusion: 
* Speaking of copyvios this bug is not important. 
* Speaking of hard privacy violations this bug is important - I do not know how to get rid of the old thumbs. Maybe a server admin would need to delete them manually if a important privacy violation would happen. However - this would only matter if the privacy violation is in a non-current file version.  Well, this easily happens if a vandal overwrites a file (preferably a file which is in high use) with a picture of his ex-girlfriend (or whatever). If the file is reverted then it is the non-current version. 
* All in all (due to the privacy problem) I think this is a bad bug which really should be fixed.
Comment 5 Mark A. Hershberger 2011-08-03 23:30:42 UTC
We'll try to get this fixed before the deployment of 1.18
Comment 6 Russ Nelson 2011-08-03 23:59:37 UTC
An attacker could use this to redistribute an image. Upload image A.jpg. Make a thumbnail of it one pixel smaller than the original, 1023px-A.jpg. Overwrite it with a copyright violation. Record the archived thumb name. Complain about the copyright violation and ask for it to be deleted. A.jpg gets deleted, but 1023px-A.jpg remains at its archived URL, but is not in the database.
Comment 7 Bryan Tong Minh 2011-08-04 07:25:07 UTC
LocalFile::purgeHistory() and LocalFile::purgeCache() should call purgeThumbnails() on $this->getHistory().
Comment 8 Mark A. Hershberger 2011-08-04 17:22:20 UTC
Created attachment 8885 [details]
Patch to purge old thumbnails from localfiles

Like this?
Comment 10 Mark A. Hershberger 2011-08-05 12:04:14 UTC
Yes, my question was just asking if such a patch would be what Bryan
was talking about.  I haven't even committed it, yet.
Comment 11 Russ Nelson 2011-08-05 23:42:27 UTC
The patch seems to be what Bryan was suggesting.
Comment 12 Chad H. 2011-08-10 23:29:44 UTC
Resolved in r94212. No need to duplicate the purging in purgeCache(), you end up calling purgeHistory() anyway :)
Comment 13 Russ Nelson 2011-08-16 02:58:56 UTC
Created attachment 8920 [details]
Uses twill to test filerepo functions.
Comment 14 Russ Nelson 2011-08-16 03:01:37 UTC
Hrm. Doesn't pass my mediawiki automated filerepo test (uploaded. Run it on a
wiki (modify the URL in the source) with your username and password on the
command line. Yes, yes, I know, but these are test wikis with a junk password.)

http://www.ra-tes.org/phase3/images/c/c6/Test-1313461285.08.png

http://www.ra-tes.org/phase3/images/thumb/c/c6/Test-1313461285.08.png/120px-Test-1313461285.08.png

http://www.ra-tes.org/phase3/images/archive/c/c6/20110816021516%21Test-1313461285.08.png

http://www.ra-tes.org/phase3/images/thumb/archive/c/c6/20110816021516%21Test-1313461285.08.png/120px-Test-1313461285.08.png

The first three 404, but the last one still works.
Comment 15 Mark A. Hershberger 2011-08-25 16:19:50 UTC
*** Bug 30535 has been marked as a duplicate of this bug. ***
Comment 16 Russ Nelson 2011-08-25 19:52:16 UTC
I've got my head down in this code anyway because of SwiftMedia. I'll see if I can find it. It's kinda in my way anyway.
Comment 17 Russ Nelson 2011-08-25 22:05:51 UTC
Ouch. You don't even have to delete the entire file. All you need to do is delete an archived version; the thumbnail isn't deleted.
Comment 18 Russ Nelson 2011-08-27 01:02:06 UTC
@Chad H noted in an email on wikitech that these files need better function names and comments. He's right. Also, as a cleanup goal, I think functions only used in the one file should be marked private, and the API functions explicitly marked public.
Comment 19 Russ Nelson 2011-08-27 01:19:01 UTC
There's two cases where thumbs should be deleted:
 1) when a new version of the file is uploaded (to get rid of thumbs that belong to an archived version of the file), and
2) when a:
2a) current or 
2b) archived version of a file is deleted.
Part (2b) has no code to implement it right now. It's not that it's being done incorrectly; it's not even being attempted.

I think the most appropriate locus for deleting stale thumbs is to delete them when a file is deleted. The other code which deletes current thumbs covers other cases and is still necessary.
Comment 20 Chad H. 2011-08-27 14:24:00 UTC
(In reply to comment #18)
> I think functions only
> used in the one file should be marked private, and the API functions explicitly
> marked public.
>

+1. I was thinking that too when I was looking at this earlier in the week.
Comment 21 Russ Nelson 2011-08-30 01:38:48 UTC
There's also a mix of functions dedicated to *Archive* access, and OldLocalFile, which derives from LocalFile with functions that already know that they're accessing Archived files. A cleanup would eliminate the *Archive* functions ... but that also means creating a File any time you want to do anything to a file. And means calling RepoGroup::singleton()->getLocalRepo()->newFile($title); (with an additional time parameter if it's an archive file. And that means parsing the file at the ! to get the time to pass to newFile ... the complexity keeps piling up, all to simplify? I'm not so sure, but I also don't like the lack of regularity and lack of information hiding.
Comment 22 Russ Nelson 2011-08-31 04:25:02 UTC
Created attachment 8992 [details]
Seems to fix the bug

This patch fixes the bug, and adds some useful helper functions to filerepo/File. It also recognizes that sometimes "$suffix" is really "$archiveName" and isn't in fact optional.

I'm uploading it here rather than fixing it directly because I haven't tested it on the trunk wiki code yet. It works on both SwiftMedia (once I check in my patches), and an older slightly pre-1.17 on which I discovered the bug.
Comment 23 Sam Reed (reedy) 2011-09-06 19:04:16 UTC
Created attachment 9021 [details]
Whitespace issues fixed

Patch looks alright, and seems to fix the deletion of archived thumbnail images

It does however, leave the "20110411224401!Blah.png" folder, which IMHO, if we're deleting the files, hence making the directory empty, we should then delete the directory
Comment 24 Chad H. 2011-09-06 21:02:56 UTC
Patch applied with minor tweaks in r97373.
Comment 25 Russ Nelson 2011-09-07 02:32:07 UTC
Make that r96373.

Oh, and Roan noticed that I'd changed the API to getArchive{Url|Path}. I changed it back in r96399
Comment 26 Roan Kattouw 2011-09-07 08:18:32 UTC
(In reply to comment #25)
> Make that r96373.
> 
> Oh, and Roan noticed that I'd changed the API to getArchive{Url|Path}. I
> changed it back in r96399
Credit where credit is due: our automated test runner (CruiseControl) noticed this :)
Comment 27 Mark A. Hershberger 2011-10-15 22:02:51 UTC
tagging bugs for Marcus to look at

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links