Skip to content

Commit

Permalink
#2189 버전 업데이트 시 cached script 무효화는 주요 클래스에 한하여 수행하도록 함
Browse files Browse the repository at this point in the history
- 심각한 부하를 발생시킬 수 있는 문제
  • Loading branch information
bnu committed Dec 6, 2017
1 parent 1109173 commit 1a852bf
Showing 1 changed file with 27 additions and 31 deletions.
58 changes: 27 additions & 31 deletions config/config.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,6 @@
// Set can use other method instead cookie to store session id(for file upload)
ini_set('session.use_only_cookies', 0);

/**
* Invalidates a cached script of OPcache when version is changed.
* @see https://github.com/xpressengine/xe-core/issues/2189
**/
if(
!is_dir(_XE_PATH_ . 'files/cache/store/' . __XE_VERSION__)
&& function_exists('opcache_get_status')
&& function_exists('opcache_invalidate')
)
{
$status = opcache_get_status();
$scripts = array_keys($status['scripts']);

foreach($scripts as $script) {
if(strpos($script, _XE_PATH_) !== 0) continue;

opcache_invalidate($script, true);
}
}

if(file_exists(_XE_PATH_ . 'config/package.inc.php'))
{
require _XE_PATH_ . 'config/package.inc.php';
Expand Down Expand Up @@ -327,17 +307,6 @@
date_default_timezone_set(@date_default_timezone_get());
}

// Require a function-defined-file for simple use
require(_XE_PATH_ . 'config/func.inc.php');

if(__DEBUG__) {
define('__StartTime__', getMicroTime());
}

if(__DEBUG__) {
$GLOBALS['__elapsed_class_load__'] = 0;
}

$GLOBALS['__xe_autoload_file_map'] = array_change_key_case(array(
'CacheBase' => 'classes/cache/CacheHandler.class.php',
'CacheHandler' => 'classes/cache/CacheHandler.class.php',
Expand Down Expand Up @@ -435,6 +404,33 @@
'TablesTag' => 'classes/xml/xmlquery/tags/table/TablesTag.class.php',
), CASE_LOWER);

/**
* Invalidates a cached script of OPcache when version is changed.
* @see https://github.com/xpressengine/xe-core/issues/2189
**/
if(
!is_dir(_XE_PATH_ . 'files/cache/store/' . __XE_VERSION__)
&& function_exists('opcache_get_status')
&& function_exists('opcache_invalidate')
)
{
foreach($GLOBALS['__xe_autoload_file_map'] as $script) {
opcache_invalidate(_XE_PATH_ . $script, true);
}
opcache_invalidate(_XE_PATH_ . 'config/func.inc.php', true);
}

// Require a function-defined-file for simple use
require(_XE_PATH_ . 'config/func.inc.php');

if(__DEBUG__) {
define('__StartTime__', getMicroTime());
}

if(__DEBUG__) {
$GLOBALS['__elapsed_class_load__'] = 0;
}

function __xe_autoload($class_name)
{
if(__DEBUG__) {
Expand Down

0 comments on commit 1a852bf

Please sign in to comment.