- Issue created by @BerkeleyJon
- 🇺🇸United States DCLoganGuy
We are having the same issue.
Drupal 7.95
Views 7.x-3.27
If I try to filter something like below, it does not save and throws an error. Steps to reproduce are the same as above.
Error:form Illegal choice 2 in filters element.Content: Published status No
And
Content: Type = Basic pageOR
Content: Type = Book pagethanks
- 🇺🇸United States rclemings
Same here with Drupal 7.95 and Views 7.x-3.29, and with Views 7.x-3.28 on another site.
It looks as if this has been a problem for some time, if unnoticed until now. I rolled back as far as 3.25 and it was still an issue, as far as I could tell.
- 🇳🇿New Zealand rimu
I recently upgraded to PHP 8.2 from 7.2, maybe that is related.
We're seeing this as well. Our system:
- PHP 8.1.14
- Drupal 7.97
- Views 7.x-3.29
FWIW, we were able to reproduce this on every PHP 8.1-compative Views release.
We just attempted a PHP downgrade, which resolved the issue.
Curiously, once we downgraded, an empty filter group was immediately visible.
- 🇺🇸United States DamienMcKenna NH, USA
Sounds like a PHP 8.1 compatibility bug then.
- 🇫🇮Finland attekilpela
I checked this and probably found the bug, but I'm not sure where it actually is:
1. User click Create new filter group and AJAX is executed to menu callback $items['admin/structure/views/ajax/%/%views_ui_cache']
https://github.com/drupalprojects/views/blob/7.x-3.x/views_ui.module#L1352. Function views_ui_ajax_form is executed with parameters: $js = TRUE, $key = rearrange-filter, $view = views name
https://github.com/drupalprojects/views/blob/7.x-3.x/includes/admin.inc#...3. $key is reassigned in line 3015 $key = key($view->stack); and is assigned to zero.
https://github.com/drupalprojects/views/blob/7.x-3.x/includes/admin.inc#...4. Then comparison $view->form_cache['key'] != $key where values are rearrange-filter and 0 which in PHP7 is FALSE and PHP8 is TRUE. The comparison of course should be between rearrange-filter and rearrange-filter.
https://github.com/drupalprojects/views/blob/7.x-3.x/includes/admin.inc#... - 🇸🇪Sweden kristofferwiklund
Finding the same problem. Looking in to it. But it seems the the references @attekilpela has, is to an old github version of Views. The correct urls should be to here: https://git.drupalcode.org/project/views/-/blob/7.x-3.x/includes/admin.inc
- 🇸🇪Sweden kristofferwiklund
So we have found code that seems have never been run in PHP 7. But as logic in PHP 8 has been changed (to the better) its now running and breaks views.
In code admin.inc:3096 https://git.drupalcode.org/project/views/-/blob/7.x-3.29/includes/admin.... we have the following row:
if (isset($view->form_cache) && $view->form_cache['key'] != $key) {
unset($view->form_cache);
}When adding a filter group $view->form_cache['key'] will be "rearrange-filter" and $key will be "0"
And in PHP 7: $view->form_cache['key'] != $key is FALSE. As "rearrange-filter" is converted to int,0. So 0!=0 is FALSE.
And in PHP 8: $view->form_cache['key'] != $key is TRUE. As $key is converted to string ''. So "rearrange-filter" != '' is TRUE.(More info here: https://wiki.php.net/rfc/string_to_number_comparison#introduction)
The affect of this is that that form_cache is clear the the form is not updated.
I have tried setting a break point in PHP7 on the "unset($view->form_cache);" row. And that has never been triggered for me.
So the solution for me is to remove the if code.
- last update
over 1 year ago run-tests.sh exception - @kristofferwiklund opened merge request.
- Status changed to RTBC
over 1 year ago 7:43pm 11 September 2023 - 🇨🇦Canada joelpittet Vancouver
This change is working well. Thanks @kristofferwiklund for digging into the details.
- 🇺🇸United States DamienMcKenna NH, USA
FYI that code section comes from #118672: Adding sql ORing capability with filters → and hasn't changed in 13 years.
- Status changed to Fixed
over 1 year ago 9:41pm 11 September 2023 -
DamienMcKenna →
committed 64244efd on 7.x-3.x authored by
kristofferwiklund →
Issue #3348800 by kristofferwiklund, BerkeleyJon, DamienMcKenna,...
-
DamienMcKenna →
committed 64244efd on 7.x-3.x authored by
kristofferwiklund →
Automatically closed - issue fixed for 2 weeks with no activity.