From 2cbd25e9e48d81c873863b31553f164d635ee701 Mon Sep 17 00:00:00 2001 From: Ori Livneh Date: Wed, 23 Sep 2015 01:11:58 -0700 Subject: [PATCH] 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 --- .../resourceloader/ResourceLoaderModule.php | 31 +------------------ 1 file changed, 1 insertion(+), 30 deletions(-) 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 ); } } -- 2.20.1