summaryrefslogtreecommitdiff
path: root/modules/search
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2010-04-16 13:53:43 +0000
committerDries Buytaert <dries@buytaert.net>2010-04-16 13:53:43 +0000
commitc0f75814bff04f41e4dc035b4e0f2ea2b19cff54 (patch)
tree59c41637451d74ced8b7b3d554a9fd0c6b27bb84 /modules/search
parent9baff4597b9c25bd8319c5aa0e8b26848ac79722 (diff)
downloadbrdo-c0f75814bff04f41e4dc035b4e0f2ea2b19cff54.tar.gz
brdo-c0f75814bff04f41e4dc035b4e0f2ea2b19cff54.tar.bz2
- Patch #771596 by jhodgdon: turning on multiple search weights causes PDO exception during search.
Diffstat (limited to 'modules/search')
-rw-r--r--modules/search/search.extender.inc3
-rw-r--r--modules/search/search.test39
2 files changed, 41 insertions, 1 deletions
diff --git a/modules/search/search.extender.inc b/modules/search/search.extender.inc
index 05daa7850..047853a9c 100644
--- a/modules/search/search.extender.inc
+++ b/modules/search/search.extender.inc
@@ -425,7 +425,8 @@ class SearchQuery extends SelectQueryExtender {
$i = 0;
$sum = array_sum($this->multiply);
foreach ($this->multiply as $total) {
- $this->scoresArguments['total_' . $i] = $sum;
+ $this->scoresArguments[':total_' . $i] = $sum;
+ $i++;
}
}
diff --git a/modules/search/search.test b/modules/search/search.test
index 8ae018999..ce7e56cb0 100644
--- a/modules/search/search.test
+++ b/modules/search/search.test
@@ -412,6 +412,45 @@ class SearchRankingTestCase extends DrupalWebTestCase {
$this->assertEqual($set[0]['node']->nid, $nodes[$node_rank][1]->nid, 'Search ranking "' . $node_rank . '" order.');
}
}
+
+ /**
+ * Verifies that if we combine two rankings, search still works.
+ *
+ * See issue http://drupal.org/node/771596
+ */
+ function testDoubleRankings() {
+ // Login with sufficient privileges.
+ $this->drupalLogin($this->drupalCreateUser(array('post comments without approval', 'create page content')));
+
+ // See testRankings() above - build a node that will rank high for sticky.
+ $settings = array(
+ 'type' => 'page',
+ 'title' => array(LANGUAGE_NONE => array(array('value' => 'Drupal rocks'))),
+ 'body' => array(LANGUAGE_NONE => array(array('value' => "Drupal's search rocks"))),
+ 'sticky' => 1,
+ );
+
+ $node = $this->drupalCreateNode($settings);
+
+ // Update the search index.
+ module_invoke_all('update_index');
+ search_update_totals();
+
+ // Refresh variables after the treatment.
+ $this->refreshVariables();
+
+ // Set up for ranking sticky and lots of comments; make sure others are
+ // disabled.
+ $node_ranks = array('sticky', 'promote', 'relevance', 'recent', 'comments', 'views');
+ foreach ($node_ranks as $var) {
+ $value = ($var == 'sticky' || $var == 'comments') ? 10 : 0;
+ variable_set('node_rank_' . $var, $value);
+ }
+
+ // Do the search and assert the results.
+ $set = node_search_execute('rocks');
+ $this->assertEqual($set[0]['node']->nid, $node->nid, 'Search double ranking order.');
+ }
}
class SearchBlockTestCase extends DrupalWebTestCase {