Cosmetic changes to common_redirect, clientError, serverError

Since these functions exit (or throw exception) after running, there
is no need to have a 'return' statement or similar afterwards.
This commit is contained in:
Mikael Nordfeldth
2014-03-10 00:19:35 +01:00
parent acbe94936f
commit c00491cd7a
132 changed files with 20 additions and 472 deletions

View File

@@ -58,7 +58,6 @@ class AnonDisfavorAction extends RedirectingAction
// TRANS: Client error.
_m('Could not disfavor notice! Please make sure your browser has cookies enabled.')
);
return;
}
$id = $this->trimmed('notice');
@@ -79,7 +78,6 @@ class AnonDisfavorAction extends RedirectingAction
common_log_db_error($fave, 'DELETE', __FILE__);
// TRANS: Server error.
$this->serverError(_m('Could not delete favorite.'));
return;
}
$profile->blowFavesCache();

View File

@@ -55,9 +55,7 @@ class AnonFavorAction extends RedirectingAction
if (empty($profile) || $_SERVER['REQUEST_METHOD'] != 'POST') {
// TRANS: Client error.
$this->clientError(_m('Could not favor notice! Please make sure your browser has cookies enabled.')
);
return;
$this->clientError(_m('Could not favor notice! Please make sure your browser has cookies enabled.'));
}
$id = $this->trimmed('notice');
@@ -67,14 +65,12 @@ class AnonFavorAction extends RedirectingAction
if ($profile->hasFave($notice)) {
// TRANS: Client error.
$this->clientError(_m('This notice is already a favorite!'));
return;
}
$fave = Fave::addNew($profile, $notice);
if (!$fave) {
// TRANS: Server error.
$this->serverError(_m('Could not create favorite.'));
return;
}
$profile->blowFavesCache();

View File

@@ -294,7 +294,6 @@ class BookmarkPlugin extends MicroAppPlugin
if (!$this->user) {
// TRANS: Client error displayed when trying to display bookmarks for a non-existing user.
$this->clientError(_('No such user.'));
return false;
}
$action->menuItem(common_local_url('bookmarks', array('nickname' => $this->user->nickname)),

View File

@@ -66,7 +66,6 @@ class ApiTimelineBookmarksAction extends ApiBareAuthAction
if (empty($this->user)) {
// TRANS: Client error displayed when requesting most recent favourite notices by a user for a non-existing user.
$this->clientError(_('No such user.'), 404, $this->format);
return;
}
$this->notices = $this->getNotices();
@@ -172,7 +171,6 @@ class ApiTimelineBookmarksAction extends ApiBareAuthAction
default:
// TRANS: Client error displayed when coming across a non-supported API method.
$this->clientError(_('API method not found.'), $code = 404);
break;
}
}

View File

@@ -80,7 +80,6 @@ class BookmarksAction extends Action
if (!$this->user) {
// TRANS: Client error displayed when trying to display bookmarks for a non-existing user.
$this->clientError(_('No such user.'));
return false;
}
$this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;

View File

