mirror of
https://github.com/Pathduck/gallery3.git
synced 2026-04-19 20:19:16 -04:00
Switch from stdClass to arrays which works around issues caused in
http://dev.kohanaphp.com/issues/2459 -- I don't exactly know why, but the solutions are equivalent so I'm not going to dig too far.
This commit is contained in:
@@ -18,27 +18,25 @@
|
||||
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
class model_cache_Core {
|
||||
private static $cache;
|
||||
private static $cache = array();
|
||||
|
||||
static function get($model_name, $id, $field_name="id") {
|
||||
if (TEST_MODE || empty(self::$cache->$model_name->$field_name->$id)) {
|
||||
if (TEST_MODE || empty(self::$cache[$model_name][$field_name][$id])) {
|
||||
$model = ORM::factory($model_name)->where($field_name, "=", $id)->find();
|
||||
if (!$model->loaded()) {
|
||||
throw new Exception("@todo MISSING_MODEL $model_name:$id");
|
||||
}
|
||||
self::$cache->$model_name->$field_name->$id = $model;
|
||||
self::$cache[$model_name][$field_name][$id] = $model;
|
||||
}
|
||||
|
||||
return self::$cache->$model_name->$field_name->$id;
|
||||
return self::$cache[$model_name][$field_name][$id];
|
||||
}
|
||||
|
||||
static function clear() {
|
||||
self::$cache = new stdClass();
|
||||
self::$cache = array();
|
||||
}
|
||||
|
||||
static function set($model) {
|
||||
self::$cache->{$model->object_name}
|
||||
->{$model->primary_key}
|
||||
->{$model->{$model->primary_key}} = $model;
|
||||
self::$cache[$model->object_name][$model->primary_key][$model->{$model->primary_key}] = $model;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user