From: Aaron Date: Thu, 20 Sep 2012 00:45:39 +0000 (-0700) Subject: Worked around hash path inconsistency to unbreak stash file thumbs. X-Git-Tag: 1.31.0-rc.0~22324^2 X-Git-Url: http://git.cyclocoop.org/%22.%28%24lien.?a=commitdiff_plain;h=3bbb73468a83aa0aa014c1eed1827ce9a43aed04;p=lhc%2Fweb%2Fwiklou.git Worked around hash path inconsistency to unbreak stash file thumbs. Change-Id: I567467b75a600841440b36352d5675866d3fca2b --- diff --git a/thumb.php b/thumb.php index cba44a9114..c53eb2a5ab 100644 --- a/thumb.php +++ b/thumb.php @@ -126,7 +126,15 @@ function wfStreamThumb( array $params ) { $fileName = strtr( $fileName, '\\/', '__' ); // Actually fetch the image. Method depends on whether it is archived or not. - if ( $isOld ) { + if ( $isTemp ) { + $repo = RepoGroup::singleton()->getLocalRepo()->getTempRepo(); + $img = new UnregisteredLocalFile( null, $repo, + # Temp files are hashed based on the name without the timestamp. + # The thumbnails will be hashed based on the entire name however. + # @TODO: fix this convention to actually be reasonable. + $repo->getZonePath( 'public' ) . '/' . $repo->getTempHashPath( $fileName ) . $fileName + ); + } elseif ( $isOld ) { // Format is ! $bits = explode( '!', $fileName, 2 ); if ( count( $bits ) != 2 ) { @@ -141,20 +149,6 @@ function wfStreamThumb( array $params ) { return; } $img = RepoGroup::singleton()->getLocalRepo()->newFromArchiveName( $title, $fileName ); - } elseif ( $isTemp ) { - $repo = RepoGroup::singleton()->getLocalRepo()->getTempRepo(); - // Format is ! or just - $bits = explode( '!', $fileName, 2 ); - // Get the name without the timestamp so hash paths are correctly computed - $title = Title::makeTitleSafe( NS_FILE, isset( $bits[1] ) ? $bits[1] : $fileName ); - if ( !$title ) { - wfThumbError( 404, wfMessage( 'badtitletext' )->text() ); - wfProfileOut( __METHOD__ ); - return; - } - $img = new UnregisteredLocalFile( $title, $repo, - $repo->getZonePath( 'public' ) . '/' . $repo->getTempHashPath( $fileName ) . $fileName - ); } else { $img = wfLocalFile( $fileName ); }