From e4b8f31af0e8cbcf347503cef114ab9c92c8431d Mon Sep 17 00:00:00 2001 From: odain Date: Thu, 26 Feb 2026 08:46:06 +0100 Subject: [PATCH] phpstan fix + add log --- webservices/cron_status.php | 2 +- webservices/launch_cron_asynchronously.php | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/webservices/cron_status.php b/webservices/cron_status.php index e523e154df..a47963b285 100644 --- a/webservices/cron_status.php +++ b/webservices/cron_status.php @@ -23,7 +23,7 @@ try { $sMsg = ""; $sLogFile = APPROOT."log/$sLogFilename"; - $aLines = Utils::ReadTail($sLogFile, 2); + $aLines = utils::ReadTail($sLogFile, 2); $sLastLine = $aLines[1] ?? ''; if (0 === strpos($sLastLine, 'Exiting: ')) { $sContent = $aLines[0]; diff --git a/webservices/launch_cron_asynchronously.php b/webservices/launch_cron_asynchronously.php index 1f5eb88311..88558aeefc 100644 --- a/webservices/launch_cron_asynchronously.php +++ b/webservices/launch_cron_asynchronously.php @@ -66,17 +66,16 @@ try { $sPHPExec = trim(\MetaModel::GetConfig()->Get('php_path')); $sCliForLogs = GetCliCommand($sPHPExec, $sLogFile, $aCronValues).PHP_EOL; - file_put_contents("$sLogFile", $sCliForLogs); - if (! is_file($sLogFile)) { - throw new \Exception("Cannot write in $sLogFile"); - } + IssueLog::Info("launch cron asynchronously/remotely", null, ['cli' => $sCliForLogs]); $aCronValues[] = "--auth_info=".escapeshellarg($sTokenInfo); $sCli = GetCliCommand($sPHPExec, $sLogFile, $aCronValues); $process = popen($sCli, 'r'); + if (false === $process){ + throw new \Exception("CLI execution issue"); + } - $i = 0; - while ($aLines = Utils::ReadTail($sLogFile)) { + while ($aLines = utils::ReadTail($sLogFile)) { $sLastLine = array_shift($aLines); if (IsErrorLine($sLastLine) || IsCronStartingLine($sLastLine)) { //return answer once we are sure cron is starting or did not pass authentication