From cf54915b1df06466f12c3a0f46b109769d5646f8 Mon Sep 17 00:00:00 2001 From: fr69400 <82267780+fr69400@users.noreply.github.com> Date: Tue, 26 Oct 2021 13:15:50 +0200 Subject: [PATCH 1/2] FIX Crash DateTime::setTimestamp() FIX Crash PHP Warning: DateTime::setTimestamp() expects parameter 1 to be int, string given in D:\Professionnel\dolibarr\htdocs\core\lib\functions.lib.php on line 2291 --- htdocs/core/lib/functions.lib.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 5f014ce3d4876..c991fec43ca65 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2288,6 +2288,12 @@ function dol_strftime($fmt, $ts = false, $is_gmt = false) function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs = '', $encodetooutput = false) { global $conf, $langs; + + // If date undefined or "", we return "" + // Must be tested before line $user_dt->setTimestamp($tzoutput == 'tzuser' ? dol_now() : $time); + if (dol_strlen($time) == 0) { + return ''; // $time=0 allowed (it means 01/01/1970 00:00:00) + } if ($tzoutput === 'auto') { $tzoutput = (empty($conf) ? 'tzserver' : (isset($conf->tzuserinputkey) ? $conf->tzuserinputkey : 'tzserver')); @@ -2380,11 +2386,6 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs = $format = str_replace('yyyy', 'yy', $format); } - // If date undefined or "", we return "" - if (dol_strlen($time) == 0) { - return ''; // $time=0 allowed (it means 01/01/1970 00:00:00) - } - // Clean format if (preg_match('/%b/i', $format)) { // There is some text to translate // We inhibate translation to text made by strftime functions. We will use trans instead later. From 36a1f16059add61a790a0ede800392aaadaef63b Mon Sep 17 00:00:00 2001 From: fr69400 <82267780+fr69400@users.noreply.github.com> Date: Tue, 26 Oct 2021 13:53:57 +0200 Subject: [PATCH 2/2] Update functions.lib.php --- htdocs/core/lib/functions.lib.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index c991fec43ca65..632404f62fc63 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2288,7 +2288,6 @@ function dol_strftime($fmt, $ts = false, $is_gmt = false) function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs = '', $encodetooutput = false) { global $conf, $langs; - // If date undefined or "", we return "" // Must be tested before line $user_dt->setTimestamp($tzoutput == 'tzuser' ? dol_now() : $time); if (dol_strlen($time) == 0) {