Skip to content

Commit

Permalink
Fix Zend Opcache opcache.validate_timestamps=0 not detecting change…
Browse files Browse the repository at this point in the history
…s in compiled yaml and twig files
  • Loading branch information
mahagr committed Apr 8, 2016
1 parent 9c5b457 commit 29eb393
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
1. [](#improved)
* Now supporting hostnames with localhost environments for better vhost support/development
1. [](#bugfix)
*
* Fix Zend Opcache `opcache.validate_timestamps=0` not detecting changes in compiled yaml and twig files

# v1.0.10
## 02/11/2016
Expand Down
11 changes: 11 additions & 0 deletions system/src/Grav/Common/File/CompiledFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,17 @@ public function content($var = null)
if ($file->locked() !== false) {
$file->save($cache);
$file->unlock();

// Compile cached file into bytecode cache
if (function_exists('opcache_compile_file')) {
opcache_compile_file($file->filename());
} elseif (function_exists('opcache_invalidate')) {
// PHP <5.5.5
opcache_invalidate($file->filename(), true);
} elseif (function_exists('apc_compile_file')) {
// PHP 5.4
apc_compile_file($file->filename());
}
}
}
$file->free();
Expand Down
3 changes: 2 additions & 1 deletion system/src/Grav/Common/Twig/Twig.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ public function init()

$params = $config->get('system.twig');
if (!empty($params['cache'])) {
$params['cache'] = $locator->findResource('cache://twig', true, true);
$cachePath = $locator->findResource('cache://twig', true, true);
$params['cache'] = new \Twig_Cache_Filesystem($cachePath, \Twig_Cache_Filesystem::FORCE_BYTECODE_INVALIDATION);
}

if (!empty($this->autoescape)) {
Expand Down

2 comments on commit 29eb393

@flaviocopes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit makes tests fail, can you check @mahagr ? https://travis-ci.org/getgrav/grav/builds/121645191

@mahagr
Copy link
Member Author

@mahagr mahagr commented on 29eb393 Apr 11, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already did, now should work.

Please sign in to comment.