mirror of
https://github.com/FreshRSS/FreshRSS.git
synced 2026-05-24 08:14:56 -04:00
Minz : bug avec OPcache de PHP 5.5+
Minz ne prenait pas en charge OPcache (cache PHP) http://php.net/opcache activé par défaut depuis PHP5.5. Ce fut un peu dur d'isoler ce bug :-/ Il faut penser à appeler opcache_invalidate avant de ré-utiliser un fichier par include(). Aussi, le mécanisme de lock() n'est plus approprié ni nécessaire. Pour FreshRSS, évite l'utilisation de ModelArray car il ne restait que quelques lignes d'utiles, et évite un héritage + appel de classe, ce qui est toujours ça de gagné.
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
class FreshRSS_Configuration extends Minz_ModelArray {
|
||||
class FreshRSS_Configuration {
|
||||
private $filename;
|
||||
|
||||
private $data = array(
|
||||
'language' => 'en',
|
||||
'old_entries' => 3,
|
||||
@@ -60,10 +62,12 @@ class FreshRSS_Configuration extends Minz_ModelArray {
|
||||
);
|
||||
|
||||
public function __construct ($user) {
|
||||
$filename = DATA_PATH . '/' . $user . '_user.php';
|
||||
$this->filename = DATA_PATH . '/' . $user . '_user.php';
|
||||
|
||||
parent::__construct($filename);
|
||||
$data = parent::loadArray();
|
||||
$data = include($this->filename);
|
||||
if (!is_array($data)) {
|
||||
throw new Minz_PermissionDeniedException($this->filename);
|
||||
}
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
if (isset($this->data[$key])) {
|
||||
@@ -75,8 +79,14 @@ class FreshRSS_Configuration extends Minz_ModelArray {
|
||||
}
|
||||
|
||||
public function save() {
|
||||
if (file_put_contents($this->filename, "<?php\n return " . var_export($array, true) . ';', LOCK_EX) === false) {
|
||||
throw new Minz_PermissionDeniedException($this->filename);
|
||||
}
|
||||
if (function_exists('opcache_invalidate')) {
|
||||
opcache_invalidate($this->filename); //Clear PHP 5.5+ cache for include
|
||||
}
|
||||
invalidateHttpCache();
|
||||
return parent::writeArray($this->data);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function __get($name) {
|
||||
|
||||
@@ -157,25 +157,22 @@ class Minz_Configuration {
|
||||
'db' => self::$db,
|
||||
);
|
||||
@rename(DATA_PATH . self::CONF_PATH_NAME, DATA_PATH . self::CONF_PATH_NAME . '.bak');
|
||||
return file_put_contents(DATA_PATH . self::CONF_PATH_NAME, "<?php\n return " . var_export($ini_array, true) . ';');
|
||||
$result = file_put_contents(DATA_PATH . self::CONF_PATH_NAME, "<?php\n return " . var_export($ini_array, true) . ';');
|
||||
if (function_exists('opcache_invalidate')) {
|
||||
opcache_invalidate(DATA_PATH . self::CONF_PATH_NAME); //Clear PHP 5.5+ cache for include
|
||||
}
|
||||
return (bool)$result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse un fichier de configuration
|
||||
* @exception Minz_FileNotExistException si le CONF_PATH_NAME n'existe pas
|
||||
* @exception Minz_PermissionDeniedException si le CONF_PATH_NAME n'est pas accessible
|
||||
* @exception Minz_BadConfigurationException si CONF_PATH_NAME mal formaté
|
||||
*/
|
||||
private static function parseFile () {
|
||||
if (!file_exists (DATA_PATH . self::CONF_PATH_NAME)) {
|
||||
throw new Minz_FileNotExistException (
|
||||
DATA_PATH . self::CONF_PATH_NAME,
|
||||
Minz_Exception::ERROR
|
||||
);
|
||||
}
|
||||
|
||||
$ini_array = include(DATA_PATH . self::CONF_PATH_NAME);
|
||||
|
||||
if (!$ini_array) {
|
||||
if (!is_array($ini_array)) {
|
||||
throw new Minz_PermissionDeniedException (
|
||||
DATA_PATH . self::CONF_PATH_NAME,
|
||||
Minz_Exception::ERROR
|
||||
|
||||
@@ -45,9 +45,12 @@ class Minz_ModelArray {
|
||||
* Sauve le tableau $array dans le fichier $filename
|
||||
**/
|
||||
protected function writeArray($array) {
|
||||
if (!file_put_contents($this->filename, "<?php\n return " . var_export($array, true) . ';', LOCK_EX)) {
|
||||
if (file_put_contents($this->filename, "<?php\n return " . var_export($array, true) . ';', LOCK_EX) === false) {
|
||||
throw new Minz_PermissionDeniedException($this->filename);
|
||||
}
|
||||
if (function_exists('opcache_invalidate')) {
|
||||
opcache_invalidate($this->filename); //Clear PHP 5.5+ cache for include
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user