Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selector on roles behaves differently than expected #1743

Closed
esszett opened this issue Jun 1, 2023 · 3 comments
Closed

Selector on roles behaves differently than expected #1743

esszett opened this issue Jun 1, 2023 · 3 comments

Comments

@esszett
Copy link

esszett commented Jun 1, 2023

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
Copy link

BitPoet commented Jun 3, 2023

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 added a commit to processwire/processwire that referenced this issue Jun 8, 2023
@ryancramerdesign
Copy link
Member

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

@esszett
Copy link
Author

esszett commented Jun 14, 2023

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

@esszett esszett closed this as completed Jun 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants