mirror of
https://github.com/Combodo/iTop.git
synced 2026-03-12 12:34:12 +01:00
N°6380 - Fix exception "Failed to parse time string" with check_backup.php script
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user