Skip to content

Commit

Permalink
Fix PHP warning when updating issue with date CF
Browse files Browse the repository at this point in the history
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 c09fb41)
  • Loading branch information
dregad committed Mar 6, 2021
1 parent 4795a39 commit 4aa1c22
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions core/cfdefs/cfdef_standard.php
Expand Up @@ -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 );
}

Expand Down

0 comments on commit 4aa1c22

Please sign in to comment.