Ajax refresh for dependent select not working/ProcessPageSearch doesn't work with owner selectors
Short description of the issue
When using a "Selector string" in a page reference field (B) that uses dependent selects and "owner" syntax and changing the page reference field that it depends on (A), all pages matching the template selector are loaded via ajax into the dropdown (of field B).
The issue seems to be that when reaching "___executeFor()" inside "ProcessPageSearch.module", the $name of the field is already changed to "page_ref_owner_id" instead of "page_ref.owner.id".
Expected behavior
Only the pages matching the "owner" selector should be loaded into the select.
Actual behavior
The "owner" selector is entirely ignored, all pages with the template are loaded. Saving the page (which means reloading) shows the correct contents.
Optional: Suggestion for a possible fix
I can fix this the dirty way by adding this inside "___executeFor()"
foreach($input->get as $name => $value) {
// ### Test override, probably insecure
if (strpos($name, "_owner_id") !== false) {
$namecorrect = str_replace("_owner_id", ".owner.id", $name);
$selectors[] = $namecorrect . "=" . (int)$value;
}
// ## continue vanilla code
Steps to reproduce the issue
Fails for a setup like this:
- pageX1 and pageX2 (template_x)
- FIELD: page_ref (containing pageZ1 and pageZ2 respectively)
- pageY
- FIELD: select_a (containing pageX1 or pageX2, selected from template_x)
- FIELD: select_b (using selector string
template=template_z, page_ref.owner.id=page.select_a--> not updating correctly, showing both pageZ1 and pageZ2 when changing select_a)
- pageZ1 and pageZ2 (template_z)
Setup/Environment
- ProcessWire version: 3.0.200
- (Optional) PHP version: 8.X