Show
Ignore:
Timestamp:
11/11/07 12:14:05 (2 years ago)
Author:
cedric@…
Message:

"lorsqu'un admin fait un (re)calcul, invalider la page en cache apache qui est perimee"

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • _plugins_/_dev_/expresso/expresso_pipeline.php

    r16750 r16761  
    8989} 
    9090 
     91function expresso_append_url($url,$cachefile){ 
     92        $GLOBALS['meta']['expresso'] .= "$url!$cachefile\n"; 
     93        expresso_genere_htaccess(); 
     94} 
     95function expresso_remove_url($url,$cachefile){ 
     96        $GLOBALS['meta']['expresso'] = preg_replace(",$url!.*?\n,","",$GLOBALS['meta']['expresso']); 
     97        expresso_genere_htaccess(); 
     98        @unlink($cachefile); 
     99} 
     100 
    91101function expresso_affichage_final($flux) { 
     102        $url = self(true); 
     103        $url = "http://".$_SERVER['HTTP_HOST']. preg_replace(';^[a-z]{3,5}://[^/]*;','',$GLOBALS['meta']['adresse_site']) . $url; 
    92104        if (empty($_POST) 
    93105        AND !isset($_COOKIE['spip_admin']) 
    94106        AND !isset($_COOKIE['spip_session']) 
    95107        AND !isset($_SERVER['PHP_AUTH_USER'])){ 
    96                 $url = self(true); 
    97                 $url = "http://".$_SERVER['HTTP_HOST']. preg_replace(';^[a-z]{3,5}://[^/]*;','',$GLOBALS['meta']['adresse_site']) . $url; 
    98108                if (isset($GLOBALS['page']['entetes']['X-Expresso'])) { 
    99109                        $nom_cache = _DIR_VAR . "apache/".md5($url).".html"; 
     
    101111                                ($GLOBALS['var_mode']=='calcul') 
    102112                                OR ($GLOBALS['var_mode']=='recalcul') 
    103                                 OR !($e=file_exists($nom_cache)) 
     113                                OR !(file_exists($nom_cache)) 
    104114                                OR ( ($d=filemtime($nom_cache)) AND ($d+$GLOBALS['page']['entetes']['X-Spip-Cache']<time())) 
    105115                                ) { 
     
    108118                                # expresso est une simple chaine pour eviter la deserialisation a chaque hit et preferer un strpos plus rapide 
    109119                                # url!nom_cache\n 
    110                                 if (strpos($GLOBALS['meta']['expresso'],"$url!")===FALSE) { 
    111                                         $GLOBALS['meta']['expresso'] .= "$url!$nom_cache\n"; 
    112                                         expresso_genere_htaccess(); 
    113                                 } 
     120                                if (strpos($GLOBALS['meta']['expresso'],"$url!")===FALSE) 
     121                                        expresso_append_url($url,$nom_cache); 
    114122                                elseif($GLOBALS['var_mode']=='recalcul') 
    115123                                        expresso_genere_htaccess(); 
    116124                        } 
    117125                } 
    118                 elseif (strpos($GLOBALS['meta']['expresso'],"$url!")!==FALSE) { 
    119                         $GLOBALS['meta']['expresso'] = preg_replace(",$url!.*?\n,","",$GLOBALS['meta']['expresso']); 
    120                         expresso_genere_htaccess(); 
    121                 } 
     126                elseif (strpos($GLOBALS['meta']['expresso'],"$url!")!==FALSE) 
     127                        expresso_remove_url($url,$nom_cache); 
     128        } 
     129        else { 
     130                if (  
     131                        isset($_COOKIE['spip_admin']) 
     132                        && 
     133                        ( ($GLOBALS['var_mode']=='calcul') OR ($GLOBALS['var_mode']=='recalcul')) 
     134                        ) { 
     135                                $nom_cache = _DIR_VAR . "apache/".md5($url).".html"; 
     136                                if (file_exists($nom_cache)) 
     137                                        expresso_remove_url($url,$nom_cache); 
     138                        } 
    122139        } 
    123140        return $flux;