[SPIP] v3.2.1-->v3.2.2
[lhc/web/www.git] / www / ecrire / inc / flock.php
index 8afe53d..dada718 100644 (file)
@@ -3,7 +3,7 @@
 /***************************************************************************\
  *  SPIP, Systeme de publication pour l'internet                           *
  *                                                                         *
- *  Copyright (c) 2001-2017                                                *
+ *  Copyright (c) 2001-2019                                                *
  *  Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James  *
  *                                                                         *
  *  Ce programme est un logiciel libre distribue sous licence GNU/GPL.     *
@@ -465,7 +465,11 @@ function spip_clear_opcode_cache($filepath) {
 
        // Zend OPcache
        if (function_exists('opcache_invalidate')) {
-               opcache_invalidate($filepath, true);
+               $invalidate = @opcache_invalidate($filepath, true);
+               // si l'invalidation a echoue lever un flag
+               if (!$invalidate and !defined('_spip_attend_invalidation_opcode_cache')) {
+                       define('_spip_attend_invalidation_opcode_cache',true);
+               }
        }
        // APC.
        if (function_exists('apc_delete_file')) {
@@ -495,14 +499,24 @@ function spip_clear_opcode_cache($filepath) {
  * @link http://wiki.mikejung.biz/PHP_OPcache
  *
  */
-function spip_attend_invalidation_opcode_cache() {
+function spip_attend_invalidation_opcode_cache($timestamp = null) {
        if (function_exists('opcache_get_configuration')
                and @ini_get('opcache.enable')
                and @ini_get('opcache.validate_timestamps')
                and $duree = @ini_get('opcache.revalidate_freq')
+               and defined('_spip_attend_invalidation_opcode_cache') // des invalidations ont echouees
        ) {
-               spip_log('Probleme de configuration opcache.revalidate_freq '. $duree .'s', _LOG_INFO_IMPORTANTE);
-               sleep($duree + 1);
+               $wait = $duree + 1;
+               if ($timestamp) {
+                       $wait -= (time() - $timestamp);
+                       if ($wait<0) {
+                               $wait = 0;
+                       }
+               }
+               spip_log('Probleme de configuration opcache.revalidate_freq '. $duree .'s : on attend '.$wait.'s', _LOG_INFO_IMPORTANTE);
+               if ($wait) {
+                       sleep($duree + 1);
+               }
        }
 }
 
@@ -570,7 +584,10 @@ function sous_repertoire($base, $subdir = '', $nobase = false, $tantpis = false)
        $base = str_replace("//", "/", $base);
 
        # suppr le dernier caractere si c'est un / ou un _
-       $base = rtrim($base, '/_');
+       $base = rtrim($base, '/');
+       if (_CREER_DIR_PLAT) {
+               $base = rtrim($base, '_');
+       }
 
        if (!strlen($subdir)) {
                $n = strrpos($base, "/");
@@ -582,6 +599,9 @@ function sous_repertoire($base, $subdir = '', $nobase = false, $tantpis = false)
        } else {
                $base .= '/';
                $subdir = str_replace("/", "", $subdir);
+               if (_CREER_DIR_PLAT) {
+                       $subdir = rtrim($subdir, '_');
+               }
        }
 
        $baseaff = $nobase ? '' : $base;