r77256 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r77255‎ | r77256 | r77257 >
Date:22:10, 24 November 2010
Author:catrope
Status:deferred
Tags:
Comment:
Support temp/thumb in thumb-handler.php . This is part of a deeply evil hack to make thumbnailing of stashed files work on the WMF cluster
Modified paths:
  • /trunk/tools/upload-scripts/thumb-handler.php (modified) (history)

Diff [purge]

Index: trunk/tools/upload-scripts/thumb-handler.php
@@ -11,10 +11,10 @@
1212 }
1313
1414 # Is this a thumbnail?
15 -if ( preg_match('!^(?:http://upload.wikimedia.org)?/+([\w-]*)/([\w-]*)/thumb(/archive|)/\w/\w\w/([^/]*)/' .
 15+if ( preg_match('!^(?:http://upload.wikimedia.org)?/+([\w-]*)/([\w-]*)/thumb(/archive|/temp|)/\w/\w\w/([^/]*)/' .
1616 '(page(\d*)-)*(\d*)px-([^/]*)$!', $uri, $matches ) )
1717 {
18 - list( $all, $site, $lang, $arch, $filename, $pagefull, $pagenum, $size, $fn2 ) = $matches;
 18+ list( $all, $site, $lang, $archOrTemp, $filename, $pagefull, $pagenum, $size, $fn2 ) = $matches;
1919 $params = array(
2020 'f' => $filename,
2121 'width' => $size
@@ -22,8 +22,10 @@
2323 if ( $pagenum ) {
2424 $params['page'] = $pagenum;
2525 }
26 - if ( $arch ) {
 26+ if ( $archOrTemp == '/archive' ) {
2727 $params['archived'] = 1;
 28+ } else if ( $archOrTemp == '/temp' ) {
 29+ $params['temp'] = 1;
2830 }
2931 } elseif ( preg_match('!^(?:http://upload.wikimedia.org)?/+([\w-]*)/([\w-]*)/thumb(/archive|)/' .
3032 '\w/\w\w/([^/]*\.(?:(?i)ogg|ogv|oga))/' .
@@ -239,10 +241,10 @@
240242 curl_close( $ch );
241243
242244 function pathFromUrl( $url ) {
243 - if( preg_match( '!^(?:http://upload.wikimedia.org)?/+([\w-]*)/([\w-]*)/thumb(/archive|)/(\w)/(\w\w)/([^/]*)/([^/]*)$!',
 245+ if( preg_match( '!^(?:http://upload.wikimedia.org)?/+([\w-]*)/([\w-]*)/thumb(/archive|/temp|)/(\w)/(\w\w)/([^/]*)/([^/]*)$!',
244246 $url, $matches ) ) {
245247 $parts = array_map( 'rawurldecode', $matches );
246 - list( $all, $site, $lang, $arch, $hash1, $hash2, $filename, $fn2 ) = $parts;
 248+ list( $all, $site, $lang, $archOrTemp, $hash1, $hash2, $filename, $fn2 ) = $parts;
247249
248250 $md5 = md5( $filename );
249251 if( $hash1 != substr( $md5, 0, 1 ) ) return false;
@@ -258,7 +260,7 @@
259261 }
260262
261263 if( $good ) {
262 - $thumbPath = array( '', 'export', 'upload', $site, $lang, 'thumb', $arch, $hash1, $hash2, $filename, $fn2 );
 264+ $thumbPath = array( '', 'export', 'upload', $site, $lang, 'thumb', $archOrTemp, $hash1, $hash2, $filename, $fn2 );
263265 if ( !checkPathComponents( $thumbPath ) ) return false;
264266 return implode( '/', $thumbPath );
265267 }

Status & tagging log