X-Git-Url: https://git.cyclocoop.org/?a=blobdiff_plain;ds=sidebyside;f=thumb.php;h=068ec01700d4f1cf4528dca2efe2b293c9d10ec5;hb=658eb79dc10fbbceec1a6bee3ab078aca06c424e;hp=cba44a911400cfbe03f454ffe7929eaead3a9432;hpb=e0b918052576bf7ba42071306a7a1954c8d3c9b3;p=lhc%2Fweb%2Fwiklou.git diff --git a/thumb.php b/thumb.php index cba44a9114..068ec01700 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 ); } @@ -237,7 +231,9 @@ function wfStreamThumb( array $params ) { if ( $wgVaryOnXFP ) { $varyHeader[] = 'X-Forwarded-Proto'; } - $response->header( 'Vary: ' . implode( ', ', $varyHeader ) ); + if ( count( $varyHeader ) ) { + $response->header( 'Vary: ' . implode( ', ', $varyHeader ) ); + } wfProfileOut( __METHOD__ ); return; } else { @@ -248,7 +244,9 @@ function wfStreamThumb( array $params ) { } $thumbPath = $img->getThumbPath( $thumbName ); if ( $img->getRepo()->fileExists( $thumbPath ) ) { - $headers[] = 'Vary: ' . implode( ', ', $varyHeader ); + if ( count( $varyHeader ) ) { + $headers[] = 'Vary: ' . implode( ', ', $varyHeader ); + } $img->getRepo()->streamFile( $thumbPath, $headers ); wfProfileOut( __METHOD__ ); return; @@ -258,7 +256,10 @@ function wfStreamThumb( array $params ) { wfProfileOut( __METHOD__ ); return; } - $headers[] = 'Vary: ' . implode( ', ', $varyHeader ); + + if ( count( $varyHeader ) ) { + $headers[] = 'Vary: ' . implode( ', ', $varyHeader ); + } // Thumbnail isn't already there, so create the new thumbnail... try {