kinglozzer

There’s at least one extra database query there, but that shouldn’t cause that much delay 😕

kinglozzer

Either that, or the $escape = false argument would pass the $value string argument directly into the query, and not invoke Criteria… but that could make it difficult to “negate” a filter for ->exclude()?

kinglozzer

Actually, I’m going to loop back to my suggestion of allowing passing Criteria objects to filter/exclude 😛 because that would avoid the double-escape issue

kinglozzer

That’s a pain, because it makes your suggestion of running everything through Criteria more difficult

kinglozzer

https://github.com/minimalcode-org/search/blob/master/src/Criteria.php#L590-L617 😞

Show 1 attachment(s)
src/Criteria.php:590-617

    /**
     * @param mixed $value
     * @return string
     */
    private function processValue($value)
    {
        if ($value === '*') {
            return $value;
        }

        if ($value instanceof DateTime) {
            $value = $value->format('Y-m-d\TH:i:s\Z');
        }

        if (\is_bool($value)) {
            return $value ? 'true' : 'false';
        }

        // Sanitize special chars
        $value = \preg_replace('/(\+|-|&&|\|\||!|\(|\)|\{|}|\[|]|\^|"|~|\*|\?|:|\/|\\\)/', '\\\$1', (string) $value);

        // Sanitize multiple words
        if (\strpos($value, ' ')) {
            $value = '"' . $value . '"';
        }

        return $value;
    }
Hide attachment content
kinglozzer

So then when QueryComponentFactory jumps in to escape it, it’s escaping it for a second time

kinglozzer

@Firesphere I think I see where the problem is… if you pass something that’s already a Solr query to Criteria, it gets escaped by Criteria