mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-27 06:04:12 +01:00
Compare commits
2 Commits
develop
...
saas/manag
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cc2f7e1592 | ||
|
|
a54b88c524 |
@@ -664,7 +664,7 @@ class CMDBSource
|
|||||||
);
|
);
|
||||||
DeadLockLog::Info($sMessage, $iMySqlErrorNo, $aLogContext);
|
DeadLockLog::Info($sMessage, $iMySqlErrorNo, $aLogContext);
|
||||||
|
|
||||||
IssueLog::Error($sMessage, LogChannels::DEADLOCK, $e->getMessage());
|
IssueLog::Error($sMessage, LogChannels::DEADLOCK, [$e->getMessage()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -146,18 +146,23 @@ class DBBackup
|
|||||||
/**
|
/**
|
||||||
* Create a normalized backup name, depending on the current date/time and Database
|
* 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|null $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
|
* @param \DateTime|null $oDateTime Date time to use for the name
|
||||||
*
|
*
|
||||||
* @return string Name of the backup file WITHOUT the file extension (eg. `.tar.gz`)
|
* @return string Name of the backup file WITHOUT the file extension (eg. `.tar.gz`)
|
||||||
* @since 3.1.0 N°5279 Add $oDateTime parameter
|
* @since 3.1.0 N°5279 Add $oDateTime parameter
|
||||||
*/
|
*/
|
||||||
public function MakeName(string $sNameSpec = "__DB__-%Y-%m-%d", DateTime $oDateTime = null)
|
public function MakeName(?string $sNameSpec = null, ?DateTime $oDateTime = null)
|
||||||
{
|
{
|
||||||
if ($oDateTime === null) {
|
if ($oDateTime === null) {
|
||||||
$oDateTime = new DateTime();
|
$oDateTime = new DateTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//N°6640
|
||||||
|
if ($sNameSpec === null) {
|
||||||
|
$sNameSpec = "__DB__-%Y-%m-%d";
|
||||||
|
}
|
||||||
|
|
||||||
$sFileName = $sNameSpec;
|
$sFileName = $sNameSpec;
|
||||||
$sFileName = str_replace('__HOST__', $this->sDBHost, $sFileName);
|
$sFileName = str_replace('__HOST__', $this->sDBHost, $sFileName);
|
||||||
$sFileName = str_replace('__DB__', $this->sDBName, $sFileName);
|
$sFileName = str_replace('__DB__', $this->sDBName, $sFileName);
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ class DBBackupTest extends ItopTestCase
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testMakeName(string $sInputFormat, DateTime $oBackupDateTime, string $sExpectedFilename): void
|
public function testMakeName(?string $sInputFormat, ?DateTime $oBackupDateTime, string $sExpectedFilename): void
|
||||||
{
|
{
|
||||||
$oConfig = utils::GetConfig();
|
$oConfig = utils::GetConfig();
|
||||||
|
|
||||||
@@ -138,6 +138,11 @@ class DBBackupTest extends ItopTestCase
|
|||||||
$oBackupDateTime = DateTime::createFromFormat('Y-m-d H:i:s', '1985-07-30 15:30:59');
|
$oBackupDateTime = DateTime::createFromFormat('Y-m-d H:i:s', '1985-07-30 15:30:59');
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
'Default format - no params' => [
|
||||||
|
'__DB__-%Y-%m-%d',
|
||||||
|
$oBackupDateTime,
|
||||||
|
static::DUMMY_DB_NAME.'-1985-07-30',
|
||||||
|
],
|
||||||
'Default format' => [
|
'Default format' => [
|
||||||
'__DB__-%Y-%m-%d',
|
'__DB__-%Y-%m-%d',
|
||||||
$oBackupDateTime,
|
$oBackupDateTime,
|
||||||
@@ -160,4 +165,28 @@ class DBBackupTest extends ItopTestCase
|
|||||||
],
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* N°6640 - Broken unattended setup with XML backup configuration
|
||||||
|
*/
|
||||||
|
public function testMakeNameWithoutParams(): void
|
||||||
|
{
|
||||||
|
$oConfig = utils::GetConfig();
|
||||||
|
|
||||||
|
// See https://github.com/Combodo/iTop/commit/f7ee21f1d7d1c23910506e9e31b57f33311bd5e0#diff-d693fb790e3463d1aa960c2b8b293532b1bbd12c3b8f885d568d315c404f926aR131
|
||||||
|
$oConfig->Set('db_host', static::DUMMY_DB_HOST);
|
||||||
|
$oConfig->Set('db_name', static::DUMMY_DB_NAME);
|
||||||
|
$oConfig->Set('db_subname', static::DUMMY_DB_SUBNAME);
|
||||||
|
|
||||||
|
$oDateTime = new DateTime();
|
||||||
|
$sExpectedFilename = static::DUMMY_DB_NAME . '-' . $oDateTime->format("Y-m-d");
|
||||||
|
|
||||||
|
$oBackup = new DBBackup($oConfig);
|
||||||
|
|
||||||
|
$sTestedFilename = $oBackup->MakeName(null);
|
||||||
|
$this->assertEquals($sExpectedFilename, $sTestedFilename, "Backup filename format doesn't match. Got '$sTestedFilename', expected '$sExpectedFilename'.");
|
||||||
|
|
||||||
|
$sTestedFilename = $oBackup->MakeName();
|
||||||
|
$this->assertEquals($sExpectedFilename, $sTestedFilename, "Backup filename format doesn't match. Got '$sTestedFilename', expected '$sExpectedFilename'.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user