From: Brion Vibber Date: Sat, 8 Jan 2011 00:25:58 +0000 (-0800) Subject: Fix error handling for missing group in apigroupmembership -- was trying to call... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=74a1c9def08a052180d50854ac6f0e28795f7bfa;p=quix0rs-gnu-social.git 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 --- diff --git a/actions/apigroupmembership.php b/actions/apigroupmembership.php index 99ac965fa1..939d22d757 100644 --- a/actions/apigroupmembership.php +++ b/actions/apigroupmembership.php @@ -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) {