Przeglądaj źródła

touch en microsecondes

Passage en microsecondes pour le touch (gestion du cache) pour éviter
les problèmes en particulier dans le cas de requêtes de moins d'une
seconde.
Nouvelle fonction invalidateHttpCache() pour plus facilement changer de
méthode de contrôle de fraîcheur de cache.
Devrait résoudre https://github.com/marienfressinaud/FreshRSS/issues/296
Alexandre Alapetite 12 lat temu
rodzic
commit
7cdc477c45

+ 1 - 1
actualize_script.php

@@ -20,4 +20,4 @@ $front_controller = new App_FrontController ();
 $front_controller->init ();
 Session::_param('mail', true); // permet de se passer de la phase de connexion
 $front_controller->run ();
-touch(DATA_PATH . '/touch.txt');
+invalidateHttpCache();

+ 1 - 1
app/controllers/entryController.php

@@ -84,7 +84,7 @@ class entryController extends ActionController {
 		$entryDAO = new EntryDAO();
 		$entryDAO->optimizeTable();
 
-		touch(DATA_PATH . '/touch.txt');
+		invalidateHttpCache();
 
 		$notif = array (
 			'type' => 'good',

+ 2 - 2
app/controllers/indexController.php

@@ -272,7 +272,7 @@ class indexController extends ActionController {
 		$res = json_decode ($result, true);
 		if ($res['status'] == 'okay' && $res['email'] == $this->view->conf->mailLogin ()) {
 			Session::_param ('mail', $res['email']);
-			touch(DATA_PATH . '/touch.txt');
+			invalidateHttpCache();
 		} else {
 			$res = array ();
 			$res['status'] = 'failure';
@@ -285,6 +285,6 @@ class indexController extends ActionController {
 	public function logoutAction () {
 		$this->view->_useLayout (false);
 		Session::_param ('mail');
-		touch(DATA_PATH . '/touch.txt');
+		invalidateHttpCache();
 	}
 }

+ 1 - 1
app/layout/layout.phtml

@@ -32,7 +32,7 @@
 
 <?php
 	if (isset ($this->notification)) {
-		touch(DATA_PATH . '/touch.txt');
+		invalidateHttpCache();
 ?>
 <div class="notification <?php echo $this->notification['type']; ?>">
 	<?php echo $this->notification['content']; ?>

+ 1 - 1
app/models/RSSConfiguration.php

@@ -473,6 +473,6 @@ class RSSConfigurationDAO extends Model_array {
 		}
 
 		$this->writeFile($this->array);
-		touch(DATA_PATH . '/touch.txt');
+		invalidateHttpCache();
 	}
 }

+ 4 - 0
lib/lib_rss.php

@@ -230,3 +230,7 @@ function lazyimg($content) {
 		$content
 	);
 }
+
+function invalidateHttpCache() {
+	file_put_contents(DATA_PATH . '/touch.txt', microtime(true));
+}

+ 1 - 1
lib/minz/dao/Model_pdo.php

@@ -85,7 +85,7 @@ class Model_pdo {
 class FreshPDO extends PDO {
 	private static function check($statement) {
 		if (preg_match('/^(?:UPDATE|INSERT|DELETE)/i', $statement)) {
-			touch(DATA_PATH . '/touch.txt');
+			invalidateHttpCache();
 		}
 	}
 

+ 4 - 3
public/index.php

@@ -27,10 +27,11 @@ if (file_exists ('install.php')) {
 	if (!file_exists(DATA_PATH . '/no-cache.txt')) {
 		require (LIB_PATH . '/http-conditional.php');
 		$dateLastModification = max(
-			@filemtime(DATA_PATH . '/touch.txt') - 1,
-			@filemtime(LOG_PATH . '/application.log') - 1,
-			@filemtime(DATA_PATH . '/application.ini') - 1
+			@filemtime(DATA_PATH . '/touch.txt'),
+			@filemtime(LOG_PATH . '/application.log'),
+			@filemtime(DATA_PATH . '/application.ini')
 		);
+		$_SERVER['QUERY_STRING'] .= '&utime=' . file_get_contents(DATA_PATH . '/touch.txt');
 		if (httpConditional($dateLastModification, 0, 0, false, false, true)) {
 			exit();	//No need to send anything
 		}