summaryrefslogtreecommitdiff
path: root/modules/gallery
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gallery')
-rw-r--r--modules/gallery/models/item.php2
-rw-r--r--modules/gallery/models/log.php17
-rw-r--r--modules/gallery/tests/Access_Helper_Test.php4
3 files changed, 19 insertions, 4 deletions
diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php
index 6499fd2d..6f0e3525 100644
--- a/modules/gallery/models/item.php
+++ b/modules/gallery/models/item.php
@@ -333,7 +333,7 @@ class Item_Model extends ORM_MPTT {
// This relationship depends on an outside module, which may not be present so handle
// failures gracefully.
try {
- return model_cache::get("user", $this->owner_id);
+ return user::lookup($this->owner_id);
} catch (Exception $e) {
return null;
}
diff --git a/modules/gallery/models/log.php b/modules/gallery/models/log.php
index 6734afb8..d143d7bd 100644
--- a/modules/gallery/models/log.php
+++ b/modules/gallery/models/log.php
@@ -18,5 +18,20 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class Log_Model extends ORM {
- protected $has_one = array("user");
+ /**
+ * @see ORM::__get()
+ */
+ public function __get($column) {
+ if ($column == "user") {
+ // This relationship depends on an outside module, which may not be present so handle
+ // failures gracefully.
+ try {
+ return user::lookup($this->user_id);
+ } catch (Exception $e) {
+ return null;
+ }
+ } else {
+ return parent::__get($column);
+ }
+ }
}
diff --git a/modules/gallery/tests/Access_Helper_Test.php b/modules/gallery/tests/Access_Helper_Test.php
index 59cec453..72d7e04c 100644
--- a/modules/gallery/tests/Access_Helper_Test.php
+++ b/modules/gallery/tests/Access_Helper_Test.php
@@ -33,7 +33,7 @@ class Access_Helper_Test extends Unit_Test_Case {
} catch (Exception $e) { }
try {
- $user = ORM::factory("user")->where("name", "access_test")->find();
+ $user = user::lookup_by_name("access_test");
if ($user->loaded) {
$user->delete();
}
@@ -307,7 +307,7 @@ class Access_Helper_Test extends Unit_Test_Case {
$group->save();
access::allow($group, "edit", $root);
- $user = ORM::factory("user", $user->id); // reload() does not flush related columns
+ $user = user::lookup($user->id); // reload() does not flush related columns
user::set_active($user);
// And verify that the user can edit.