From 6c4c4319ef8c8b181b96b0f97b2217d75d6c4d92 Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Mon, 12 Aug 2013 20:00:01 +0200 Subject: [PATCH] Plugins with classes that extend Managed_DataObject get better code reuse The switch to having a function in Managed_DataObject is now being applied to plugins which can use this as well. There are some plugins that still use Memcached_DataObject, but these will be taken care of later. --- plugins/ActivitySpam/Spam_score.php | 14 -------------- plugins/Blog/Blog_entry.php | 5 ----- plugins/EmailReminder/classes/Email_reminder.php | 15 --------------- plugins/Event/Happening.php | 14 -------------- plugins/Event/RSVP.php | 13 ------------- .../ExtendedProfile/classes/Profile_detail.php | 16 ---------------- plugins/GNUsocialPhoto/Photo.php | 5 ----- plugins/GNUsocialVideo/Video.php | 5 ----- plugins/ModLog/ModLog.php | 14 -------------- plugins/OStatus/classes/Ostatus_profile.php | 5 ----- plugins/OpenID/User_openid_prefs.php | 16 ---------------- plugins/Poll/Poll.php | 16 ---------------- plugins/Poll/Poll_response.php | 16 ---------------- plugins/Poll/User_poll_prefs.php | 16 ---------------- plugins/QnA/classes/QnA_Answer.php | 16 ---------------- plugins/QnA/classes/QnA_Question.php | 16 ---------------- plugins/QnA/classes/QnA_Vote.php | 16 ---------------- plugins/Realtime/Realtime_channel.php | 15 --------------- plugins/SearchSub/SearchSub.php | 16 ---------------- plugins/TagSub/TagSub.php | 16 ---------------- 20 files changed, 265 deletions(-) diff --git a/plugins/ActivitySpam/Spam_score.php b/plugins/ActivitySpam/Spam_score.php index 997a9f83ad..dd7209f594 100644 --- a/plugins/ActivitySpam/Spam_score.php +++ b/plugins/ActivitySpam/Spam_score.php @@ -53,20 +53,6 @@ class Spam_score extends Managed_DataObject public $score; // float public $created; // datetime - /** - * Get an instance by key - * - * @param string $k Key to use to lookup (usually 'notice_id' for this class) - * @param mixed $v Value to lookup - * - * @return Spam_score object found, or null for no hits - * - */ - function staticGet($k, $v=null) - { - return Managed_DataObject::staticGet('Spam_score', $k, $v); - } - function saveNew($notice, $result) { $score = new Spam_score(); diff --git a/plugins/Blog/Blog_entry.php b/plugins/Blog/Blog_entry.php index b40039b2d7..4d1820936f 100644 --- a/plugins/Blog/Blog_entry.php +++ b/plugins/Blog/Blog_entry.php @@ -60,11 +60,6 @@ class Blog_entry extends Managed_DataObject public $modified; // datetime const TYPE = ActivityObject::ARTICLE; - - function staticGet($k, $v=null) - { - return Managed_DataObject::staticGet('Blog_entry', $k, $v); - } static function schemaDef() { diff --git a/plugins/EmailReminder/classes/Email_reminder.php b/plugins/EmailReminder/classes/Email_reminder.php index 29af05a915..235305f047 100644 --- a/plugins/EmailReminder/classes/Email_reminder.php +++ b/plugins/EmailReminder/classes/Email_reminder.php @@ -37,21 +37,6 @@ class Email_reminder extends Managed_DataObject public $created; // timestamp public $modified; // timestamp - /** - * Get an instance by key - * - * This is a utility method to get a single instance with a given key value. - * - * @param string $k Key to use to lookup - * @param mixed $v Value to lookup - * - * @return QnA_Answer object found, or null for no hits - */ - function staticGet($k, $v=null) - { - return Memcached_DataObject::staticGet('email_reminder', $k, $v); - } - /** * Do we need to send a reminder? * diff --git a/plugins/Event/Happening.php b/plugins/Event/Happening.php index b8347bdb2c..52aa206435 100644 --- a/plugins/Event/Happening.php +++ b/plugins/Event/Happening.php @@ -63,20 +63,6 @@ class Happening extends Managed_DataObject public $description; // text public $created; // datetime - /** - * Get an instance by key - * - * @param string $k Key to use to lookup (usually 'id' for this class) - * @param mixed $v Value to lookup - * - * @return Happening object found, or null for no hits - * - */ - function staticGet($k, $v=null) - { - return Memcached_DataObject::staticGet('Happening', $k, $v); - } - /** * The One True Thingy that must be defined and declared. */ diff --git a/plugins/Event/RSVP.php b/plugins/Event/RSVP.php index 1f47958e9a..3220661354 100644 --- a/plugins/Event/RSVP.php +++ b/plugins/Event/RSVP.php @@ -56,19 +56,6 @@ class RSVP extends Managed_DataObject public $response; // tinyint public $created; // datetime - /** - * Get an instance by key - * - * @param string $k Key to use to lookup (usually 'id' for this class) - * @param mixed $v Value to lookup - * - * @return RSVP object found, or null for no hits - */ - function staticGet($k, $v=null) - { - return Memcached_DataObject::staticGet('RSVP', $k, $v); - } - /** * Get an instance by compound key * diff --git a/plugins/ExtendedProfile/classes/Profile_detail.php b/plugins/ExtendedProfile/classes/Profile_detail.php index 94e52c396c..5335786ef9 100644 --- a/plugins/ExtendedProfile/classes/Profile_detail.php +++ b/plugins/ExtendedProfile/classes/Profile_detail.php @@ -69,22 +69,6 @@ class Profile_detail extends Managed_DataObject public $created; public $modified; - /** - * Get an instance by key - * - * This is a utility method to get a single instance with a given key value. - * - * @param string $k Key to use to lookup - * @param mixed $v Value to lookup - * - * @return User_greeting_count object found, or null for no hits - * - */ - function staticGet($k, $v=null) - { - return Memcached_DataObject::staticGet('Profile_detail', $k, $v); - } - /** * Get an instance by compound key * diff --git a/plugins/GNUsocialPhoto/Photo.php b/plugins/GNUsocialPhoto/Photo.php index f6d932a300..2bbbe91fd5 100644 --- a/plugins/GNUsocialPhoto/Photo.php +++ b/plugins/GNUsocialPhoto/Photo.php @@ -45,11 +45,6 @@ class Photo extends Managed_DataObject public $title; // varchar (255) public $description; // text public $profile_id; // int - - public function staticGet($k, $v=null) - { - return Memcached_DataObject::staticGet('photo', $k, $v); - } public function getByNotice($notice) { diff --git a/plugins/GNUsocialVideo/Video.php b/plugins/GNUsocialVideo/Video.php index 73e240c470..7525b22fe5 100644 --- a/plugins/GNUsocialVideo/Video.php +++ b/plugins/GNUsocialVideo/Video.php @@ -42,11 +42,6 @@ class Video extends Managed_DataObject public $uri; // varchar (255) // This is the corresponding notice's uri. public $url; // varchar (255) public $profile_id; // int - - public function staticGet($k, $v=null) - { - return Memcached_DataObject::staticGet('Video', $k, $v); - } public function getByNotice($notice) { diff --git a/plugins/ModLog/ModLog.php b/plugins/ModLog/ModLog.php index b2c6546838..ff2588cfdb 100644 --- a/plugins/ModLog/ModLog.php +++ b/plugins/ModLog/ModLog.php @@ -55,20 +55,6 @@ class ModLog extends Managed_DataObject public $grant; // 1 = grant, 0 = revoke public $created; // datetime - /** - * Get an instance by key - * - * @param string $k Key to use to lookup (usually 'user_id' for this class) - * @param mixed $v Value to lookup - * - * @return TagSub object found, or null for no hits - * - */ - function staticGet($k, $v=null) - { - return Managed_DataObject::staticGet('ModLog', $k, $v); - } - /** * Get an instance by compound key * diff --git a/plugins/OStatus/classes/Ostatus_profile.php b/plugins/OStatus/classes/Ostatus_profile.php index 661b7fe3f7..47817f2873 100644 --- a/plugins/OStatus/classes/Ostatus_profile.php +++ b/plugins/OStatus/classes/Ostatus_profile.php @@ -42,11 +42,6 @@ class Ostatus_profile extends Managed_DataObject public $created; public $modified; - public /*static*/ function staticGet($k, $v=null) - { - return parent::staticGet(__CLASS__, $k, $v); - } - /** * Return table definition for Schema setup and DB_DataObject usage. * diff --git a/plugins/OpenID/User_openid_prefs.php b/plugins/OpenID/User_openid_prefs.php index 74a21f685e..fcd88f4541 100644 --- a/plugins/OpenID/User_openid_prefs.php +++ b/plugins/OpenID/User_openid_prefs.php @@ -53,22 +53,6 @@ class User_openid_prefs extends Managed_DataObject public $created; // datetime public $modified; // datetime - /** - * Get an instance by key - * - * This is a utility method to get a single instance with a given key value. - * - * @param string $k Key to use to lookup (usually 'user_id' for this class) - * @param mixed $v Value to lookup - * - * @return TagSub object found, or null for no hits - * - */ - function staticGet($k, $v=null) - { - return Managed_DataObject::staticGet('User_openid_prefs', $k, $v); - } - /** * The One True Thingy that must be defined and declared. */ diff --git a/plugins/Poll/Poll.php b/plugins/Poll/Poll.php index 399d492406..f9155def4a 100644 --- a/plugins/Poll/Poll.php +++ b/plugins/Poll/Poll.php @@ -53,22 +53,6 @@ class Poll extends Managed_DataObject public $options; // text; newline(?)-delimited public $created; // datetime - /** - * Get an instance by key - * - * This is a utility method to get a single instance with a given key value. - * - * @param string $k Key to use to lookup (usually 'user_id' for this class) - * @param mixed $v Value to lookup - * - * @return User_greeting_count object found, or null for no hits - * - */ - function staticGet($k, $v=null) - { - return Memcached_DataObject::staticGet('Poll', $k, $v); - } - /** * Get an instance by compound key * diff --git a/plugins/Poll/Poll_response.php b/plugins/Poll/Poll_response.php index 2518ac2beb..a63d790b53 100644 --- a/plugins/Poll/Poll_response.php +++ b/plugins/Poll/Poll_response.php @@ -52,22 +52,6 @@ class Poll_response extends Managed_DataObject public $selection; // int -> choice # public $created; // datetime - /** - * Get an instance by key - * - * This is a utility method to get a single instance with a given key value. - * - * @param string $k Key to use to lookup (usually 'user_id' for this class) - * @param mixed $v Value to lookup - * - * @return User_greeting_count object found, or null for no hits - * - */ - function staticGet($k, $v=null) - { - return Memcached_DataObject::staticGet('Poll_response', $k, $v); - } - /** * Get an instance by compound key * diff --git a/plugins/Poll/User_poll_prefs.php b/plugins/Poll/User_poll_prefs.php index 338e811948..450a6b9cfb 100644 --- a/plugins/Poll/User_poll_prefs.php +++ b/plugins/Poll/User_poll_prefs.php @@ -50,22 +50,6 @@ class User_poll_prefs extends Managed_DataObject public $created; // datetime public $modified; // datetime - /** - * Get an instance by key - * - * This is a utility method to get a single instance with a given key value. - * - * @param string $k Key to use to lookup (usually 'user_id' for this class) - * @param mixed $v Value to lookup - * - * @return User_greeting_count object found, or null for no hits - * - */ - function staticGet($k, $v=null) - { - return Memcached_DataObject::staticGet('User_poll_prefs', $k, $v); - } - /** * The One True Thingy that must be defined and declared. */ diff --git a/plugins/QnA/classes/QnA_Answer.php b/plugins/QnA/classes/QnA_Answer.php index 7f92e47c61..0d34f6baf8 100644 --- a/plugins/QnA/classes/QnA_Answer.php +++ b/plugins/QnA/classes/QnA_Answer.php @@ -55,22 +55,6 @@ class QnA_Answer extends Managed_DataObject public $content; // text -> response text public $created; // datetime - /** - * Get an instance by key - * - * This is a utility method to get a single instance with a given key value. - * - * @param string $k Key to use to lookup - * @param mixed $v Value to lookup - * - * @return QnA_Answer object found, or null for no hits - * - */ - function staticGet($k, $v=null) - { - return Memcached_DataObject::staticGet('QnA_Answer', $k, $v); - } - /** * Get an instance by compound key * diff --git a/plugins/QnA/classes/QnA_Question.php b/plugins/QnA/classes/QnA_Question.php index 820656870b..e1713b4660 100644 --- a/plugins/QnA/classes/QnA_Question.php +++ b/plugins/QnA/classes/QnA_Question.php @@ -55,22 +55,6 @@ class QnA_Question extends Managed_DataObject public $closed; // int (boolean) whether a question is closed public $created; // datetime - /** - * Get an instance by key - * - * This is a utility method to get a single instance with a given key value. - * - * @param string $k Key to use to lookup - * @param mixed $v Value to lookup - * - * @return QnA_Question object found, or null for no hits - * - */ - function staticGet($k, $v=null) - { - return Memcached_DataObject::staticGet('QnA_Question', $k, $v); - } - /** * Get an instance by compound key * diff --git a/plugins/QnA/classes/QnA_Vote.php b/plugins/QnA/classes/QnA_Vote.php index cbb8a717c9..025f6b0c6b 100644 --- a/plugins/QnA/classes/QnA_Vote.php +++ b/plugins/QnA/classes/QnA_Vote.php @@ -55,22 +55,6 @@ class QnA_Vote extends Managed_DataObject public $profile_id; // int -> question.id public $created; // datetime - /** - * Get an instance by key - * - * This is a utility method to get a single instance with a given key value. - * - * @param string $k Key to use to lookup - * @param mixed $v Value to lookup - * - * @return QnA_Vote object found, or null for no hits - * - */ - function staticGet($k, $v=null) - { - return Memcached_DataObject::staticGet('QnA_Vote', $k, $v); - } - /** * Get an instance by compound key * diff --git a/plugins/Realtime/Realtime_channel.php b/plugins/Realtime/Realtime_channel.php index 1d2ca53912..3538e884a0 100644 --- a/plugins/Realtime/Realtime_channel.php +++ b/plugins/Realtime/Realtime_channel.php @@ -61,21 +61,6 @@ class Realtime_channel extends Managed_DataObject public $created; // created date public $modified; // modified date - /** - * Get an instance by key - * - * This is a utility method to get a single instance with a given key value. - * - * @param string $k Key to use to lookup (usually 'user_id' for this class) - * @param mixed $v Value to lookup - * - * @return Realtime_channel object found, or null for no hits - */ - function staticGet($k, $v=null) - { - return Managed_DataObject::staticGet('Realtime_channel', $k, $v); - } - /** * Get an instance by compound key * diff --git a/plugins/SearchSub/SearchSub.php b/plugins/SearchSub/SearchSub.php index 7e9a94caa9..246720b6a5 100644 --- a/plugins/SearchSub/SearchSub.php +++ b/plugins/SearchSub/SearchSub.php @@ -50,22 +50,6 @@ class SearchSub extends Managed_DataObject public $profile_id; // int -> profile.id public $created; // datetime - /** - * Get an instance by key - * - * This is a utility method to get a single instance with a given key value. - * - * @param string $k Key to use to lookup (usually 'user_id' for this class) - * @param mixed $v Value to lookup - * - * @return SearchSub object found, or null for no hits - * - */ - function staticGet($k, $v=null) - { - return Memcached_DataObject::staticGet('SearchSub', $k, $v); - } - /** * Get an instance by compound key * diff --git a/plugins/TagSub/TagSub.php b/plugins/TagSub/TagSub.php index c0c4c1ec86..b917786540 100644 --- a/plugins/TagSub/TagSub.php +++ b/plugins/TagSub/TagSub.php @@ -49,22 +49,6 @@ class TagSub extends Managed_DataObject public $profile_id; // int -> profile.id public $created; // datetime - /** - * Get an instance by key - * - * This is a utility method to get a single instance with a given key value. - * - * @param string $k Key to use to lookup (usually 'user_id' for this class) - * @param mixed $v Value to lookup - * - * @return TagSub object found, or null for no hits - * - */ - function staticGet($k, $v=null) - { - return Memcached_DataObject::staticGet('TagSub', $k, $v); - } - /** * Get an instance by compound key *