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.
This commit is contained in:
Jeffery To 2009-06-14 16:39:31 +08:00
parent 77c94c44a6
commit f7d488d4b2
3 changed files with 32 additions and 19 deletions

View File

@ -67,11 +67,16 @@ class NoticesearchrssAction extends Rss10Action
if (!$limit) $limit = 20;
$search_engine->limit(0, $limit, true);
$search_engine->query($q);
$notice->find();
if (false === $search_engine->query($q)) {
$cnt = 0;
} else {
$cnt = $notice->find();
}
while ($notice->fetch()) {
$notices[] = clone($notice);
if ($cnt > 0) {
while ($notice->fetch()) {
$notices[] = clone($notice);
}
}
return $notices;

View File

@ -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;
}
$notices[] = clone($notice);
}
if ($cnt > $this->rpp) {
break;
}
$notices[] = clone($notice);
}
return $notices;

View File

@ -124,8 +124,11 @@ class TwitapisearchjsonAction extends TwitterapiAction
$search_engine = $notice->getSearchEngine('identica_notices');
$search_engine->set_sort_mode('chron');
$search_engine->limit(($this->page - 1) * $this->rpp, $this->rpp + 1, true);
$search_engine->query($q);
$cnt = $notice->find();
if (false === $search_engine->query($q)) {
$cnt = 0;
} else {
$cnt = $notice->find();
}
// TODO: since_id, lang, geocode