From 4aa1c22b9412752ac210ee36f23b7872e9f13029 Mon Sep 17 00:00:00 2001 From: Damien Regad Date: Sun, 21 Feb 2021 17:01:57 +0100 Subject: [PATCH] Fix PHP warning when updating issue with date CF On PHP 8, when updating an issue in a project where a date custom field is linked, and the field's value is not set (empty string), Mantis throws a Warning: Uncaught TypeError: date(): Argument #2 ($timestamp) must be of type ?int, string given This fixes the issue by setting the date to 0 if it is not numeric, prior to calling print_date_selection_set(). Fixes #27928 (cherry picked from commit c09fb41bf8beae969013029ad0577ab11344e8b1) --- core/cfdefs/cfdef_standard.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/cfdefs/cfdef_standard.php b/core/cfdefs/cfdef_standard.php index 039c1c86ca..2cc442052f 100644 --- a/core/cfdefs/cfdef_standard.php +++ b/core/cfdefs/cfdef_standard.php @@ -497,6 +497,9 @@ function cfdef_input_textarea( array $p_field_def, $p_custom_field_value, $p_req * @return void */ function cfdef_input_date( $p_field_def, $p_custom_field_value, $p_required = '' ) { + if( !is_numeric( $p_custom_field_value ) ) { + $p_custom_field_value = 0; + } print_date_selection_set( 'custom_field_' . $p_field_def['id'], config_get( 'short_date_format' ), $p_custom_field_value, false, true, 0, 0, 'input-sm', $p_required ); }