r108937 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r108936‎ | r108937 | r108938 >
Date:19:17, 14 January 2012
Author:aaron
Status:ok
Tags:core 
Comment:
r105512: Handle REDIRECT_URL discrepancies and always work with URI paths for thumb 404 handling
Modified paths:
  • /trunk/phase3/thumb.php (modified) (history)

Diff [purge]

Index: trunk/phase3/thumb.php
@@ -46,12 +46,18 @@
4747 * @return void
4848 */
4949 function wfThumbHandle404() {
50 - # lighttpd puts the original request in REQUEST_URI, while
51 - # sjs sets that to the 404 handler, and puts the original
52 - # request in REDIRECT_URL.
 50+ # lighttpd puts the original request in REQUEST_URI, while sjs sets
 51+ # that to the 404 handler, and puts the original request in REDIRECT_URL.
5352 if ( isset( $_SERVER['REDIRECT_URL'] ) ) {
54 - # The URL is un-encoded, so put it back how it was.
 53+ # The URL is un-encoded, so put it back how it was
5554 $uri = str_replace( "%2F", "/", urlencode( $_SERVER['REDIRECT_URL'] ) );
 55+ # Just get the URI path (REDIRECT_URL is either a full URL or a path)
 56+ if ( $uri[0] !== '/' ) {
 57+ $bits = wfParseUrl( $uri );
 58+ if ( $bits && isset( $bits['path'] ) ) {
 59+ $uri = $bits['path'];
 60+ }
 61+ }
5662 } else {
5763 $uri = $_SERVER['REQUEST_URI'];
5864 }
@@ -215,18 +221,23 @@
216222 * Extract the required params for thumb.php from the thumbnail request URI.
217223 * At least 'width' and 'f' should be set if the result is an array.
218224 *
219 - * @param $uri String Thumbnail request URI
 225+ * @param $uri String Thumbnail request URI path
220226 * @return Array|null associative params array or null
221227 */
222228 function wfExtractThumbParams( $uri ) {
223229 $repo = RepoGroup::singleton()->getLocalRepo();
224230
 231+ $bits = wfParseUrl( $repo->getZoneUrl( 'thumb' ) );
 232+ if ( !$bits ) {
 233+ return null;
 234+ }
 235+ $zoneUrlRegex = preg_quote( $bits['path'] );
 236+
225237 $hashDirRegex = $subdirRegex = '';
226238 for ( $i = 0; $i < $repo->getHashLevels(); $i++ ) {
227239 $subdirRegex .= '[0-9a-f]';
228240 $hashDirRegex .= "$subdirRegex/";
229241 }
230 - $zoneUrlRegex = preg_quote( $repo->getZoneUrl( 'thumb' ) );
231242
232243 $thumbUrlRegex = "!^$zoneUrlRegex(/archive|/temp|)/$hashDirRegex([^/]*)/([^/]*)$!";
233244

Follow-up revisions

RevisionCommit summaryAuthorDate
r109643Similar to r108937: fixed breakage where the zone urls were defined as relati...aaron20:52, 20 January 2012

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r105512FU r101117: removed cURL thumb handler code and made thumb_handler.php a thin...aaron03:43, 8 December 2011

Status & tagging log