From a019667e198b5ed6fc1a1c240e994047dd4fe16e Mon Sep 17 00:00:00 2001 From: "Committo,Ergo:sum" <esj@rezo.net> Date: Sat, 11 Aug 2007 12:00:20 +0000 Subject: [PATCH] =?UTF-8?q?Faire=20le=20clearstatcache=20dans=20Cron,=20pl?= =?UTF-8?q?utot=20que=20inc=5Fcron=20pour=20que=20=C3=A7a=20profite=20?= =?UTF-8?q?=C3=A0=20cron.lock.=20Simplifier=20spip=5Ftouch=20et=20redresse?= =?UTF-8?q?r=20son=20commentaire.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ecrire/inc/cron.php | 1 - ecrire/inc/utils.php | 24 +++++++++++------------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/ecrire/inc/cron.php b/ecrire/inc/cron.php index f0cfa24c32..7f38d3cab0 100644 --- a/ecrire/inc/cron.php +++ b/ecrire/inc/cron.php @@ -59,7 +59,6 @@ function inc_cron_dist($taches = array()) { // Quelle est la tache la plus urgente ? $tache = ''; $tmin = $t = time(); - clearstatcache(); foreach ($taches as $nom => $periode) { $celock = _DIR_TMP . $nom . '.lock'; $date_lock = @filemtime($celock); diff --git a/ecrire/inc/utils.php b/ecrire/inc/utils.php index 6016c27454..8cc4387cba 100644 --- a/ecrire/inc/utils.php +++ b/ecrire/inc/utils.php @@ -558,22 +558,20 @@ function spip_timer($t='rien') { } -// spip_touch : verifie si un fichier existe et n'est pas vieux (duree en s) -// et le cas echeant le touch() ; renvoie true si la condition est verifiee -// et fait touch() sauf si ca n'est pas souhaite -// (regle aussi le probleme des droits sur les fichiers touch()) +// Renvoie False si un fichier n'est pas plus vieux que $duree secondes, +// sinon renvoie True et le date sauf si ca n'est pas souhaite // http://doc.spip.org/@spip_touch function spip_touch($fichier, $duree=0, $touch=true) { - if (!($exists = @is_readable($fichier)) - || ($duree == 0) - || (@filemtime($fichier) < time() - $duree)) { - if ($touch) { - if (!@touch($fichier)) { spip_unlink($fichier); @touch($fichier); }; - if (!$exists) @chmod($fichier, _SPIP_CHMOD & ~0111); - } - return true; + if ($duree) { + clearstatcache(); + if ((@$f=filemtime($fichier)) AND ($f >= time() - $duree)) + return false; } - return false; + if ($touch) { + if (!@touch($fichier)) { spip_unlink($fichier); @touch($fichier); }; + @chmod($fichier, _SPIP_CHMOD & ~0111); + } + return true; } // Ce declencheur de tache de fond, de l'espace prive (cf inc_presentation) -- GitLab