processwire / processwire-issues

ProcessWire issue reports.
45 stars 2 forks source link

Selector on roles behaves differently than expected #1743

Closed esszett closed 1 year ago

esszett commented 1 year ago

Short description of the issue

It seems that using the field 'roles' in selectors doesn't work exactly the same as one can see on other fields.

$s1 = "roles=aaa"; $s2 = "roles=aaa|guest"; $s3 = "roles=aaa|guest|notavailable";

echo $users->find($s1); //works, returns some users echo $users->find($s2); //works, returns some more users echo $users->find($s3); //returns empty pageArray !

Expected behavior

The third example should find at least the same users as the second example.

Actual behavior

The third selector with an OR value containing an non-existing role-name leads to an empty pageArray.

Steps to reproduce the issue

  1. do a find on $users with selector roles='existing|other-existing'
  2. compare the result with a find like roles='existing|other-existing|non-existing'

Setup/Environment

SERVER DETAILS ProcessWire: 3.0.217 PHP: 8.0.28 Webserver: Apache/2.4.57 (Unix) OpenSSL/1.1.1t MySQL Server: 10.11.3-MariaDB MySQL Client: mysqlnd 8.0.28

BitPoet commented 1 year ago

This actually affects all queries for page references, not just roles/users, e.g.

$pages->find('mypagereffield=home|about|notavailable');

As a workaround, one can use (less performant) OR-groups.

$users->find('(roles=aaa), (roles=guest), (roles=notavailable)');
ryancramerdesign commented 1 year ago

@esszett @BitPoet Thanks, I've pushed an attempted fix for this issue.

esszett commented 1 year ago

@ryancramerdesign Processwire 3.0.220 is returning the expected result now. I confirm fixed.