Closed laurentmuller closed 5 years ago
What problem would this fix?
The "orderable"
or "searchable"
values are string (either "true
" or "false"
) and when You cast a non-empty string to a bool value, the returned value is always true
.
So (bool)"true"
return true
and (bool)"false"
return also true
! It is because You must check the string value.
See: PHP Documentation
Hi,
When are these values string
?
I am aware of how type juggling and casting work in PHP, but as shown above those properties can never contain string values, as enforced by the Symfony OptionsResolver component. The null
fallbacks are sane defaults also returning in correct boolean values.
Sorry, sorry and again sorry.
I wrote this issue in the wrong repository !
Right 😆
When parsing Parameters to create a DataTableQuery, the values (like 'searchable' or 'orderable') are cast to a boolean with code like:
(bool) $column['orderable']
But the parameter value can only be the literal
'true'
or'false'
and when cast, it returnstrue
.A bug fix is to test the literal value with code like:
'true' === $column['orderable']
or
filter_var($column['orderable'], FILTER_VALIDATE_BOOLEAN)
Tested with Symfony v3.4.24 and PHP v7.2.14.