@@ -71,7 +71,6 @@ class BookmarksrssAction extends Rss10Action
if (!$this->user) {
// TRANS: Client error displayed when trying to get the RSS feed with bookmarks of a user that does not exist.
$this->clientError(_('No such user.'));
return false;
} else {
$this->notices = $this->getNotices($this->limit);
return true;

View File

@@ -39,14 +39,12 @@ class CasloginAction extends Action
if (!$user) {
// TRANS: Server error displayed when trying to log in with incorrect username or password.
$this->serverError(_m('Incorrect username or password.'));
return;
}
// success!
if (!common_set_user($user)) {
// TRANS: Server error displayed when login fails in CAS authentication plugin.
$this->serverError(_m('Error setting user. You are probably not authorized.'));
return;
}
common_real_login(true);

View File

@@ -191,7 +191,6 @@ class EmailregisterAction extends Action
if (!empty($cur)) {
common_redirect(common_local_url('all', array('nickname' => $cur->nickname)));
return;
}
switch ($this->state) {

View File

@@ -63,7 +63,6 @@ class TimelistAction extends Action {
if (!common_logged_in()) {
// TRANS: Error message displayed when trying to perform an action that requires a logged in user.
$this->clientError(_m('Not logged in.'));
return;
}
if (!empty($this->start)) {
@@ -71,7 +70,6 @@ class TimelistAction extends Action {
} else {
// TRANS: Client error when submitting a form with unexpected information.
$this->clientError(_m('Unexpected form submission.'));
return;
}
if ($this->boolean('ajax')) {

View File

@@ -620,7 +620,6 @@ class ProfileDetailSettingsAction extends ProfileSettingsAction
common_log_db_error($profile, 'UPDATE', __FILE__);
// TRANS: Server error thrown when user profile settings could not be saved.
$this->serverError(_m('Could not save profile.'));
return;
}
// Set the user tags
@@ -629,7 +628,6 @@ class ProfileDetailSettingsAction extends ProfileSettingsAction
if (!$result) {
// TRANS: Server error thrown when user profile settings tags could not be saved.
$this->serverError(_m('Could not save tags.'));
return;
}
Event::handle('EndProfileSaveForm', array($this));

View File

@@ -414,7 +414,6 @@ ENDOFSCRIPT;
$action->logout();
common_redirect($logoutUrl, 303);
return false; // probably never get here, but hey
}
return true;

View File

@@ -48,7 +48,6 @@ class FacebookfinishloginAction extends Action
if (empty($this->accessToken)) {
$this->clientError(_m("Unable to authenticate you with Facebook."));
return false;
}
$graphUrl = 'https://graph.facebook.com/me?access_token=' . urlencode($this->accessToken);
@@ -117,8 +116,6 @@ class FacebookfinishloginAction extends Action
// TRANS: in the same StatusNet site.
_m('There is already a local account linked with that Facebook account.')
);
return;
}
$cur = common_current_user();
@@ -133,8 +130,6 @@ class FacebookfinishloginAction extends Action
// TRANS: in the same StatusNet site.
_m('There is already a local account linked with that Facebook account.')
);
return;
}
}
@@ -329,7 +324,6 @@ class FacebookfinishloginAction extends Action
if (common_config('site', 'closed')) {
// TRANS: Client error trying to register with registrations not allowed.
$this->clientError(_m('Registration not allowed.'));
return;
}
$invite = null;
@@ -339,7 +333,6 @@ class FacebookfinishloginAction extends Action
if (empty($code)) {
// TRANS: Client error trying to register with registrations 'invite only'.
$this->clientError(_m('Registration not allowed.'));
return;
}
$invite = Invitation::getKV($code);
@@ -347,7 +340,6 @@ class FacebookfinishloginAction extends Action
if (empty($invite)) {
// TRANS: Client error trying to register with an invalid invitation code.
$this->clientError(_m('Not a valid invitation code.'));
return;
}
}
@@ -384,7 +376,6 @@ class FacebookfinishloginAction extends Action
if (!$result) {
// TRANS: Server error displayed when connecting to Facebook fails.
$this->serverError(_m('Error connecting user to Facebook.'));
return;
}
// Add a Foreign_user record
@@ -518,7 +509,6 @@ class FacebookfinishloginAction extends Action
if (empty($result)) {
// TRANS: Server error displayed when connecting to Facebook fails.
$this->serverError(_m('Error connecting user to Facebook.'));
return;
}
}

View File

@@ -261,7 +261,6 @@ class FacebooksettingsAction extends SettingsAction {
common_log_db_error($user, 'DELETE', __FILE__);
// TRANS: Server error displayed when deleting the link to a Facebook account fails.
$this->serverError(_m('Could not delete link to Facebook.'));
return;
}
// TRANS: Confirmation message. StatusNet account was unlinked from Facebook.

View File

@@ -63,14 +63,12 @@ class ProfilefieldsAdminPanelAction extends AdminPanelAction
$field->systemname = $this->trimmed('systemname');
if (!gnusocial_field_systemname_validate($field->systemname)) {
$this->clientError(_('Internal system name must be unique and consist of only alphanumeric characters!'));
return false;
}
if ($field->id) {
if ($field->validate())
$field->update();
else {
$this->clientError(_('There was an error with the field data.'));
return false;
}
}
else {

View File

@@ -73,7 +73,6 @@ class GroupinboxAction extends GroupAction
if ($nickname != $nicknameArg) {
$url = common_local_url('groupinbox', array('nickname' => $nickname));
common_redirect($url);
return false;
}
$localGroup = Local_group::getKV('nickname', $nickname);

View File

@@ -81,7 +81,6 @@ class NewgroupmessageAction extends Action
if ($nickname != $nicknameArg) {
$url = common_local_url('newgroupmessage', array('nickname' => $nickname));
common_redirect($url, 301);
return false;
}
$localGroup = Local_group::getKV('nickname', $nickname);

View File

@@ -245,7 +245,6 @@ class IrcManager extends ImManager {
common_log_db_error($confirm, 'DELETE', __FILE__);
// TRANS: Server error thrown on database error when deleting IRC nickname confirmation.
$this->serverError(_m('Could not delete confirmation.'));
return;
}
}
}

