Commit 2a4dc77a authored by mmn's avatar mmn

The overloaded DB_DataObject function staticGet is now called getKV

I used this hacky sed-command (run it from your GNU Social root, or change the first grep's path to where it actually lies) to do a rough fix on all ::staticGet calls and rename them to ::getKV

   sed -i -s -e '/DataObject::staticGet/I!s/::staticGet/::getKV/Ig' $(grep -R ::staticGet `pwd`/* | grep -v -e '^extlib' | grep -v DataObject:: |grep -v "function staticGet"|cut -d: -f1 |sort |uniq)

If you're applying this, remember to change the Managed_DataObject and Memcached_DataObject function definitions of staticGet to getKV!

This might of course take some getting used to, or modification fo StatusNet plugins, but the result is that all the static calls (to staticGet) are now properly made without breaking PHP Strict Standards. Standards are there to be followed (and they caused some very bad confusion when used with get_called_class)

Reasonably any plugin or code that tests for the definition of 'GNUSOCIAL' or similar will take this change into consideration.
parent e95f77d3
......@@ -94,7 +94,7 @@ class AddpeopletagAction extends Action
$tagged_id = $this->arg('tagged');
$this->tagged = Profile::staticGet('id', $tagged_id);
$this->tagged = Profile::getKV('id', $tagged_id);
if (empty($this->tagged)) {
// TRANS: Client error displayed trying to perform an action related to a non-existing profile.
......@@ -103,7 +103,7 @@ class AddpeopletagAction extends Action
}
$id = $this->arg('peopletag_id');
$this->peopletag = Profile_list::staticGet('id', $id);
$this->peopletag = Profile_list::getKV('id', $id);
if (empty($this->peopletag)) {
// TRANS: Client error displayed trying to reference a non-existing list.
......@@ -130,7 +130,7 @@ class AddpeopletagAction extends Action
$this->peopletag->tag);
if (!$ptag) {
$user = User::staticGet('id', $id);
$user = User::getKV('id', $id);
if ($user) {
$this->clientError(
// TRANS: Client error displayed when an unknown error occurs when adding a user to a list.
......
......@@ -62,7 +62,7 @@ class AllrssAction extends Rss10Action
{
parent::prepare($args);
$nickname = $this->trimmed('nickname');
$this->user = User::staticGet('nickname', $nickname);
$this->user = User::getKV('nickname', $nickname);
if (!$this->user) {
// TRANS: Client error when user not found for an rss related action.
......
......@@ -69,7 +69,7 @@ class ApiconversationAction extends ApiAuthAction
throw new ClientException(_('No conversation ID.'));
}
$this->conversation = Conversation::staticGet('id', $convId);
$this->conversation = Conversation::getKV('id', $convId);
if (empty($this->conversation)) {
// TRANS: Client exception thrown when referring to a non-existing conversation ID (%d).
......
......@@ -64,12 +64,12 @@ class ApiFavoriteCreateAction extends ApiAuthAction
parent::prepare($args);
$this->user = $this->auth_user;
$this->notice = Notice::staticGet($this->arg('id'));
$this->notice = Notice::getKV($this->arg('id'));
if ($this->notice->repeat_of != '' ) {
common_log(LOG_DEBUG, 'Trying to Fave '.$this->notice->id.', repeat of '.$this->notice->repeat_of);
common_log(LOG_DEBUG, 'Will Fave '.$this->notice->repeat_of.' instead');
$real_notice_id = $this->notice->repeat_of;
$this->notice = Notice::staticGet($real_notice_id);
$this->notice = Notice::getKV($real_notice_id);
}
return true;
......@@ -163,7 +163,7 @@ class ApiFavoriteCreateAction extends ApiAuthAction
*/
function notify($fave, $notice, $user)
{
$other = User::staticGet('id', $notice->profile_id);
$other = User::getKV('id', $notice->profile_id);
if ($other && $other->id != $user->id) {
if ($other->email && $other->emailnotifyfav) {
mail_notify_fave($other, $user, $notice);
......
......@@ -64,12 +64,12 @@ class ApiFavoriteDestroyAction extends ApiAuthAction
parent::prepare($args);
$this->user = $this->auth_user;
$this->notice = Notice::staticGet($this->arg('id'));
$this->notice = Notice::getKV($this->arg('id'));
if ($this->notice->repeat_of != '' ) {
common_log(LOG_DEBUG, 'Trying to unFave '.$this->notice->id);
common_log(LOG_DEBUG, 'Will unFave '.$this->notice->repeat_of.' instead');
$real_notice_id = $this->notice->repeat_of;
$this->notice = Notice::staticGet($real_notice_id);
$this->notice = Notice::getKV($real_notice_id);
}
return true;
......
......@@ -68,17 +68,17 @@ class ApiFriendshipsShowAction extends ApiBareAuthAction
$target_screen_name = $this->trimmed('target_screen_name');
if (!empty($source_id)) {
$this->source = User::staticGet($source_id);
$this->source = User::getKV($source_id);
} elseif (!empty($source_screen_name)) {
$this->source = User::staticGet('nickname', $source_screen_name);
$this->source = User::getKV('nickname', $source_screen_name);
} else {
$this->source = $this->auth_user;
}
if (!empty($target_id)) {
$this->target = User::staticGet($target_id);
$this->target = User::getKV($target_id);
} elseif (!empty($target_screen_name)) {
$this->target = User::staticGet('nickname', $target_screen_name);
$this->target = User::getKV('nickname', $target_screen_name);
}
return true;
......
......@@ -297,13 +297,13 @@ class ApiGroupCreateAction extends ApiAuthAction
*/
function groupNicknameExists($nickname)
{
$local = Local_group::staticGet('nickname', $nickname);
$local = Local_group::getKV('nickname', $nickname);
if (!empty($local)) {
return true;
}
$alias = Group_alias::staticGet('alias', $nickname);
$alias = Group_alias::getKV('alias', $nickname);
if (!empty($alias)) {
return true;
......
......@@ -198,7 +198,7 @@ class ApiGroupProfileUpdateAction extends ApiAuthAction
if (!empty($this->nickname) && ($this->nickname != $orig->nickname)) {
common_log(LOG_INFO, "Saving local group info.");
$local = Local_group::staticGet('group_id', $this->group->id);
$local = Local_group::getKV('group_id', $this->group->id);
$local->setNickname($this->nickname);
}
......@@ -220,14 +220,14 @@ class ApiGroupProfileUpdateAction extends ApiAuthAction
function nicknameExists($nickname)
{
$group = Local_group::staticGet('nickname', $nickname);
$group = Local_group::getKV('nickname', $nickname);
if (!empty($group) &&
$group->group_id != $this->group->id) {
return true;
}
$alias = Group_alias::staticGet('alias', $nickname);
$alias = Group_alias::getKV('alias', $nickname);
if (!empty($alias) &&
$alias->group_id != $this->group->id) {
......
......@@ -68,7 +68,7 @@ class ApiGroupShowAction extends ApiPrivateAuthAction
$this->group = $this->getTargetGroup($this->arg('id'));
if (empty($this->group)) {
$alias = Group_alias::staticGet(
$alias = Group_alias::getKV(
'alias',
common_canonical_nickname($this->arg('id'))
);
......
......@@ -126,7 +126,7 @@ class ApiSearchJSONAction extends ApiPrivateAuthAction
$stream = new TagNoticeStream(substr($q, 1), $this->auth_profile);
} else if ($this->isAnURL($q)) {
$canon = File_redirection::_canonUrl($q);
$file = File::staticGet('url', $canon);
$file = File::getKV('url', $canon);
if (!empty($file)) {
$stream = new FileNoticeStream($file, $this->auth_profile);
}
......
......@@ -77,7 +77,7 @@ class ApiStatusesDestroyAction extends ApiAuthAction
$this->notice_id = (int)$this->arg('id');
}
$this->notice = Notice::staticGet((int)$this->notice_id);
$this->notice = Notice::getKV((int)$this->notice_id);
return true;
}
......
......@@ -67,7 +67,7 @@ class ApiStatusesRetweetAction extends ApiAuthAction
$id = $this->trimmed('id');
$this->original = Notice::staticGet('id', $id);
$this->original = Notice::getKV('id', $id);
if (empty($this->original)) {
// TRANS: Client error displayed trying to repeat a non-existing notice through the API.
......
......@@ -63,7 +63,7 @@ class ApiStatusesRetweetsAction extends ApiAuthAction
$id = $this->trimmed('id');
$this->original = Notice::staticGet('id', $id);
$this->original = Notice::getKV('id', $id);
if (empty($this->original)) {
// TRANS: Client error displayed trying to display redents of a non-exiting notice.
......
......@@ -82,7 +82,7 @@ class ApiStatusesShowAction extends ApiPrivateAuthAction
$this->notice_id = (int)$this->arg('id');
}
$this->notice = Notice::staticGet((int)$this->notice_id);
$this->notice = Notice::getKV((int)$this->notice_id);
return true;
}
......@@ -147,7 +147,7 @@ class ApiStatusesShowAction extends ApiPrivateAuthAction
// XXX: Twitter just sets a 404 header and doens't bother
// to return an err msg
$deleted = Deleted_notice::staticGet($this->notice_id);
$deleted = Deleted_notice::getKV($this->notice_id);
if (!empty($deleted)) {
$this->clientError(
......
......@@ -254,7 +254,7 @@ class ApiStatusesUpdateAction extends ApiAuthAction
if (!empty($this->in_reply_to_status_id)) {
// Check whether notice actually exists
$reply = Notice::staticGet($this->in_reply_to_status_id);
$reply = Notice::getKV($this->in_reply_to_status_id);
if ($reply) {
$reply_to = $this->in_reply_to_status_id;
......
......@@ -414,7 +414,7 @@ class ApiTimelineUserAction extends ApiBareAuthAction
common_debug("Note ID is {$note->id}");
if (!empty($note->id)) {
$notice = Notice::staticGet('uri', trim($note->id));
$notice = Notice::getKV('uri', trim($note->id));
if (!empty($notice)) {
// TRANS: Client error displayed when using another format than AtomPub.
......@@ -445,7 +445,7 @@ class ApiTimelineUserAction extends ApiBareAuthAction
if (!empty($profile)) {
$options['replies'][] = $uri;
} else {
$group = User_group::staticGet('uri', $uri);
$group = User_group::getKV('uri', $uri);
if (!empty($group)) {
$options['groups'][] = $group->id;
} else {
......@@ -459,7 +459,7 @@ class ApiTimelineUserAction extends ApiBareAuthAction
// @fixme what about conversation ID?
if (!empty($activity->context->replyToID)) {
$orig = Notice::staticGet('uri',
$orig = Notice::getKV('uri',
$activity->context->replyToID);
if (!empty($orig)) {
$options['reply_to'] = $orig->id;
......
......@@ -56,7 +56,7 @@ class ApiUserProfileImageAction extends ApiPrivateAuthAction
function prepare($args)
{
parent::prepare($args);
$this->user = User::staticGet('nickname', $this->arg('screen_name'));
$this->user = User::getKV('nickname', $this->arg('screen_name'));
$this->size = $this->arg('size');
return true;
......
......@@ -68,7 +68,7 @@ class ApiUserShowAction extends ApiPrivateAuthAction
// XXX: email field deprecated in Twitter's API
if (!empty($email)) {
$this->user = User::staticGet('email', $email);
$this->user = User::getKV('email', $email);
} else {
$this->user = $this->getTargetUser($this->arg('id'));
}
......
......@@ -63,7 +63,7 @@ class ApprovegroupAction extends Action
$nickname_arg = $this->trimmed('nickname');
$id = intval($this->arg('id'));
if ($id) {
$this->group = User_group::staticGet('id', $id);
$this->group = User_group::getKV('id', $id);
} else if ($nickname_arg) {
$nickname = common_canonical_nickname($nickname_arg);
......@@ -75,7 +75,7 @@ class ApprovegroupAction extends Action
return false;
}
$local = Local_group::staticGet('nickname', $nickname);
$local = Local_group::getKV('nickname', $nickname);
if (!$local) {
// TRANS: Client error displayed when trying to leave a non-local group.
......@@ -83,7 +83,7 @@ class ApprovegroupAction extends Action
return false;
}
$this->group = User_group::staticGet('id', $local->group_id);
$this->group = User_group::getKV('id', $local->group_id);
} else {
// TRANS: Client error displayed when trying to leave a group without providing a group name or group ID.
$this->clientError(_('No nickname or ID.'), 404);
......@@ -104,7 +104,7 @@ class ApprovegroupAction extends Action
}
if ($this->arg('profile_id')) {
if ($cur->isAdmin($this->group)) {
$this->profile = Profile::staticGet('id', $this->arg('profile_id'));
$this->profile = Profile::getKV('id', $this->arg('profile_id'));
} else {
// TRANS: Client error displayed trying to approve group membership while not a group administrator.
$this->clientError(_('Only group admin can approve or cancel join requests.'), 403);
......
......@@ -61,7 +61,7 @@ class ApprovesubAction extends Action
return false;
}
if ($this->arg('profile_id')) {
$this->profile = Profile::staticGet('id', $this->arg('profile_id'));
$this->profile = Profile::getKV('id', $this->arg('profile_id'));
} else {
// TRANS: Client error displayed trying to approve subscriptionswithout specifying a profile to approve.
$this->clientError(_('Must specify a profile.'));
......
......@@ -62,7 +62,7 @@ class AtompubfavoritefeedAction extends ApiAuthAction
{
parent::prepare($argarray);
$this->_profile = Profile::staticGet('id', $this->trimmed('profile'));
$this->_profile = Profile::getKV('id', $this->trimmed('profile'));
if (empty($this->_profile)) {
// TRANS: Client exception thrown when requesting a favorite feed for a non-existing profile.
......@@ -251,7 +251,7 @@ class AtompubfavoritefeedAction extends ApiAuthAction
return;
}
$notice = Notice::staticGet('uri', $note->id);
$notice = Notice::getKV('uri', $note->id);
if (empty($notice)) {
// XXX: import from listed URL or something
......@@ -362,7 +362,7 @@ class AtompubfavoritefeedAction extends ApiAuthAction
*/
function notify($fave, $notice, $user)
{
$other = User::staticGet('id', $notice->profile_id);
$other = User::getKV('id', $notice->profile_id);
if ($other && $other->id != $user->id) {
if ($other->email && $other->emailnotifyfav) {
mail_notify_fave($other, $user, $notice);
......
......@@ -64,7 +64,7 @@ class AtompubmembershipfeedAction extends ApiAuthAction
$profileId = $this->trimmed('profile');
$this->_profile = Profile::staticGet('id', $profileId);
$this->_profile = Profile::getKV('id', $profileId);
if (empty($this->_profile)) {
// TRANS: Client exception.
......@@ -250,7 +250,7 @@ class AtompubmembershipfeedAction extends ApiAuthAction
return;
}
$group = User_group::staticGet('uri', $groupObj->id);
$group = User_group::getKV('uri', $groupObj->id);
if (empty($group)) {
// XXX: import from listed URL or something
......
......@@ -68,14 +68,14 @@ class AtompubshowfavoriteAction extends ApiAuthAction
$profileId = $this->trimmed('profile');
$noticeId = $this->trimmed('notice');
$this->_profile = Profile::staticGet('id', $profileId);
$this->_profile = Profile::getKV('id', $profileId);
if (empty($this->_profile)) {
// TRANS: Client exception.
throw new ClientException(_('No such profile.'), 404);
}
$this->_notice = Notice::staticGet('id', $noticeId);
$this->_notice = Notice::getKV('id', $noticeId);
if (empty($this->_notice)) {
// TRANS: Client exception thrown when referencing a non-existing notice.
......
......@@ -65,7 +65,7 @@ class AtompubshowmembershipAction extends ApiAuthAction
$profileId = $this->trimmed('profile');
$this->_profile = Profile::staticGet('id', $profileId);
$this->_profile = Profile::getKV('id', $profileId);
if (empty($this->_profile)) {
// TRANS: Client exception.
......@@ -74,7 +74,7 @@ class AtompubshowmembershipAction extends ApiAuthAction
$groupId = $this->trimmed('group');
$this->_group = User_group::staticGet('id', $groupId);
$this->_group = User_group::getKV('id', $groupId);
if (empty($this->_group)) {
// TRANS: Client exception thrown when referencing a non-existing group.
......
......@@ -64,7 +64,7 @@ class AtompubshowsubscriptionAction extends ApiAuthAction
parent::prepare($argarray);
$subscriberId = $this->trimmed('subscriber');
$this->_subscriber = Profile::staticGet('id', $subscriberId);
$this->_subscriber = Profile::getKV('id', $subscriberId);
if (empty($this->_subscriber)) {
// TRANS: Client exception thrown when trying to display a subscription for a non-existing profile ID.
......@@ -75,7 +75,7 @@ class AtompubshowsubscriptionAction extends ApiAuthAction
$subscribedId = $this->trimmed('subscribed');
$this->_subscribed = Profile::staticGet('id', $subscribedId);
$this->_subscribed = Profile::getKV('id', $subscribedId);
if (empty($this->_subscribed)) {
// TRANS: Client exception thrown when trying to display a subscription for a non-existing profile ID.
......
......@@ -66,7 +66,7 @@ class AtompubsubscriptionfeedAction extends ApiAuthAction
$subscriber = $this->trimmed('subscriber');
$this->_profile = Profile::staticGet('id', $subscriber);
$this->_profile = Profile::getKV('id', $subscriber);
if (empty($this->_profile)) {
// TRANS: Client exception thrown when trying to display a subscription for a non-existing profile ID.
......
......@@ -65,7 +65,7 @@ class AttachmentAction extends Action
parent::prepare($args);
if ($id = $this->trimmed('attachment')) {
$this->attachment = File::staticGet($id);
$this->attachment = File::getKV($id);
}
if (empty($this->attachment)) {
......
......@@ -71,7 +71,7 @@ class Attachment_thumbnailAction extends AttachmentAction
*/
function showCore()
{
$file_thumbnail = File_thumbnail::staticGet('file_id', $this->attachment->id);
$file_thumbnail = File_thumbnail::getKV('file_id', $this->attachment->id);
if (empty($file_thumbnail->url)) {
return;
}
......
......@@ -73,7 +73,7 @@ class AvatarbynicknameAction extends Action
return;
}
$user = User::staticGet('nickname', $nickname);
$user = User::getKV('nickname', $nickname);
if (!$user) {
// TRANS: Client error displayed trying to get an avatar for a non-existing user.
$this->clientError(_('No such user.'));
......
......@@ -74,7 +74,7 @@ class BlockedfromgroupAction extends GroupAction
return false;
}
$local = Local_group::staticGet('nickname', $nickname);
$local = Local_group::getKV('nickname', $nickname);
if (!$local) {
// TRANS: Client error displayed when requesting a list of blocked users for a non-local group.
......@@ -82,7 +82,7 @@ class BlockedfromgroupAction extends GroupAction
return false;
}
$this->group = User_group::staticGet('id', $local->group_id);
$this->group = User_group::getKV('id', $local->group_id);
if (!$this->group) {
// TRANS: Client error displayed when requesting a list of blocked users for a non-existing group.
......
......@@ -63,7 +63,7 @@ class CancelgroupAction extends Action
$nickname_arg = $this->trimmed('nickname');
$id = intval($this->arg('id'));
if ($id) {
$this->group = User_group::staticGet('id', $id);
$this->group = User_group::getKV('id', $id);
} else if ($nickname_arg) {
$nickname = common_canonical_nickname($nickname_arg);
......@@ -74,7 +74,7 @@ class CancelgroupAction extends Action
return false;
}
$local = Local_group::staticGet('nickname', $nickname);
$local = Local_group::getKV('nickname', $nickname);
if (!$local) {
// TRANS: Client error displayed when trying to leave a non-local group.
......@@ -82,7 +82,7 @@ class CancelgroupAction extends Action
return false;
}
$this->group = User_group::staticGet('id', $local->group_id);
$this->group = User_group::getKV('id', $local->group_id);
} else {
// TRANS: Client error displayed when trying to leave a group without providing a group name or group ID.
$this->clientError(_('No nickname or ID.'), 404);
......@@ -103,7 +103,7 @@ class CancelgroupAction extends Action
}
if ($this->arg('profile_id')) {
if ($cur->isAdmin($this->group)) {
$this->profile = Profile::staticGet('id', $this->arg('profile_id'));
$this->profile = Profile::getKV('id', $this->arg('profile_id'));
} else {
// TRANS: Client error displayed when trying to approve or cancel a group join request without
// TRANS: being a group administrator.
......
......@@ -85,7 +85,7 @@ class CancelsubscriptionAction extends Action
return;
}
$other = Profile::staticGet('id', $other_id);
$other = Profile::getKV('id', $other_id);
if (!$other) {
// TRANS: Client error displayed when trying to leave a non-existing group.
......
......@@ -74,7 +74,7 @@ class ConfirmaddressAction extends Action
$this->clientError(_('No confirmation code.'));
return;
}
$confirm = Confirm_address::staticGet('code', $code);
$confirm = Confirm_address::getKV('code', $code);
if (!$confirm) {
// TRANS: Client error displayed when providing a non-existing confirmation code in the contact address confirmation action.
$this->clientError(_('Confirmation code not found.'));
......@@ -110,7 +110,7 @@ class ConfirmaddressAction extends Action
if ($type == 'sms') {
$cur->carrier = ($confirm->address_extra)+0;
$carrier = Sms_carrier::staticGet($cur->carrier);
$carrier = Sms_carrier::getKV($cur->carrier);
$cur->smsemail = $carrier->toEmailAddress($cur->sms);
}
......
......@@ -64,7 +64,7 @@ class DeleteapplicationAction extends Action
}
$id = (int)$this->arg('id');
$this->app = Oauth_application::staticGet('id', $id);
$this->app = Oauth_application::getKV('id', $id);
if (empty($this->app)) {
// TRANS: Client error displayed trying to delete an application that does not exist.
......
......@@ -68,7 +68,7 @@ class DeletegroupAction extends RedirectingAction
$nickname_arg = $this->trimmed('nickname');
$id = intval($this->arg('id'));
if ($id) {
$this->group = User_group::staticGet('id', $id);
$this->group = User_group::getKV('id', $id);
} else if ($nickname_arg) {
$nickname = common_canonical_nickname($nickname_arg);
......@@ -80,7 +80,7 @@ class DeletegroupAction extends RedirectingAction
return false;
}