N°9169 - Refactor code

This commit is contained in:
Eric Espie
2026-04-22 17:30:34 +02:00
parent de0e94800a
commit 467d2755ca

View File

@@ -1989,14 +1989,7 @@ JS
return;
}
// Use mutex to check if cron is running
$oMutex = new iTopMutex(
'cron'.$oConfig->Get('db_name').$oConfig->Get('db_subname'),
$oConfig->Get('db_host'),
$oConfig->Get('db_user'),
$oConfig->Get('db_pwd'),
$oConfig->Get('db_tls.enabled'),
$oConfig->Get('db_tls.ca')
);
$oMutex = self::GetCronMutex($oConfig);
$iCount = 1;
$iStarted = time();
$iMaxDuration = $oConfig->Get('cron_max_execution_time');
@@ -2014,6 +2007,26 @@ JS
}
}
/**
* @param \Config $oConfig
*
* @return \iTopMutex
* @since 3.3.0
*/
public static function GetCronMutex(Config $oConfig): iTopMutex
{
$oMutex = new iTopMutex(
'cron'.$oConfig->Get('db_name').$oConfig->Get('db_subname'),
$oConfig->Get('db_host'),
$oConfig->Get('db_user'),
$oConfig->Get('db_pwd'),
$oConfig->Get('db_tls.enabled'),
$oConfig->Get('db_tls.ca')
);
return $oMutex;
}
/**
* Create and store Setup authentication token
*