All Low add-ons are now owned by EEHarbor. Read the blog post.

Support archive

PHP errors when using results tag with no query param

Rob Gamm 8 Nov 2012 16:56 problem, complete

Hi,

I've just installed the latest version of low search and there's, what I assume is, a pretty critical bug for me as it completely breaks sites, or at the least a huge backwards compatibility breakage (if so, warning would be appreciated please!). Leaving out the query parameter on the results tag used to just apply all other params, but now completely breaks the site, causing PHP errors and returning everything in all search indexes regardless of other parameters.

Is this now expected behavior, or just an oversight? I've included further details and a quick fix below, but would be good to know what the intention was :)

Cheers,
Rob

The php errors in question are:

A PHP Error was encountered
Severity: Warning
Message: array_merge() [function.array-merge]: Argument #1 is not an array
Filename: low_search/mod.low_search.php
Line Number: 306
A PHP Error was encountered
--------------
Severity: Warning
Message: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object
Filename: low_search/mod.low_search.php
Line Number: 325

and the tag used to generate this is simply {exp:low_search:results collection="name"}

It appears to be caused by changes in the way the decoding of the query param is handled, as the decode function now returns false and no empty array is forced in this case. It can be fixed by adding

if ($this->params === false) {
$this->params = array();
}
to line 302 in mod.low_search.php

Replies

  1. Low 8 Nov 2012 17:29

    That's rather unfortunate and shouldn't be the case. As soon as I'm back home (on the road ATM), I'll try and reproduce and get a fix out.

  2. Low 9 Nov 2012 09:23

    Version 2.1.2 should fix this.

  3. Rob Gamm 9 Nov 2012 10:47

    Great, thanks for the speedy resolution!