diff --git a/classes/Avatar.php b/classes/Avatar.php index 8cff14273c..aed6ea0dd2 100644 --- a/classes/Avatar.php +++ b/classes/Avatar.php @@ -22,11 +22,6 @@ class Avatar extends Managed_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE - - static function pivotGet($keyCol, $keyVals, $otherCols) - { - return Memcached_DataObject::pivotGet('Avatar', $keyCol, $keyVals, $otherCols); - } public static function schemaDef() { diff --git a/classes/Managed_DataObject.php b/classes/Managed_DataObject.php index d173deff24..4ec8de669d 100644 --- a/classes/Managed_DataObject.php +++ b/classes/Managed_DataObject.php @@ -61,6 +61,20 @@ abstract class Managed_DataObject extends Memcached_DataObject return parent::pkeyGetClass(get_called_class(), $kv); } + /** + * Get multiple items from the database by key + * + * @param string $keyCol name of column for key + * @param array $keyVals key values to fetch + * @param array $otherCols Other columns to hold fixed + * + * @return array Array mapping $keyVals to objects, or null if not found + */ + static function pivotGet($keyCol, array $keyVals, array $otherCols=array()) + { + return parent::pivotGetClass(get_called_class(), $keyCol, $keyVals, $otherCols); + } + /** * Get a multi-instance object * diff --git a/classes/Memcached_DataObject.php b/classes/Memcached_DataObject.php index aa3a70395f..262f83b83c 100644 --- a/classes/Memcached_DataObject.php +++ b/classes/Memcached_DataObject.php @@ -76,7 +76,7 @@ class Memcached_DataObject extends Safe_DataObject */ function multiGet($cls, $keyCol, $keyVals, $skipNulls=true) { - $result = self::pivotGet($cls, $keyCol, $keyVals); + $result = self::pivotGetClass($cls, $keyCol, $keyVals); $values = array_values($result); @@ -103,7 +103,7 @@ class Memcached_DataObject extends Safe_DataObject * * @return array Array mapping $keyVals to objects, or null if not found */ - static function pivotGet($cls, $keyCol, $keyVals, $otherCols = array()) + static function pivotGetClass($cls, $keyCol, array $keyVals, array $otherCols = array()) { if (!is_a($cls, __CLASS__, true)) { throw new Exception('Trying to fetch ' . __CLASS__ . ' into a non-related class'); @@ -292,7 +292,7 @@ class Memcached_DataObject extends Safe_DataObject } if (count($allPkeys) > 0) { - $keyResults = self::pivotGet($cls, $pkeyCols, $allPkeys); + $keyResults = self::pivotGetClass($cls, $pkeyCols, $allPkeys); foreach ($pkeyMap as $keyVal => $pkeyList) { foreach ($pkeyList as $pkeyVal) { diff --git a/classes/Notice.php b/classes/Notice.php index 4f78343798..e71b63ba47 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -2600,7 +2600,7 @@ class Notice extends Managed_DataObject $ids = array_unique($ids); - return Memcached_DataObject::pivotGet('Profile', 'id', $ids); + return Profile::pivotGet('id', $ids); } static function fillGroups(&$notices) @@ -2621,7 +2621,7 @@ class Notice extends Managed_DataObject $gids = array_unique($gids); - $group = Memcached_DataObject::pivotGet('User_group', 'id', $gids); + $group = User_group::pivotGet('id', $gids); foreach ($notices as $notice) { @@ -2660,7 +2660,7 @@ class Notice extends Managed_DataObject $fileIds = array_unique($fileIds); - $fileMap = Memcached_DataObject::pivotGet('File', 'id', $fileIds); + $fileMap = File::pivotGet('id', $fileIds); foreach ($notices as $notice) { diff --git a/classes/Profile.php b/classes/Profile.php index 93eb41bdcb..c8f44c007b 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -1494,8 +1494,4 @@ class Profile extends Managed_DataObject { return $this; } - - static function pivotGet($key, $values, $otherCols=array()) { - return Memcached_DataObject::pivotGet('Profile', $key, $values, $otherCols); - } } diff --git a/lib/inboxnoticestream.php b/lib/inboxnoticestream.php index fee0e8a096..27fec9518b 100644 --- a/lib/inboxnoticestream.php +++ b/lib/inboxnoticestream.php @@ -144,7 +144,7 @@ class RawInboxNoticeStream extends NoticeStream $ids = $this->getNoticeIds($offset, $limit, $sinceId, $maxId); - $notices = Memcached_DataObject::pivotGet('Notice', 'id', $ids); + $notices = Notice::pivotGet('id', $ids); // By default, takes out false values diff --git a/lib/noticelist.php b/lib/noticelist.php index 7f38cf005b..c242417e5a 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -147,8 +147,8 @@ class NoticeList extends Widget $ids[] = $notice->id; } - Memcached_DataObject::pivotGet('Fave', 'notice_id', $ids, array('user_id' => $p->id)); - Memcached_DataObject::pivotGet('Notice', 'repeat_of', $ids, array('profile_id' => $p->id)); + Fave::pivotGet('notice_id', $ids, array('user_id' => $p->id)); + Notice::pivotGet('repeat_of', $ids, array('profile_id' => $p->id)); } Event::handle('EndNoticeListPrefill', array(&$notices, &$profiles, $avatarSize)); diff --git a/lib/scopingnoticestream.php b/lib/scopingnoticestream.php index 9a101fa3ac..c1651d5a30 100644 --- a/lib/scopingnoticestream.php +++ b/lib/scopingnoticestream.php @@ -89,10 +89,9 @@ class ScopingNoticeStream extends FilteringNoticeStream $pids[] = $profile->id; } - Memcached_DataObject::pivotGet('Profile_role', - 'profile_id', - $pids, - array('role' => Profile_role::SILENCED)); + Profile_role::pivotGet('profile_id', + $pids, + array('role' => Profile_role::SILENCED)); } } }