Steps to reproduce:

1) Download Drupal 7.7 and Search Configuration 7.x-1.0.
2) Install Drupal, Search, & Search Configuration.
3) Configure Search and Search Configuration permissions such that all roles have "Use search" and "Basic page: Search content of this type", but no other permissions.
4) Create a Basic page with the title of "St. John's Mercy Medical Center".
5) Run cron to index the node.
6) While still logged in as UID 1, search for (no quotes) "st. john's mercy", then "john's", then "st. john". You will see the node you created.
7) Now, logout, and perform the same search. You will NOT see the node.
8) Still logged out, search for "john" or "mercy", and you WILL see the node.

It appears that the punctuation breaks the search somehow, for all users except UID 1. In the setup above, authenticated users, and even administrators have the same problem as anonymous users.

UID 1 finds the result because the query is not altered in search_config_query_node_access_alter for this user. But if the query is altered, then searches with periods or apostrophes just don't work.

Any idea why?

Comments

joelstein’s picture

Here's one of the queries generated on the search page. Notice that the Search module searches for the word "article" (which is a restricted content type) instead of the search term "john". I wonder if this is a bug with the search module? It seems like it's using the wrong variable substitution.

SELECT i.type AS type, i.sid AS sid, SUM((2.34658697204 * i.score * t.count)) 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
INNER JOIN search_dataset d ON i.sid = d.sid AND i.type = d.type
WHERE (n.status = '1')
AND( (i.word = 'john') )
AND (i.type = 'node') 
AND (n.type NOT IN ('article'))
AND( (n.type != 'article') )
AND( (d.data LIKE 'article' ESCAPE '\\') AND (d.data LIKE 'article' ESCAPE '\\') ) 
GROUP BY i.type, i.sid 
HAVING (COUNT(*) >= '1')
ORDER BY calculated_score DESC
LIMIT 10
OFFSET 0
joelstein’s picture

alan d.’s picture

Priority: Critical » Major

@joelstein
Nice find with the core issues, will track with interest!

xjm’s picture

Status: Active » Closed (duplicate)

A fix has been committed for the core issue, so this problem should be resolved in Drupal 7.9 when it comes out in a week or two. Marking duplicate of #1112854: Subqueries use wrong arguments.