summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2011-11-03 21:24:35 -0700
committerBharat Mediratta <bharat@menalto.com>2011-11-03 21:24:35 -0700
commiteab12774fbe828b295c8ec0b440df8151df74fa1 (patch)
treee9d2f708a49c6a32d9c26812728023f51c981692
parent8a88a64b9a953ec810514df772c8ba877afb6768 (diff)
In get_position() don't try to truncate the score if it's empty. Follow-on to ce43f29e2ceaac3d638061f81dc6037b5e0018d3
-rw-r--r--modules/search/helpers/search.php12
1 files changed, 6 insertions, 6 deletions
diff --git a/modules/search/helpers/search.php b/modules/search/helpers/search.php
index d6d67c29..ab6da802 100644
--- a/modules/search/helpers/search.php
+++ b/modules/search/helpers/search.php
@@ -112,22 +112,22 @@ class search_Core {
static function get_position($item, $q) {
$page_size = module::get_var("gallery", "page_size", 9);
-
$query = self::_build_query_base($q, array("{items}.id = " . $item->id));
-
$db = Database::instance();
// Truncate the score by two decimal places as this resolves the issues
// that arise due to in exact numeric conversions.
$score = $db->query($query)->current()->score;
- $score = substr($score, 0, strlen($score) - 2);
+ if (strlen($score) > 7) {
+ $score = substr($score, 0, strlen($score) - 2);
+ }
$data = $db->query(self::_build_query_base($q) . " HAVING `score` >= " . $score);
-
$data->seek($data->count() - 1);
- while ($data->get("id") != $item->id && $data->prev()->valid());
+ while ($data->get("id") != $item->id && $data->prev()->valid()) {
+ }
- return $data->key() + 1;
+ return $data->key() + 1;
}
}