Hi.

We noticed a strange bug sometime ago where filtering the list of redirections in the admin view sometimes returned no results although we knew there were results.

Stranger still, if we changed the first letter of the filter term to upper case (e.g. from 'safety' to 'Safety',) the expected results were returned - even though the redirection paths were all lower case.

I investigated and found the following situation:

1. path redirect constructs a SQL WHERE .. LIKE clause - e.g. "WHERE `path` LIKE '%safety%'"
2. this is passed to pager_query which passes in turn to db_query_range
3. db_query_range performs sprintf-style substitution on the query, matching and replacing based on DB_QUERY_REGEXP: /(%d|%s|%%|%f|%b|%n)/
4. this sees '%s' in '%safety%' as a placeholder, so our query now looks like: "SELECT ... FROM {path_redirect} WHERE `path` LIKE 'afety%'" - hence no matches.

The attached patch resolves this by escaping the first % sign with another % sign.

CommentFileSizeAuthor
sprintf-placeholder-bug.patch462 bytesjames.cartledge

Comments

dave reid’s picture

Status: Active » Closed (won't fix)

You seem to be using some custom code. The filter hasn't yet been implemented in the module's official CVS code. I'll be sure to test this when it is being finished however.

james.cartledge’s picture

Oh no. That's quite embarrassing. If you like I can open a feature request and attach the code we're running as a patch...

dave reid’s picture

Nope. I actually just committed the filter code to CVS that I had been working on in #365242: Add a filter to admin/build/redirect.