summaryrefslogtreecommitdiff
path: root/modules/gallery/helpers
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2009-07-17 12:51:27 -0700
committerBharat Mediratta <bharat@menalto.com>2009-07-17 12:51:27 -0700
commitcd907c2b42f8b50ebe6d490aab42365e16deb258 (patch)
treeb58350f7d7ffebeb91d5d9d2f273c0561625664b /modules/gallery/helpers
parent8a6556b30bc34d69284df6246f4010a8835f3bc2 (diff)
Change model_cache::clear() API to clear everything. This prevents
old ORM relationships from hanging around, which was causing problems when doing MPTT manipulations (resulting in incorrect permission propagation-- very bad!)
Diffstat (limited to 'modules/gallery/helpers')
-rw-r--r--modules/gallery/helpers/access.php4
-rw-r--r--modules/gallery/helpers/item.php4
-rw-r--r--modules/gallery/helpers/model_cache.php6
3 files changed, 8 insertions, 6 deletions
diff --git a/modules/gallery/helpers/access.php b/modules/gallery/helpers/access.php
index 5dd1e465..63324e5d 100644
--- a/modules/gallery/helpers/access.php
+++ b/modules/gallery/helpers/access.php
@@ -205,6 +205,7 @@ class access_Core {
}
self::_update_htaccess_files($album, $group, $perm_name, $value);
+ model_cache::clear();
}
/**
@@ -256,6 +257,7 @@ class access_Core {
}
}
}
+ model_cache::clear();
}
/**
@@ -426,6 +428,7 @@ class access_Core {
$cache_table = $perm_name == "view" ? "items" : "access_caches";
$db->query("ALTER TABLE {{$cache_table}} DROP `$field`");
$db->query("ALTER TABLE {access_intents} DROP `$field`");
+ model_cache::clear();
ORM::factory("access_intent")->clear_cache();
}
@@ -443,6 +446,7 @@ class access_Core {
$db->query("ALTER TABLE {{$cache_table}} ADD `$field` SMALLINT NOT NULL DEFAULT 0");
$db->query("ALTER TABLE {access_intents} ADD `$field` BOOLEAN DEFAULT NULL");
$db->update("access_intents", array($field => 0), array("item_id" => 1));
+ model_cache::clear();
ORM::factory("access_intent")->clear_cache();
}
diff --git a/modules/gallery/helpers/item.php b/modules/gallery/helpers/item.php
index f40b5c97..80c25862 100644
--- a/modules/gallery/helpers/item.php
+++ b/modules/gallery/helpers/item.php
@@ -53,7 +53,7 @@ class item_Core {
access::required("view", $parent);
access::required("edit", $parent);
- model_cache::clear("item", $parent->album_cover_item_id);
+ model_cache::clear();
$parent->album_cover_item_id = $item->is_album() ? $item->album_cover_item_id : $item->id;
$parent->thumb_dirty = 1;
$parent->save();
@@ -69,7 +69,7 @@ class item_Core {
access::required("edit", $album);
@unlink($album->thumb_path());
- model_cache::clear("item", $album->album_cover_item_id) ;
+ model_cache::clear();
$album->album_cover_item_id = null;
$album->thumb_width = 0;
$album->thumb_height = 0;
diff --git a/modules/gallery/helpers/model_cache.php b/modules/gallery/helpers/model_cache.php
index 2649fdbd..a3e09862 100644
--- a/modules/gallery/helpers/model_cache.php
+++ b/modules/gallery/helpers/model_cache.php
@@ -32,10 +32,8 @@ class model_cache_Core {
return self::$cache->$model_name->$field_name->$id;
}
- static function clear($model_name, $id, $field_name="id") {
- if (!empty(self::$cache->$model_name->$field_name->$id)) {
- unset(self::$cache->$model_name->$field_name->$id);
- }
+ static function clear() {
+ self::$cache = new stdClass();
}
static function set($model) {