From 2859d368e457e6d8b0502a8946e0b5dee712d27f Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Thu, 3 Nov 2011 17:06:44 +0000 Subject: [PATCH] let us force thumb rendering even if previous file exist The new FORCE_RENDER flag should always be used with FORCE_NOW. It let us override the file_exist() check and thus trigger a thumb rendering even if the file exist. Will be needed by the vipscaler extension. --- includes/filerepo/File.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/includes/filerepo/File.php b/includes/filerepo/File.php index 63719eeffc..e78eca4104 100644 --- a/includes/filerepo/File.php +++ b/includes/filerepo/File.php @@ -30,7 +30,14 @@ abstract class File { const DELETED_COMMENT = 2; const DELETED_USER = 4; const DELETED_RESTRICTED = 8; - const RENDER_NOW = 1; + + /** Force rendering in the current process */ + const RENDER_NOW = 1; + /** + * Force rendering even if thumbnail already exist and using RENDER_NOW + * I.e. you have to pass both flags: File::RENDER_NOW | File::RENDER_FORCE + */ + const RENDER_FORCE = 2; const DELETE_SOURCE = 1; @@ -672,18 +679,21 @@ abstract class File { $thumbPath = $this->getThumbPath( $thumbName ); if ( $this->repo && $this->repo->canTransformVia404() && !($flags & self::RENDER_NOW ) ) { + wfDebug( __METHOD__ . " transformation deferred." ); return $this->handler->getTransform( $this, $thumbPath, $thumbUrl, $params ); } wfDebug( __METHOD__.": Doing stat for $thumbPath\n" ); $this->migrateThumbFile( $thumbName ); - if ( file_exists( $thumbPath )) { + if ( file_exists( $thumbPath ) && !($flags & self::RENDER_FORCE) ) { $thumbTime = filemtime( $thumbPath ); if ( $thumbTime !== FALSE && gmdate( 'YmdHis', $thumbTime ) >= $wgThumbnailEpoch ) { return $this->handler->getTransform( $this, $thumbPath, $thumbUrl, $params ); } + } elseif( $flags & self::RENDER_FORCE ) { + wfDebug( __METHOD__ . " forcing rendering per flag File::RENDER_FORCE\n" ); } $thumb = $this->handler->doTransform( $this, $thumbPath, $thumbUrl, $params ); -- 2.20.1