Skip to content
Code-Schnipsel Gruppen Projekte
Commit 73e00022 erstellt von Henning Leutz's avatar Henning Leutz :martial_arts_uniform:
Dateien durchsuchen

fix(phpstan): improve cron execution and error handling

Summary of changes:
- Removed redundant PHPDoc from `ExecCrons` class.
- Ensured the input `cronId` is cast to an integer before calling `runCron` in `ExecCrons` class.
- Removed extraneous details from PHPDoc in `Manager` class.
- Added more robust checking for parameters in `Manager` class.
- Included method existence check for `deactivate` before calling it in `QuiqqerCrons` class.

These changes contribute towards improving cron execution and handling potential errors more
gracefully.

Related: #57
Übergeordneter dde17568
No related branches found
No related tags found
2 Merge Requests!24Update 'next-3.x' with latest changes from 'main',!23chore(phpstan): update phpstan version and clear phpstan baseline
Pipeline #15955 bestanden mit Phase
in 1 Minute und 37 Sekunden
......@@ -22,8 +22,6 @@ class ExecCrons extends QUI\System\Console\Tool
}
/**
* (non-PHPdoc)
*
* @throws Exception
* @see \QUI\System\Console\Tool::execute()
*/
......@@ -101,7 +99,7 @@ class ExecCrons extends QUI\System\Console\Tool
$cronId = $this->readInput();
try {
$this->runCron($cronId);
$this->runCron((int)$cronId);
} catch (QUI\Exception $Exception) {
$this->writeLn($Exception->getMessage(), 'red');
$this->resetColor();
......
......@@ -410,9 +410,6 @@ class Manager
/**
* Execute a cron
*
* @param integer $cronId - ID of the cron
*
* @return Manager
* @throws QUI\Exception
*/
public function executeCron(int $cronId): static
......@@ -822,7 +819,11 @@ class Manager
for ($j = 0; $j < $Params->length; $j++) {
$ParamsNode = $Params->item($j);
if ($ParamsNode->parentNode && $ParamsNode->parentNode->tagName === 'cron') {
if (
$ParamsNode->parentNode
&& isset($ParamsNode->parentNode->tagName)
&& $ParamsNode->parentNode->tagName === 'cron'
) {
$CronParams = $ParamsNode->getElementsByTagName('param');
break;
}
......
......@@ -192,7 +192,10 @@ class QuiqqerCrons
foreach ($result as $entry) {
try {
$Site = $Project->get((int)$entry['id']);
$Site->deactivate();
if (method_exists($Site, 'deactivate')) {
$Site->deactivate();
}
$deactivate[] = (int)$entry['id'];
} catch (QUI\Exception $Exception) {
......
0% oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren