Import new XE functions clearStatCache() and invalidateOpcache()

xpressengine/xe-core 23ec7b7

라이믹스는 Storage 클래스에서 파일을 쓸 때마다 opcache와 stat cache를
자동으로 비워주고 있으므로 이런 조치가 필요하지 않으나,
XE와의 호환성을 위해 동일한 함수를 제공함. 사용을 권장하지 않음.
This commit is contained in:
Kijin Sung 2017-12-09 01:38:46 +09:00
parent cfe5ae01d3
commit b25ce87ae5

View file

@ -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 */