Skip to content

Commit

Permalink
#2189 버전이 변경되면 OPcache에 캐시된 스크립트를 무효화
Browse files Browse the repository at this point in the history
- config.inc.php 파일은 항상 캐시를 무효화 함
  • Loading branch information
bnu committed Dec 5, 2017
1 parent 31af193 commit 1109173
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
19 changes: 19 additions & 0 deletions config/config.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,25 @@
// 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'))
{
Expand Down
4 changes: 4 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
/**
* @brief Include the necessary configuration files
**/
if(function_exists('opcache_invalidate'))
{
opcache_invalidate(dirname(__FILE__) . '/config/config.inc.php', true);
}
require dirname(__FILE__) . '/config/config.inc.php';

/**
Expand Down

0 comments on commit 1109173

Please sign in to comment.