A free, self-hostable news aggregator…
Minz: remove Minz_Cache
Alexandre Alapetite72ae58d45534
diff --git a/lib/Minz/Cache.php b/lib/Minz/Cache.phpdeleted file mode 100644index fcb627eb2..000000000--- a/lib/Minz/Cache.php+++ /dev/null@@ -1,116 +0,0 @@-<?php-/**- * MINZ - Copyright 2011 Marien Fressinaud- * Sous licence AGPL3 <http://www.gnu.org/licenses/>-*/--/**- * La classe Cache permet de gérer facilement les pages en cache- */-class Minz_Cache {- /**- * $expire timestamp auquel expire le cache de $url- */- private $expire = 0;-- /**- * $file est le nom du fichier de cache- */- private $file = '';-- /**- * $enabled permet de déterminer si le cache est activé- */- private static $enabled = true;-- /**- * Constructeur- */- public function __construct () {- $this->_fileName ();- $this->_expire ();- }-- /**- * Setteurs- */- public function _fileName () {- $file = md5 (Minz_Request::getURI ());-- $this->file = CACHE_PATH . '/'.$file;- }-- public function _expire () {- if ($this->exist ()) {- $this->expire = filemtime ($this->file)- + Minz_Configuration::delayCache ();- }- }-- /**- * Permet de savoir si le cache est activé- * @return true si activé, false sinon- */- public static function isEnabled () {- return Minz_Configuration::cacheEnabled () && self::$enabled;- }-- /**- * Active / désactive le cache- */- public static function switchOn () {- self::$enabled = true;- }- public static function switchOff () {- self::$enabled = false;- }-- /**- * Détermine si le cache de $url a expiré ou non- * @return true si il a expiré, false sinon- */- public function expired () {- return time () > $this->expire;- }-- /**- * Affiche le contenu du cache- * @print le code html du cache- */- public function render () {- if ($this->exist ()) {- include ($this->file);- }- }-- /**- * Enregistre $html en cache- * @param $html le html à mettre en cache- */- public function cache ($html) {- file_put_contents ($this->file, $html);- }-- /**- * Permet de savoir si le cache existe- * @return true si il existe, false sinon- */- public function exist () {- return file_exists ($this->file);- }-- /**- * Nettoie le cache en supprimant tous les fichiers- */- public static function clean () {- $files = opendir (CACHE_PATH);-- while ($fic = readdir ($files)) {- if ($fic != '.' && $fic != '..') {- unlink (CACHE_PATH.'/'.$fic);- }- }-- closedir ($files);- }-}diff --git a/lib/Minz/Configuration.php b/lib/Minz/Configuration.phpindex 324aae881..d905f6ddd 100644--- a/lib/Minz/Configuration.php+++ b/lib/Minz/Configuration.php@@ -34,8 +34,6 @@ class Minz_Configuration {* $base_url le chemin de base pour accéder à l'application* $title le nom de l'application* $language la langue par défaut de l'application- * $cacheEnabled permet de savoir si le cache doit être activé- * $delayCache la limite de cache* $db paramètres pour la base de données (tableau)* - host le serveur de la base* - user nom d'utilisateur@@ -48,8 +46,6 @@ class Minz_Configuration {private static $use_url_rewriting = false;private static $title = '';private static $language = 'en';- private static $cache_enabled = false;- private static $delay_cache = 3600;private static $default_user = '';private static $allow_anonymous = false;private static $allow_anonymous_refresh = false;@@ -103,12 +99,6 @@ class Minz_Configuration {public static function language () {return self::$language;}- public static function cacheEnabled () {- return self::$cache_enabled;- }- public static function delayCache () {- return self::$delay_cache;- }public static function dataBase () {return self::$db;}@@ -282,18 +272,6 @@ class Minz_Configuration {if (isset ($general['language'])) {self::$language = $general['language'];}- if (isset ($general['cache_enabled'])) {- self::$cache_enabled = $general['cache_enabled'];- if (CACHE_PATH === false && self::$cache_enabled) {- throw new FileNotExistException (- 'CACHE_PATH',- Minz_Exception::ERROR- );- }- }- if (isset ($general['delay_cache'])) {- self::$delay_cache = inval($general['delay_cache']);- }if (isset ($general['default_user'])) {self::$default_user = $general['default_user'];}diff --git a/lib/Minz/Dispatcher.php b/lib/Minz/Dispatcher.phpindex 71dfe8ac6..819f4cd5c 100644--- a/lib/Minz/Dispatcher.php+++ b/lib/Minz/Dispatcher.php@@ -41,7 +41,6 @@ class Minz_Dispatcher {* @exception Minz_Exception*/public function run ($ob = true) {- $cache = new Minz_Cache();// Le ob_start est dupliqué : sans ça il y a un bug sous Firefox// ici on l'appelle avec 'ob_gzhandler', après sans.// Vraisemblablement la compression fonctionne mais c'est sale@@ -50,45 +49,31 @@ class Minz_Dispatcher {ob_start ('ob_gzhandler');}- if (Minz_Cache::isEnabled () && !$cache->expired ()) {- if ($ob) {- ob_start ();- }- $cache->render ();- if ($ob) {- $text = ob_get_clean();- }- } else {- $text = ''; //TODO: Clean this code- while (Minz_Request::$reseted) {- Minz_Request::$reseted = false;+ $text = ''; //TODO: Clean this code+ while (Minz_Request::$reseted) {+ Minz_Request::$reseted = false;- try {- $this->createController ('FreshRSS_' . Minz_Request::controllerName () . '_Controller');- $this->controller->init ();- $this->controller->firstAction ();- $this->launchAction (- Minz_Request::actionName ()- . 'Action'- );- $this->controller->lastAction ();+ try {+ $this->createController ('FreshRSS_' . Minz_Request::controllerName () . '_Controller');+ $this->controller->init ();+ $this->controller->firstAction ();+ $this->launchAction (+ Minz_Request::actionName ()+ . 'Action'+ );+ $this->controller->lastAction ();- if (!Minz_Request::$reseted) {- if ($ob) {- ob_start ();- }- $this->controller->view ()->build ();- if ($ob) {- $text = ob_get_clean();- }+ if (!Minz_Request::$reseted) {+ if ($ob) {+ ob_start ();+ }+ $this->controller->view ()->build ();+ if ($ob) {+ $text = ob_get_clean();}- } catch (Minz_Exception $e) {- throw $e;}- }-- if (Minz_Cache::isEnabled ()) {- $cache->cache ($text);+ } catch (Minz_Exception $e) {+ throw $e;}}