diff --git a/core/modules/search/lib/Drupal/search/SearchQuery.php b/core/modules/search/lib/Drupal/search/SearchQuery.php index b49c06a..668ca14 100644 --- a/core/modules/search/lib/Drupal/search/SearchQuery.php +++ b/core/modules/search/lib/Drupal/search/SearchQuery.php @@ -413,6 +413,7 @@ public function addScore($score, $arguments = array(), $multiply = FALSE) { */ public function execute() { + if (!$this->executedFirstPass) { $this->executeFirstPass(); } @@ -440,8 +441,12 @@ public function execute() } } + // Format the float to make sure that the decimal separator is a period + // no matter what the numeric locale is set to. This is so the database + // query will not fail. + $relevance = number_format((1.0 / $this->normalize), 10, '.', ''); // Replace i.relevance pseudo-field with the actual, normalized value. - $this->scores = str_replace('i.relevance', '(' . (1.0 / $this->normalize) . ' * i.score * t.count)', $this->scores); + $this->scores = str_replace('i.relevance', '(' . $relevance . ' * i.score * t.count)', $this->scores); // Convert scores to an expression. $this->addExpression('SUM(' . implode(' + ', $this->scores) . ')', 'calculated_score', $this->scoresArguments); @@ -455,7 +460,6 @@ public function execute() ->addTag('search_' . $this->type) ->addMetaData('normalize', $this->normalize) ->fields('i', array('type', 'sid')); - return $this->query->execute(); }