Cockpit-HQ / Cockpit

Cockpit Core - Content Platform
https://getcockpit.com
Other
388 stars 47 forks source link

Search on Entities is broken #121

Closed pictus closed 1 year ago

pictus commented 1 year ago

We created some entities, after that, it was not possible to search for those entries.

The error was something like preg_match requires the second argument to be a string, array given in lib/MongoLite/UtilArrayQuery.php:195.

I dont have the time, to make a PR, or a deeper research, only wanted to give my solution, how i fixed this problem, sorry for that.

Solution:

case '$not':
                # add this line, than the search works correct.
                if(is_array($a)) { break; } 

                $r = (boolean) @\preg_match(isset($b[0]) && $b[0]=='/' ? $b : '/'.$b.'/iu', $a, $match);
                if ($func === '$not') {
                    $r = !$r;
                }
                break;
aheinze commented 1 year ago

Thanks for reporting. Should be fixed with this commit: https://github.com/Cockpit-HQ/Cockpit/commit/54d7d5d2bba898b63a8677ef2daa7eec5ced5102