From: Tim Starling Date: Fri, 27 Apr 2007 09:17:05 +0000 (+0000) Subject: Restored previous interface for thumbUrl(), for backwards compatibility. Fixed squid... X-Git-Tag: 1.31.0-rc.0~53206 X-Git-Url: http://git.cyclocoop.org/fichier?a=commitdiff_plain;h=f6509ff750e8d8e98a5f8814fb65caed330e5f70;p=lhc%2Fweb%2Fwiklou.git Restored previous interface for thumbUrl(), for backwards compatibility. Fixed squid purging of thumbnails in Image::purgeCache(), broken since r21411. --- diff --git a/includes/Image.php b/includes/Image.php index 89f6871d75..88b49d5311 100644 --- a/includes/Image.php +++ b/includes/Image.php @@ -764,7 +764,7 @@ class Image * @todo document * @private */ - function thumbUrl( $thumbName ) { + function thumbUrlFromName( $thumbName, $subdir = 'thumb' ) { global $wgUploadPath, $wgUploadBaseUrl, $wgSharedUploadPath; if($this->fromSharedDirectory) { $base = ''; @@ -774,15 +774,27 @@ class Image $path = $wgUploadPath; } if ( Image::isHashed( $this->fromSharedDirectory ) ) { - $subdir = wfGetHashPath($this->name, $this->fromSharedDirectory) . + $hashdir = wfGetHashPath($this->name, $this->fromSharedDirectory) . wfUrlencode( $this->name ); } else { - $subdir = ''; + $hashdir = ''; } - $url = "{$base}{$path}/thumb{$subdir}/" . wfUrlencode( $thumbName ); + $url = "{$base}{$path}/{$subdir}{$hashdir}/" . wfUrlencode( $thumbName ); return $url; } + /** + * @deprecated Use $image->transform()->getUrl() or thumbUrlFromName() + */ + function thumbUrl( $width, $subdir = 'thumb' ) { + $name = $this->thumbName( array( 'width' => $width ) ); + if ( strval( $name ) !== '' ) { + return $this->thumbUrlFromName( $name, $subdir ); + } else { + return false; + } + } + function getTransformScript() { global $wgSharedThumbnailScriptPath, $wgThumbnailScriptPath; if ( $this->fromSharedDirectory ) { @@ -915,7 +927,7 @@ class Image list( $thumbExt, $thumbMime ) = self::getThumbType( $this->extension, $this->mime ); $thumbName = $this->thumbName( $normalisedParams ); $thumbPath = wfImageThumbDir( $this->name, $this->fromSharedDirectory ) . "/$thumbName"; - $thumbUrl = $this->thumbUrl( $thumbName ); + $thumbUrl = $this->thumbUrlFromName( $thumbName ); $this->migrateThumbFile( $thumbName ); @@ -1063,8 +1075,8 @@ class Image $urls = array(); foreach ( $files as $file ) { $m = array(); - if ( preg_match( '/^(\d+)px/', $file, $m ) ) { - $url = $this->thumbUrl( $m[1] ); + if ( preg_match( '/^\d+px/', $file, $m ) ) { + $url = $this->thumbUrlFromName( $file ); $urls[] = $url; @unlink( "$dir/$file" ); }