From 0f9ec45a063becb96ce14bc51ee9ba1164695e0d Mon Sep 17 00:00:00 2001 From: Hannes Mannerheim Date: Tue, 16 Feb 2016 19:20:44 +0100 Subject: [PATCH] removes error in blocked-feed when we haven't blocked anyone --- actions/apiqvitterblocks.php | 14 +++++++++----- classes/QvitterBlocked.php | 7 ++++++- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/actions/apiqvitterblocks.php b/actions/apiqvitterblocks.php index ebeed52..f6d7bb2 100644 --- a/actions/apiqvitterblocks.php +++ b/actions/apiqvitterblocks.php @@ -109,14 +109,18 @@ class ApiQvitterBlocksAction extends ApiPrivateAuthAction $blocks = QvitterBlocked::getBlocked($this->target->id, $offset, $limit); - $profiles = array(); + if($blocks) { + $profiles = array(); - while ($blocks->fetch()) { - $this_profile_block = clone($blocks); - $profiles[] = $this->getTargetProfile($this_profile_block->blocked); + while ($blocks->fetch()) { + $this_profile_block = clone($blocks); + $profiles[] = $this->getTargetProfile($this_profile_block->blocked); + } + return $profiles; + } else { + return false; } - return $profiles; } /** diff --git a/classes/QvitterBlocked.php b/classes/QvitterBlocked.php index a3cbc58..39f8b51 100644 --- a/classes/QvitterBlocked.php +++ b/classes/QvitterBlocked.php @@ -49,7 +49,12 @@ class QvitterBlocked extends Profile_block public static function getBlocked($profile_id, $offset = 0, $limit = PROFILES_PER_PAGE) { $ids = self::getBlockedIDs($profile_id, $offset, $limit); - return Profile_block::listFind('blocked', $ids); + try { + $blocked = Profile_block::listFind('blocked', $ids); + return $blocked; + } catch(NoResultException $e) { + return false; + } }