Browse Source

Report de r22112 : #3418 : purger les opcode cache y compris sur php-fpm (a valider) / Credits pour le patch https://www.drupal.org/node/779482

svn/attic/tags/spip-3.1.0-beta/22130
Cerdic 6 years ago
parent
commit
56007a9618
  1. 40
      ecrire/inc/flock.php

40
ecrire/inc/flock.php

@ -266,8 +266,7 @@ function ecrire_fichier ($fichier, $contenu, $ignorer_echec = false, $truncate=t
// liberer le verrou et fermer le fichier
@chmod($fichier, _SPIP_CHMOD & 0666);
if ($ok) {
if (!defined('_OPCACHE_BUG') AND function_exists('opcache_invalidate'))
opcache_invalidate($fichier, true);
spip_clear_opcode_cache($fichier);
return $ok;
}
}
@ -425,10 +424,43 @@ function spip_unlink($f) {
* @param null $filename
*/
function spip_clearstatcache($clear_realpath_cache = false, $filename=null){
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);
}
}
/**
* Suppression complete d'un repertoire.
*

Loading…
Cancel
Save