From 3e73038709902531e77dcccfcb8a99efbe2b6907 Mon Sep 17 00:00:00 2001 From: Molkobain Date: Thu, 22 Jun 2023 13:50:35 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B06380=20-=20Fix=20exception=20"Failed=20t?= =?UTF-8?q?o=20parse=20time=20string"=20with=20check=5Fbackup.php=20script?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- datamodels/2.x/itop-backup/check-backup.php | 9 +++++++-- setup/backup.class.inc.php | 8 ++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/datamodels/2.x/itop-backup/check-backup.php b/datamodels/2.x/itop-backup/check-backup.php index 16a6ab06d..30b1c956d 100644 --- a/datamodels/2.x/itop-backup/check-backup.php +++ b/datamodels/2.x/itop-backup/check-backup.php @@ -102,14 +102,19 @@ if (!function_exists('sys_get_temp_dir')) } - +/** + * @param int $iRefTime Reference date time as a unix timestamp + * + * @return string Absolute path to the backup file, WITHOUT the file extension (`.tar.gz`) + * @throws \Exception + */ function MakeArchiveFileName($iRefTime = null) { $sDefaultBackupFileName = sys_get_temp_dir().'/'."__DB__-%Y-%m-%d"; $sBackupFile = utils::ReadParam('backup_file', $sDefaultBackupFileName, true, 'raw_data'); $oBackup = new DBBackup(); - $oDateTime = $iRefTime !== null ? new DateTime($iRefTime) : new DateTime(); + $oDateTime = $iRefTime !== null ? DateTime::createFromFormat('U', $iRefTime) : new DateTime(); $sBackupFile = $oBackup->MakeName($sBackupFile, $oDateTime); return $sBackupFile; diff --git a/setup/backup.class.inc.php b/setup/backup.class.inc.php index 3d5817398..9b38db6b8 100644 --- a/setup/backup.class.inc.php +++ b/setup/backup.class.inc.php @@ -146,13 +146,13 @@ class DBBackup /** * Create a normalized backup name, depending on the current date/time and Database * - * @param string sNameSpec Name and path, eventually containing itop placeholders + time formatting following the strftime() format {@link https://www.php.net/manual/fr/function.strftime.php} + * @param string $sNameSpec Name and path, eventually containing itop placeholders + time formatting following the strftime() format {@link https://www.php.net/manual/fr/function.strftime.php} * @param \DateTime|null $oDateTime Date time to use for the name * - * @return string - * @since 3.1.0 N°5279 Add $oDtaeaTime parameter + * @return string Name of the backup file WITHOUT the file extension (eg. `.tar.gz`) + * @since 3.1.0 N°5279 Add $oDateTime parameter */ - public function MakeName($sNameSpec = "__DB__-%Y-%m-%d", DateTime $oDateTime = null) + public function MakeName(string $sNameSpec = "__DB__-%Y-%m-%d", DateTime $oDateTime = null) { if ($oDateTime === null) { $oDateTime = new DateTime();