From 467d2755cabf10376ff6a1d20cd0597f17f37964 Mon Sep 17 00:00:00 2001 From: Eric Espie Date: Wed, 22 Apr 2026 17:30:34 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B09169=20-=20Refactor=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- setup/setuputils.class.inc.php | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/setup/setuputils.class.inc.php b/setup/setuputils.class.inc.php index 9b9e884856..8f80a931e7 100644 --- a/setup/setuputils.class.inc.php +++ b/setup/setuputils.class.inc.php @@ -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 *