From b25ce87ae587ac2670c197776f2cd6434b63f74e Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Sat, 9 Dec 2017 01:38:46 +0900 Subject: [PATCH] Import new XE functions clearStatCache() and invalidateOpcache() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit xpressengine/xe-core 23ec7b7 라이믹스는 Storage 클래스에서 파일을 쓸 때마다 opcache와 stat cache를 자동으로 비워주고 있으므로 이런 조치가 필요하지 않으나, XE와의 호환성을 위해 동일한 함수를 제공함. 사용을 권장하지 않음. --- classes/file/FileHandler.class.php | 58 ++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/classes/file/FileHandler.class.php b/classes/file/FileHandler.class.php index d3575415c..af5f696c5 100644 --- a/classes/file/FileHandler.class.php +++ b/classes/file/FileHandler.class.php @@ -818,6 +818,64 @@ class FileHandler $path = self::getRealPath($path); return Rhymix\Framework\Storage::isDirectory($path) && Rhymix\Framework\Storage::isWritable($path); } + + /** + * @deprecated + * + * Clears file status cache + * + * @param string|array $target filename or directory + * @param boolean $include include files in the directory + */ + public static function clearStatCache($target, $include = false) + { + foreach(is_array($target) ? $target : array($target) as $target_item) + { + $target_item = self::getRealPath($target_item); + if($include && self::isDir($target_item)) + { + self::clearStatCache(self::readDir($target_item, '', false, true), $include); + } + else + { + clearstatcache(true, $target_item); + } + } + } + + /** + * @deprecated + * + * Invalidates a cached script of OPcache + * + * @param string|array $target filename or directory + * @param boolean $force force + */ + public static function invalidateOpcache($target, $force = true) + { + static $opcache = null; + + if($opcache === null) + { + $opcache = function_exists('opcache_invalidate'); + } + if($opcache === false) + { + return; + } + + foreach(is_array($target) ? $target : array($target) as $target_item) + { + if(substr($target_item, -4) === '.php') + { + opcache_invalidate(self::getRealPath($target_item), $force); + } + elseif($path = self::isDir($target_item)) + { + self::invalidateOpcache(self::readDir($path, '', false, true), $force); + } + } + } } /* End of file FileHandler.class.php */