Changeset 112182 in spip-zone
- Timestamp:
- Oct 27, 2018, 8:08:30 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
_plugins_/cachelab/trunk/inc/cachelab.php
r112135 r112182 61 61 if ($session=='courante') 62 62 $session = spip_session(); 63 63 64 $chemin = (isset($conditions['chemin']) ? $conditions['chemin'] : null); 64 65 $chemins = explode('|', $chemin); // sert seulement pour methode_chemin == strpos 66 65 67 $cle_objet = (isset($conditions['cle_objet']) ? $conditions['cle_objet'] : null); 66 68 $id_objet = (isset($conditions['id_objet']) ? $conditions['id_objet'] : null); … … 69 71 $cle_objet=null; 70 72 } 73 71 74 // pour 'contexte' on simule un 'more' pour donner un exemple d'extension 72 75 if (isset($conditions['contexte']) and $conditions['contexte'] and !isset($conditions['more'])) … … 75 78 $morefunc='cachelab_filtrecache_'.$more; 76 79 // Signature nécessaire : $morefunc ($action, $conditions, $options, &$stats) 77 if (!function_exists($morefunc)) 78 die ("La fonction '$morefunc' n'est pas définie"); 80 if (!function_exists($morefunc)) { 81 spip_log ("La fonction '$morefunc' n'est pas définie", 'cachelab_erreur'); 82 return; 83 } 79 84 } 80 85 … … 82 87 // explode+strpos par défaut pour les chemins 83 88 $methode_chemin = (isset ($options['methode_chemin']) ? $options['methode_chemin'] : 'strpos'); 89 $partie_chemin = (isset ($options['partie_chemin']) ? $options['partie_chemin'] : 'tout'); 84 90 // clean par défaut 85 91 $do_clean = (isset ($options['clean']) ? $options['clean'] : (!defined('CACHELAB_CLEAN') or CACHELAB_CLEAN)); … … 110 116 111 117 // on saute les caches d'autres origines 112 // (et les caches d'un précédent_CACHE_NAMESPACE pour ce même site)118 // (et les caches d'un autre _CACHE_NAMESPACE pour ce même site) 113 119 if (strpos ($cle, _CACHE_NAMESPACE) !== 0) { 114 120 $stats['nb_alien']++; … … 127 133 $del=$Memoization->del(substr($cle,$len_prefix)); 128 134 if (!$del) 129 spip_log ("Echec du clean du cache $cle (création : {$d['creation_time']}, invalidation : $meta_derniere_modif)", "cachelab ");135 spip_log ("Echec du clean du cache $cle (création : {$d['creation_time']}, invalidation : $meta_derniere_modif)", "cachelab_erreur"); 130 136 $stats['nb_clean']++; 131 137 }; … … 144 150 // 2eme filtrage : par le chemin 145 151 if ($chemin) { 152 switch ($partie_chemin) { 153 case 'tout' : 154 case 'chemin' : 155 $partie_cle = $cle; 156 break; 157 case 'fichier' : 158 $parties = explode('/', $cle); 159 $partie_cle = array_pop($parties); 160 break; 161 case 'dossier' : 162 $parties = explode('/', $cle); 163 $parties = array_pop($parties); 164 $partie_cle = array_pop($parties); 165 break; 166 default : 167 spip_log ("Option partie_chemin incorrecte : '$partie_chemin'", 'cachelab_erreur'); 168 return; 169 } 146 170 // mémo php : « continue resumes execution just before the closing curly bracket ( } ), and break resumes execution just after the closing curly bracket. » 147 171 switch ($methode_chemin) { 148 172 case 'strpos' : 149 173 foreach ($chemins as $unchemin) 150 if ($unchemin and (strpos ($ cle, $unchemin) !== false))174 if ($unchemin and (strpos ($partie_cle, $unchemin) !== false)) 151 175 break 2; // trouvé : sort du foreach et du switch et poursuit le test des autres conditions 152 176 continue 2; // échec : passe à la $cle suivante 153 177 case 'regexp' : 154 if ($chemin and ($danslechemin = preg_match(",$chemin,i", $ cle)))178 if ($chemin and ($danslechemin = preg_match(",$chemin,i", $partie_cle))) 155 179 break; // trouvé : poursuit le test des autres conditions 156 180 continue 2; // échec : passe à la clé suivante 157 181 default : 158 die("Méthode '$methode_chemin' pas prévue pour le filtrage par le chemin"); 182 spip_log ("Méthode '$methode_chemin' pas prévue pour le filtrage par le chemin", 'cachelab_erreur'); 183 return; 159 184 }; 160 185 }
Note: See TracChangeset
for help on using the changeset viewer.