developer.jelix.org n'est plus utilisée, et existe uniquement pour son historique. Postez les nouveaux tickets sur le compte github.
Opened 10 years ago
Last modified 9 years ago
#1217 reviewing new feature
jZone - Suppression des fichiers en fonction d'une période
Reported by: | yamsuz | Owned by: | yamsuz |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | jelix:utils | Version: | trunk |
Severity: | normal | Keywords: | |
Cc: | Blocked By: | ||
Blocking: | Documentation needed: | no | |
Hosting Provider: | Php version: |
Description (last modified by laurentj)
Il serait intéressant de faire un système permettant de supprimer les fichiers cache également en fonction d'une période. Actuellement il y a bien un système pour supprimer en fonction d'une durée mais pas en fonction d'une période (jour, mois, semaine, année etc ...)
Le principe est assez simple, on rajoute un control pour vérifier si le format de la date de création du fichier (cache) correspond au même format de la date du jour. Le parametre à rajouter est tout simplement le format que vous désirer tester (cf la fonction date de php)
protected _formatDate=""; et j'ai rajouté ce test dans la fonction getContent() dans le test permettant de vérifier si le fichier existe.
if(file_exists($f)){
j'ai rajouté :
if($this->_formatDate != ""){ clearstatcache(); if(date($this->_formatDate,filemtime($f)) != date($this->_formatDate)){ // timeout : regenerate the cache unlink($f); $this->_cancelCache=false; $content=$this->_createContent(); if(!$this->_cancelCache){ jFile::write($f,$content); } return $content; } }
Voici ce que ça donne :
if(file_exists($f)){ if($this->_cacheTimeout > 0){ [...] } //BEGIN Ma modif if($this->_formatDate != ""){ clearstatcache(); if(date($this->_formatDate,filemtime($f)) != date($this->_formatDate)){ // timeout : regenerate the cache unlink($f); $this->_cancelCache=false; $content=$this->_createContent(); if(!$this->_cancelCache){ jFile::write($f,$content); } return $content; } } //END Ma modif if($this->_tplname != ''){ [...] } $content = file_get_contents($f); }
Attachments (1)
Change History (7)
comment:1 Changed 10 years ago by foxmask
comment:2 Changed 10 years ago by laurentj
- Component changed from jelix to jelix:utils
comment:3 Changed 10 years ago by yamsuz
- Version changed from 1.1.7 to trunk
Changed 10 years ago by yamsuz
Rajout d'un test pour la suppression de zone en fonction d'une période
comment:4 Changed 10 years ago by yamsuz
Je viens de faire mon premier patch, j'espère que j'ai tout fait correctement.
comment:5 Changed 9 years ago by laurentj
- Description modified (diff)
- Status changed from new to confirmed
comment:6 Changed 9 years ago by laurentj
- Owner set to yamsuz
- Status changed from confirmed to reviewing
Il vaut mieux abuser des balises entourant le code (3 accolades) pour afficher du code, sinon c'est carrément pas lisible :/