View File

@@ -63,7 +63,6 @@ class MapAction extends Action
$args['page'] = $this->arg['page'];
}
common_redirect(common_local_url($this->trimmed('action'), $args), 301);
return false;
}
$this->user = User::getKV('nickname', $nickname);
@@ -71,7 +70,6 @@ class MapAction extends Action
if (!$this->user) {
// TRANS: Client error displayed when referring to a non-existing user.
$this->clientError(_m('No such user.'), 404);
return false;
}
$this->profile = $this->user->getProfile();
@@ -79,7 +77,6 @@ class MapAction extends Action
if (!$this->profile) {
// TRANS: Error message displayed when referring to a user without a profile.
$this->serverError(_m('User has no profile.'));
return false;
}
$page = $this->trimmed('page');

View File

@@ -48,12 +48,10 @@ class MinifyAction extends Action
} else {
// TRANS: Client error displayed when not providing a valid path in parameter "f".
$this->clientError(_m('The parameter "f" is not a valid path.'),404);
return false;
}
}else{
// TRANS: Client error displayed when not providing parameter "f".
$this->clientError(_m('The parameter "f" is required but missing.'),500);
return false;
}
}
@@ -112,7 +110,6 @@ class MinifyAction extends Action
default:
// TRANS: Client error displayed when trying to minify an unsupported file type.
$this->clientError(_m('File type not supported.'),500);
return false;
}
return $out;
}

View File

@@ -281,7 +281,6 @@ class OStatusPlugin extends Plugin
// redirect to the new profile.
common_redirect(common_local_url('tagprofile', array('id' => $oprofile->profile_id)), 303);
return false;
} catch (Exception $e) {
// TRANS: Error message in OStatus plugin. Do not translate the domain names example.com

View File

@@ -145,7 +145,6 @@ class GroupsalmonAction extends SalmonAction
if (Group_block::isBlocked($this->group, $profile)) {
// TRANS: Client error displayed when trying to join a group the user is blocked from by a group admin.
$this->clientError(_m('You have been blocked from that group by the admin.'), 403);
return false;
}
try {

View File

@@ -38,7 +38,6 @@ class OStatusTagAction extends OStatusInitAction
if (common_logged_in()) {
// TRANS: Client error displayed when trying to list a local object as if it is remote.
$this->clientError(_m('You can use the local list functionality!'));
return false;
}
$this->nickname = $this->trimmed('nickname');

View File

@@ -132,10 +132,8 @@ class OpenIDPlugin extends Plugin
$action = trim($args['action']);
if (in_array($action, array('login', 'register'))) {
common_redirect(common_local_url('openidlogin'));
exit(0);
} else if ($action == 'passwordsettings') {
common_redirect(common_local_url('openidsettings'));
exit(0);
} else if ($action == 'recoverpassword') {
// TRANS: Client exception thrown when an action is not available.
throw new ClientException(_m('Unavailable action.'));
@@ -444,7 +442,6 @@ class OpenIDPlugin extends Plugin
{
if (common_config('site', 'openid_only') || (!empty($user) && User_openid::hasOpenID($user->id))) {
common_redirect(common_local_url('openidlogin'), 303);
return false;
}
return true;
}

View File

@@ -322,7 +322,6 @@ class FinishopenidloginAction extends Action
if (common_config('site', 'closed')) {
// TRANS: OpenID plugin message. No new user registration is allowed on the site.
$this->clientError(_m('Registration not allowed.'));
return;
}
$invite = null;
@@ -332,7 +331,6 @@ class FinishopenidloginAction extends Action
if (empty($code)) {
// TRANS: OpenID plugin message. No new user registration is allowed on the site without an invitation code, and none was provided.
$this->clientError(_m('Registration not allowed.'));
return;
}
$invite = Invitation::getKV($code);
@@ -340,7 +338,6 @@ class FinishopenidloginAction extends Action
if (empty($invite)) {
// TRANS: OpenID plugin message. No new user registration is allowed on the site without an invitation code, and the one provided was not valid.
$this->clientError(_m('Not a valid invitation code.'));
return;
}
}
@@ -356,7 +353,6 @@ class FinishopenidloginAction extends Action
if (!$display || !$canonical) {
// TRANS: OpenID plugin server error. A stored OpenID cannot be retrieved.
$this->serverError(_m('Stored OpenID not found.'));
return;
}
// Possible race condition... let's be paranoid
@@ -366,7 +362,6 @@ class FinishopenidloginAction extends Action
if ($other) {
// TRANS: OpenID plugin server error.
$this->serverError(_m('Creating new account for OpenID that already has a user.'));
return;
}
Event::handle('StartOpenIDCreateNewUser', array($canonical, &$sreg));
@@ -418,8 +413,7 @@ class FinishopenidloginAction extends Action
Event::handle('EndRegistrationTry', array($this));
common_redirect(common_local_url('showstream', array('nickname' => $user->nickname)),
303);
common_redirect(common_local_url('showstream', array('nickname' => $user->nickname)), 303);
}
function connectUser()
@@ -442,7 +436,6 @@ class FinishopenidloginAction extends Action
if (!$display || !$canonical) {
// TRANS: OpenID plugin server error. A stored OpenID cannot be found.
$this->serverError(_m('Stored OpenID not found.'));
return;
}
$result = oid_link_user($user->id, $canonical, $display);
@@ -450,7 +443,6 @@ class FinishopenidloginAction extends Action
if (!$result) {
// TRANS: OpenID plugin server error. The user or user profile could not be saved.
$this->serverError(_m('Error connecting user to OpenID.'));
return;
}
if (Event::handle('StartOpenIDUpdateUser', array($user, $canonical, &$sreg))) {

View File

@@ -76,7 +76,6 @@ class OpenidserverAction extends Action
// were POSTed here.
common_set_returnto($_SERVER['REQUEST_URI']);
common_redirect(common_local_url('login'), 303);
return;
}
}else if(common_profile_url($user->nickname) == $request->identity || $request->idSelect()){
$user_openid_trustroot = User_openid_trustroot::pkeyGet(
@@ -101,7 +100,6 @@ class OpenidserverAction extends Action
// prompting user for form resubmission if we
// were POSTed here.
common_redirect(common_local_url('openidtrust'), 303);
return;
}
}else{
//user has previously authorized this trust root

View File

@@ -60,7 +60,6 @@ class OpenidtrustAction extends Action
/* Go log in, and then come back. */
common_set_returnto($_SERVER['REQUEST_URI']);
common_redirect(common_local_url('login'));
return;
}
$this->trust_root = $_SESSION['openid_trust_root'];
$this->allowUrl = $_SESSION['openid_allow_url'];
@@ -68,7 +67,6 @@ class OpenidtrustAction extends Action
if(empty($this->trust_root) || empty($this->allowUrl) || empty($this->denyUrl)){
// TRANS: Client error when visiting page directly.
$this->clientError(_m('This page should only be reached during OpenID processing, not directly.'));
return;
}
return true;
}

