Fix error handling for missing group in apigroupmembership -- was trying to call methods on the variable before we checked it, which triggers PHP fatal error

This commit is contained in:
Brion Vibber 2011-01-07 16:25:58 -08:00
parent cb56f445b8
commit 74a1c9def0
1 changed files with 6 additions and 6 deletions

View File

@ -66,6 +66,12 @@ class ApiGroupMembershipAction extends ApiPrivateAuthAction
parent::prepare($args);
$this->group = $this->getTargetGroup($this->arg('id'));
if (empty($this->group)) {
// TRANS: Client error displayed trying to show group membership on a non-existing group.
$this->clientError(_('Group not found.'), 404, $this->format);
return false;
}
$this->profiles = $this->getProfiles();
return true;
@ -84,12 +90,6 @@ class ApiGroupMembershipAction extends ApiPrivateAuthAction
{
parent::handle($args);
if (empty($this->group)) {
// TRANS: Client error displayed trying to show group membership on a non-existing group.
$this->clientError(_('Group not found.'), 404, $this->format);
return false;
}
// XXX: RSS and Atom
switch($this->format) {