N°7858 Typo in backup config causing wrong scheduling of first occurrence of weekly backup (if on the same day as first execution)

This commit is contained in:
Romain Quetiez
2024-09-27 16:47:32 +02:00
parent 380512dcbe
commit 5ae2fdee94
2 changed files with 7 additions and 0 deletions

View File

@@ -201,6 +201,7 @@ abstract class AbstractWeeklyScheduledProcess implements iScheduledProcess
static::MODULE_SETTING_TIME,
static::GetDefaultModuleSettingTime()
);
$sProcessTime = trim($sProcessTime);
if (!preg_match('/[0-2]\d:[0-5]\d/', $sProcessTime))
{
throw new ProcessInvalidConfigException($this->GetModuleName().": wrong format for setting '".static::MODULE_SETTING_TIME."' (found '$sProcessTime')");

View File

@@ -104,6 +104,12 @@ class WeeklyScheduledProcessTest extends ItopTestCase
$oWeeklyImpl->InterpretWeekDays();
}
public function testTimeConfigShouldBeTrimmed()
{
$oWeeklyImpl = new \WeeklyScheduledProcessMockConfig(true, ' 22:33 ', 'monday');
$this->assertEquals(new DateTime('2020-05-11 22:33:00'), $oWeeklyImpl->GetNextOccurrence('2020-05-11 21:00'));
}
public function testTimeConfigSecondsShouldBeIgnored()
{
$oWeeklyImpl = new \WeeklyScheduledProcessMockConfig(true, '22:33:44.123', 'monday');