MantisBT: master-2.27 6d9b53dd

Author Committer Branch Timestamp Parent
dregad dregad master-2.27 2025-02-23 10:24 master-2.27 726961e1
Affected Issues  0035291: Filters including date custom fields don't work on PHP 8.0
Changeset

Fix filters with date custom fields on PHP 8

In PHP < 8.0, comparing a string to 0 evaluates to true when the string
is empty, but starting with 8.0 it returns false 1.

As a result, when BugFilterQuery::build_prop_custom_fields() checks the
filter ($t_field[0] == CUSTOM_FIELD_DATE_ANY, line 1470), it fails on
PHP 8.0+.

To fix this behavior, we ensure that a date custom fields's filter type
is always an int:

  • When processing it in filter_gpc_get(), use gpc_get_int() instead of
    gpc_get_string() to retrieve the filter's type
  • When validating a filter, add special handling for date custom fields
    to ensure that the values (control, timestamp 1 & 2) are treated as
    integers.

Fixes 0035291

mod - core/filter_api.php Diff File