More defensive checks for date_epoch data type.

This commit is contained in:
vedanshujain 2022-05-11 14:25:34 +05:30
parent 8c148e7e4b
commit d2e6689407
1 changed files with 8 additions and 1 deletions

View File

@ -751,7 +751,14 @@ WHERE $where_clause
$row[ $destination_alias ] = wc_string_to_bool( $row[ $destination_alias ] ); $row[ $destination_alias ] = wc_string_to_bool( $row[ $destination_alias ] );
} }
if ( 'date_epoch' === $schema['type'] ) { if ( 'date_epoch' === $schema['type'] ) {
$row[ $alias ] = ( new \DateTime( "@{$row[ $alias ]}" ) )->format( 'Y-m-d H:i:s' ); if ( '' === $row[ $alias ] || null === $row[ $alias ] ) {
$row[ $alias ] = null;
} else {
$row[ $alias ] = ( new \DateTime( "@{$row[ $alias ]}" ) )->format( 'Y-m-d H:i:s' );
}
if ( '0000-00-00 00:00:00' === $row[ $destination_alias ] ) {
$row[ $destination_alias ] = null;
}
} }
if ( is_null( $row[ $alias ] ) ) { if ( is_null( $row[ $alias ] ) ) {
$row[ $alias ] = $this->get_type_defaults( $schema['type'] ); $row[ $alias ] = $this->get_type_defaults( $schema['type'] );