From: Ori Livneh Date: Wed, 23 Sep 2015 08:11:58 +0000 (-0700) Subject: resourceloader: Use FileContentsHasher in safeFileHash() X-Git-Tag: 1.31.0-rc.0~9875^2 X-Git-Url: http://git.cyclocoop.org//%27http:/ie7-js.googlecode.com/svn/test/index.html/%27?a=commitdiff_plain;h=2cbd25e9e48d81c873863b31553f164d635ee701;p=lhc%2Fweb%2Fwiklou.git resourceloader: Use FileContentsHasher in safeFileHash() Replace the one-off code for APC-assisted file content hashing from I5ceb8537c with a call to the FileContentsHasher class introduced in I1ff61153. Change-Id: I8e4c3d5a5e7cdf6455a43769261d742b0255622c --- diff --git a/includes/resourceloader/ResourceLoaderModule.php b/includes/resourceloader/ResourceLoaderModule.php index 1d3ffb553c..376b62cdf1 100644 --- a/includes/resourceloader/ResourceLoaderModule.php +++ b/includes/resourceloader/ResourceLoaderModule.php @@ -857,35 +857,6 @@ abstract class ResourceLoaderModule { * @return string Hash */ protected static function safeFileHash( $filePath ) { - static $cache; - - if ( !$cache ) { - $cache = ObjectCache::newAccelerator( CACHE_NONE ); - } - - MediaWiki\suppressWarnings(); - $mtime = filemtime( $filePath ); - MediaWiki\restoreWarnings(); - if ( !$mtime ) { - return ''; - } - - $cacheKey = wfGlobalCacheKey( 'resourceloader', __METHOD__, $filePath ); - $cachedHash = $cache->get( $cacheKey ); - if ( isset( $cachedHash['mtime'] ) && $cachedHash['mtime'] === $mtime ) { - return $cachedHash['hash']; - } - - MediaWiki\suppressWarnings(); - $contents = file_get_contents( $filePath ); - MediaWiki\restoreWarnings(); - if ( !$contents ) { - return ''; - } - - $hash = hash( 'md4', $contents ); - $cache->set( $cacheKey, array( 'mtime' => $mtime, 'hash' => $hash ), 60 * 60 * 24 ); - - return $hash; + return FileContentsHasher::getFileContentsHash( $filePath ); } }