r105208 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105207‎ | r105208 | r105209 >
Date:19:17, 5 December 2011
Author:aaron
Status:reverted (Comments)
Tags:
Comment:
FU r104216: keep the r103738 regex check for thumbnails but use the parent directory as the source file name. This avoids the assumption that the thumb URL starts with /thumb.
Modified paths:
  • /trunk/phase3/img_auth.php (modified) (history)

Diff [purge]

Index: trunk/phase3/img_auth.php
@@ -94,12 +94,12 @@
9595 return;
9696 }
9797
98 - // Extract the file name and chop off the size specifier.
 98+ // Extract the file name and chop off the size specifier
9999 // (e.g. 120px-Foo.png => Foo.png or page2-120px-Foo.png => Foo.png).
100 - // This only applies to thumbnails, and all thumbnails should
101 - // be under a folder that has the source file name.
 100+ // This only applies to thumbnails, and all thumbnails should have
 101+ // a width indicator and be under a folder that has the source file name.
102102 $name = wfBaseName( $path );
103 - if ( strpos( $path, '/thumb/' ) === 0 ) {
 103+ if ( preg_match( '!(?:[^-]*-)*?\d+px-(.*)!i', $name ) ) {
104104 $name = wfBaseName( dirname( $path ) ); // this file is a thumbnail
105105 }
106106

Follow-up revisions

RevisionCommit summaryAuthorDate
r105330Reverted r105208 per CRaaron18:48, 6 December 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r103738image_auth.php cleanups:...aaron08:50, 20 November 2011
r104216FU r103738: redid the method of getting the source file name for thumbnails a...aaron02:21, 25 November 2011

Comments

#Comment by Brion VIBBER (talk | contribs)   18:41, 6 December 2011

This will trigger thumb mode on filenames in the form "500px-Nuvola_apps_package_graphics.png" (warned against but not forbidden by upload code) or "Full-500px-Nuvola_apps_package_graphics.png" (not prevented at all); you'd then end up with $name set to something like 'f9' from the hash dirs...

#Comment by Aaron Schulz (talk | contribs)   18:44, 6 December 2011

I thought the former was banned. I guess I'll just remove the page\d- check and the hell with ProofreadPage.

#Comment by Aaron Schulz (talk | contribs)   18:45, 6 December 2011

Gah, that would still only work if \dpx- was banned, which it isn't. So we are back to the /thumb assumption.

#Comment by Brion VIBBER (talk | contribs)   18:52, 6 December 2011

I'm pretty sure 'thumb' is hardcoded within the directory structure. Shouldn't we just use that, knowing what the path will be?

... hmm, potentially at least thumbDir/thumbUrl can be overridden in $wgLocalFileRepo, but if so we'll have that information available right?

#Comment by Aaron Schulz (talk | contribs)   19:00, 6 December 2011

Yes, you can try to use that config and strip the hostname and such off.

$repo = RepoGroup::singleton()->getLocalRepo() $bits = wfParseUrl( $repo->getZonePath( 'thumb' ) );

...do something with $bits['path']

#Comment by Aaron Schulz (talk | contribs)   19:02, 6 December 2011

That should be getZoneUrl() not getZonePath() of course.

Status & tagging log