If I set more than one weight to > 0 on the search configuration page, the node search fails and the dblog has an error message like:

PDOException: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens: SELECT i.type AS type, i.sid AS sid, SUM(CAST(:multiply_0 AS DECIMAL) * COALESCE(( 2.0 - 2.0 / (1.0 + node_comment_statistics.comment_count * CAST(:scale AS DECIMAL))), 0) / CAST(:total_0 AS DECIMAL) + CAST(:multiply_1 AS DECIMAL) * COALESCE(( POW(2.0, (GREATEST(n.created, n.changed) - :node_cron_last) * 6.43e-8)), 0) / CAST(:total_1 AS DECIMAL)) AS calculated_score FROM {search_index} i INNER JOIN {node} n ON n.nid = i.sid INNER JOIN {search_total} t ON i.word = t.word LEFT JOIN {node_comment_statistics} node_comment_statistics ON node_comment_statistics.nid = i.sid INNER JOIN {search_dataset} d ON i.sid = d.sid AND i.type = d.type WHERE (n.status = :db_condition_placeholder_0) AND( (i.word = :db_condition_placeholder_1) )AND (i.type = :db_condition_placeholder_2) AND( (d.data LIKE :db_condition_placeholder_3 ESCAPE '\\') ) GROUP BY i.type, i.sid HAVING (COUNT(*) >= :matches) ORDER BY calculated_score DESC LIMIT 10 OFFSET 0; Array ( [:db_condition_placeholder_0] => 1 [:db_condition_placeholder_1] => blog [:db_condition_placeholder_2] => node [:db_condition_placeholder_3] => % blog % [:matches] => 1 [:scale] => 0 [:multiply_0] => 4 [:node_cron_last] => 1271277590 [:multiply_1] => 6 [total_0] => 10 )  in PagerDefault->execute() (line 93 of /mnt/www/html/tangle001/docroot/includes/pager.inc).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pwolanin’s picture

FileSize
48.1 KB

doh, attached screenshot disappeared. Here it is:

jhodgdon’s picture

Priority: Normal » Critical

That doesn't look good! Good catch!

We should fix it and also make a test.

Since it's a crash situation (PDO exception arising from using the Drupal core UI in a reasonable way), I think status should be critical on this one.

jhodgdon’s picture

Issue tags: +Needs tests

tagging

jhodgdon’s picture

It looks like the error in the query is that placeholder :total_0 in the query was given as just total_0 in the arg list.

jhodgdon’s picture

Oh, and :total_1 is also missing.

jhodgdon’s picture

Assigned: Unassigned » jhodgdon

Hah! I think I found the problem and have a fix. Writing tests... will report back shortly.

jhodgdon’s picture

Status: Active » Needs review
FileSize
1.94 KB
2.56 KB

Here's a patch. If you apply just the search.test part of the patch, you get an exception much like the one reported above. If you also apply the search.extender.inc part of the patch, the test passes.

I'll attach this as two patches: the full patch (test + fix) and just the failing test (so we can verify that the test bot agrees that the added test is a good one for revealing this bug).

Status: Needs review » Needs work

The last submitted patch, 771596-failing-test.patch, failed testing.

jhodgdon’s picture

Status: Needs work » Needs review

There you go. The "test and fix" patch needs review. Obviously don't just add the "failing test" patch. :)

pwolanin’s picture

Status: Needs review » Reviewed & tested by the community

Ah yes - $i++ would help.

Change makes sense, and added testing is lovely.

jhodgdon’s picture

Not only $i++ but also the : was missing.

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to CVS HEAD. Thanks.

Status: Fixed » Closed (fixed)
Issue tags: -Needs tests

Automatically closed -- issue fixed for 2 weeks with no activity.