View File

@@ -76,7 +76,6 @@ class SearchsubAction extends Action
// TRANS: Client error displayed trying to perform any request method other than POST.
// TRANS: Do not translate POST.
$this->clientError(_m('This action only accepts POST requests.'));
return false;
}
// CSRF protection
@@ -87,7 +86,6 @@ class SearchsubAction extends Action
// TRANS: Client error displayed when the session token is not okay.
$this->clientError(_m('There was a problem with your session token.'.
' Try again, please.'));
return false;
}
// Only for logged-in users
@@ -97,7 +95,6 @@ class SearchsubAction extends Action
if (empty($this->user)) {
// TRANS: Error message displayed when trying to perform an action that requires a logged in user.
$this->clientError(_m('Not logged in.'));
return false;
}
// Profile to subscribe to
@@ -107,7 +104,6 @@ class SearchsubAction extends Action
if (empty($this->search)) {
// TRANS: Client error displayed trying to subscribe to a non-existing profile.
$this->clientError(_m('No such profile.'));
return false;
}
return true;

View File

@@ -116,7 +116,6 @@ abstract class BaseMirrorAction extends Action
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
// TRANS: Client error displayed when trying to use another method than POST.
$this->clientError(_m('This action only accepts POST requests.'));
return false;
}
// CSRF protection
@@ -126,7 +125,6 @@ abstract class BaseMirrorAction extends Action
// TRANS: Client error displayed when the session token does not match or is not given.
$this->clientError(_m('There was a problem with your session token.'.
' Try again, please.'));
return false;
}
// Only for logged-in users
@@ -136,7 +134,6 @@ abstract class BaseMirrorAction extends Action
if (empty($this->user)) {
// TRANS: Error message displayed when trying to perform an action that requires a logged in user.
$this->clientError(_m('Not logged in.'));
return false;
}
return true;
}

View File

