From f7d488d4b2bfdc8dfa6b5a2bc2931dbf824509a0 Mon Sep 17 00:00:00 2001 From: Jeffery To Date: Sun, 14 Jun 2009 16:39:31 +0800 Subject: Fixes the notice search RSS feeds / API results for searches that return no matches. If a user does a notice search that should return no matching notices, the RSS feed / API results for that search currently returns all notices instead of no notices. This fixes it so that an empty list is returned instead. --- actions/twitapisearchatom.php | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'actions/twitapisearchatom.php') diff --git a/actions/twitapisearchatom.php b/actions/twitapisearchatom.php index eb9ab5d8e..708b1494d 100644 --- a/actions/twitapisearchatom.php +++ b/actions/twitapisearchatom.php @@ -165,24 +165,29 @@ class TwitapisearchatomAction extends TwitterapiAction $search_engine->set_sort_mode('chron'); $search_engine->limit(($this->page - 1) * $this->rpp, $this->rpp + 1, true); - $search_engine->query($q); - $this->cnt = $notice->find(); + if (false === $search_engine->query($q)) { + $this->cnt = 0; + } else { + $this->cnt = $notice->find(); + } $cnt = 0; - while ($notice->fetch()) { + if ($this->cnt > 0) { + while ($notice->fetch()) { - ++$cnt; + ++$cnt; - if (!$this->max_id) { - $this->max_id = $notice->id; - } + if (!$this->max_id) { + $this->max_id = $notice->id; + } - if ($cnt > $this->rpp) { - break; - } + if ($cnt > $this->rpp) { + break; + } - $notices[] = clone($notice); + $notices[] = clone($notice); + } } return $notices; -- cgit v1.2.3-54-g00ecf