diff --git a/include/class.orm.php b/include/class.orm.php index 326736f81012d171fd0c9f502025aec956f9b157..43df8e29f3ad0acf11fc684c89245f5fd6223d7f 100644 --- a/include/class.orm.php +++ b/include/class.orm.php @@ -37,6 +37,8 @@ class ModelMeta implements ArrayAccess { 'select_related' => array(), 'view' => false, ); + static $model_cache; + var $model; function __construct($model) { @@ -147,21 +149,25 @@ class ModelMeta implements ArrayAccess { } function inspectFields() { - static $cache; - if (!isset($cache)) - $cache = function_exists('apc_fetch'); - if ($cache) { + if (!isset(self::$model_cache)) + self::$model_cache = function_exists('apc_fetch'); + if (self::$model_cache) { $key = md5(SECRET_SALT . GIT_VERSION . $this['table']); if ($fields = apc_fetch($key)) { return $fields; } } $fields = DbEngine::getCompiler()->inspectTable($this['table']); - if ($cache) { + if (self::$model_cache) { apc_store($key, $fields); } return $fields; } + + static function flushModelCache() { + if (self::$model_cache) + @apc_clear_cache('user'); + } } class VerySimpleModel { diff --git a/include/class.upgrader.php b/include/class.upgrader.php index 63fba34d852d31d41c6a970528f4fbe9d35ac722..aa45d831d3c9b25410ab937ed65cf569c49f1a08 100644 --- a/include/class.upgrader.php +++ b/include/class.upgrader.php @@ -72,8 +72,10 @@ class Upgrader { function setState($state) { $this->state = $state; - if ($state == 'done') + if ($state == 'done') { $this->createUpgradedTicket(); + ModelMeta::flushModelCache(); + } } function createUpgradedTicket() {