@@ -76,7 +76,6 @@ class TagsubAction extends Action
// TRANS: Client error displayed trying to perform any request method other than POST.
// TRANS: Do not translate POST.
$this->clientError(_m('This action only accepts POST requests.'));
return false;
}
// CSRF protection
@@ -87,7 +86,6 @@ class TagsubAction extends Action
// TRANS: Client error displayed when the session token is not okay.
$this->clientError(_m('There was a problem with your session token.'.
' Try again, please.'));
return false;
}
// Only for logged-in users
@@ -97,7 +95,6 @@ class TagsubAction extends Action
if (empty($this->user)) {
// TRANS: Error message displayed when trying to perform an action that requires a logged in user.
$this->clientError(_m('Not logged in.'));
return false;
}
// Profile to subscribe to
@@ -107,7 +104,6 @@ class TagsubAction extends Action
if (empty($this->tag)) {
// TRANS: Client error displayed trying to subscribe to a non-existing profile.
$this->clientError(_m('No such profile.'));
return false;
}
return true;

View File

@@ -496,7 +496,6 @@ class TwitterauthorizationAction extends Action
if (common_config('site', 'closed')) {
// TRANS: Client error displayed when trying to create a new user while creating new users is not allowed.
$this->clientError(_m('Registration not allowed.'));
return;
}
$invite = null;
@@ -506,7 +505,6 @@ class TwitterauthorizationAction extends Action
if (empty($code)) {
// TRANS: Client error displayed when trying to create a new user while creating new users is not allowed.
$this->clientError(_m('Registration not allowed.'));
return;
}
$invite = Invitation::getKV($code);
@@ -514,7 +512,6 @@ class TwitterauthorizationAction extends Action
if (empty($invite)) {
// TRANS: Client error displayed when trying to create a new user with an invalid invitation code.
$this->clientError(_m('Not a valid invitation code.'));
return;
}
}
@@ -543,7 +540,6 @@ class TwitterauthorizationAction extends Action
if (empty($user)) {
// TRANS: Server error displayed when creating a new user has failed.
$this->serverError(_m('Error registering user.'));
return;
}
$result = $this->saveForeignLink($user->id,
@@ -555,7 +551,6 @@ class TwitterauthorizationAction extends Action
if (!$result) {
// TRANS: Server error displayed when connecting a user to a Twitter user has failed.
$this->serverError(_m('Error connecting user to Twitter.'));
return;
}
common_set_user($user);
@@ -566,8 +561,7 @@ class TwitterauthorizationAction extends Action
Event::handle('EndRegistrationTry', array($this));
common_redirect(common_local_url('showstream', array('nickname' => $user->nickname)),
303);
common_redirect(common_local_url('showstream', array('nickname' => $user->nickname)), 303);
}
function connectNewUser()
@@ -598,7 +592,6 @@ class TwitterauthorizationAction extends Action
if (!$result) {
// TRANS: Server error displayed connecting a user to a Twitter user has failed.
$this->serverError(_m('Error connecting user to Twitter.'));
return;
}
common_debug('TwitterBridge Plugin - ' .
@@ -619,7 +612,6 @@ class TwitterauthorizationAction extends Action
if (empty($result)) {
// TRANS: Server error displayed connecting a user to a Twitter user has failed.
$this->serverError(_m('Error connecting user to Twitter.'));
return;
}
common_debug('TwitterBridge Plugin - ' .

View File

@@ -263,7 +263,6 @@ class TwittersettingsAction extends ProfileSettingsAction
if (empty($flink)) {
// TRANS: Client error displayed when trying to remove a connected Twitter account when there isn't one connected.
$this->clientError(_m('No Twitter connection to remove.'));
return;
}
$result = $flink->safeDelete();
@@ -272,7 +271,6 @@ class TwittersettingsAction extends ProfileSettingsAction
common_log_db_error($flink, 'DELETE', __FILE__);
// TRANS: Server error displayed when trying to remove a connected Twitter account fails.
$this->serverError(_m('Could not remove Twitter user.'));
return;
}
// TRANS: Success message displayed after disconnecting a Twitter account.

View File

@@ -63,7 +63,6 @@ class AdminprofileflagAction extends Action
if (!common_logged_in()) {
// TRANS: Error message displayed when trying to perform an action that requires a logged in user.
$this->clientError(_m('Not logged in.'));
return;
}
$user = common_current_user();
@@ -88,7 +87,6 @@ class AdminprofileflagAction extends Action
if (!$user->hasRight(UserFlagPlugin::REVIEWFLAGS)) {
// TRANS: Error message displayed when trying to review profile flags while not authorised.
$this->clientError(_m('You cannot review profile flags.'));
return false;
}
$this->page = $this->trimmed('page');