- return (version_compare(PHP_VERSION, '5.3.0') >= 0)?
- clearstatcache($clear_realpath_cache,$filename):clearstatcache();
+ if (!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 50300) {
+ // Below PHP 5.3, clearstatcache does not accept any function parameters.
+ return clearstatcache();
+ }
+ else {
+ return clearstatcache($clear_realpath_cache, $filename);
+ }
+
+}
+
+
+/**
+ * Invalidates a PHP file from any active opcode caches.
+ *
+ * If the opcode cache does not support the invalidation of individual files,
+ * the entire cache will be flushed.
+ * kudo : http://cgit.drupalcode.org/drupal/commit/?id=be97f50
+ *
+ * @param string $filepath
+ * The absolute path of the PHP file to invalidate.
+ */
+function spip_clear_opcode_cache($filepath) {
+ spip_clearstatcache(TRUE, $filepath);
+
+ // Zend OPcache
+ if (function_exists('opcache_invalidate')) {
+ opcache_invalidate($filepath, TRUE);
+ }
+ // APC.
+ if (function_exists('apc_delete_file')) {
+ // apc_delete_file() throws a PHP warning in case the specified file was
+ // not compiled yet.
+ // @see http://php.net/apc-delete-file
+ @apc_delete_file($filepath);
+ }