At the beginning of Solr_Base_Query::filter_extract() there are three lines like:
$patterns[] = '/(^| |-)'. $name .':([\[\{](\S+) TO (\S+)[\]\}])/';
Now, while this normally works, it completely breaks if someone would have the crazy idea to use complete URIs as field names. So to preserve peace and prepare for that day, may it never come, I propose the attached patch, which seems to work fine.

CommentFileSizeAuthor
query_class_regex_quote.patch1.2 KBdrunken monkey

Comments

pwolanin’s picture

I'm pretty sure things will break badly if your field names are not valid PHP identifiers - have you checked that it's even possible to observe this problem?

drunken monkey’s picture

Why should they need to be? I don't see a reason, and it also doesn't seem to be the case.

Anyways, yes, I observed the problem, and it should be pretty easy to reproduce: Just download the unstable2 version of my apachesolr_rdf module and follow the instructions at #527630-1: First prototype done, but omitting this patch.

When trying to search, you'll inevitably get errors from these exact preg_match_all calls, that will instantly vanish once you apply the patch in this issue.

pwolanin’s picture

Status: Needs review » Postponed (maintainer needs more info)

because every field is used as a property on the document object

drunken monkey’s picture

Status: Postponed (maintainer needs more info) » Needs review
$a = '4 8r u8(U$"8z5g8u';
$$a = 2;

$b = $a;
echo $$b;

I think that running this proves that you can use anything you want as an indirect variable name. ;) The same goes for object properties.

jpmckinney’s picture

Status: Needs review » Patch (to be ported)
$a = '4 8r u8(U$"8z5g8u';
$b->$a = 2;
print_r($b);

stdClass Object
(
    [4 8r u8(U$"8z5g8u] => 2
)

Crazy stuff.

I'm not sure what characters are allowed in a Solr field name. In any case, it is possible for a custom module to add field aliases that use special characters, in which case we would want to quote those characters when extracting filters. So I see nothing wrong with a one line patch.

Committed to 2.x http://drupal.org/cvs?commit=359680

jpmckinney’s picture

Status: Patch (to be ported) » Fixed

Status: Fixed » Closed (fixed)

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