From 87a78af60cb286e3b1be45ed5d8223fa90d10f7f Mon Sep 17 00:00:00 2001 From: Robin Kluth Date: Wed, 27 Sep 2023 20:51:50 +0200 Subject: [PATCH] return any errors during update_cron execution --- src/include/ABSettings.php | 4 +++- src/pages/content/settings.php | 6 +++++- src/scripts/checkCron.php | 10 ++++++++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/include/ABSettings.php b/src/include/ABSettings.php index 11c89b1..e974aef 100644 --- a/src/include/ABSettings.php +++ b/src/include/ABSettings.php @@ -235,7 +235,9 @@ public function checkCron() { unlink(ABSettings::$pluginDir . '/' . ABSettings::$cronFile); } // Let dcron know our changes via update_cron - exec("update_cron"); + $out = $code = 0; + exec("update_cron", $out, $code); + return [$code, $out]; } } diff --git a/src/pages/content/settings.php b/src/pages/content/settings.php index 61f861b..ae723cd 100644 --- a/src/pages/content/settings.php +++ b/src/pages/content/settings.php @@ -122,7 +122,7 @@ $abSettings = new ABSettings(); if ($_POST) { - $abSettings->checkCron(); + list($code, $out) = $abSettings->checkCron(); } @@ -209,6 +209,10 @@ HTML; } + +if ($code != 0) { + echo "

Cron error!

" . implode('; ', $out) . "

"; +} ?>
diff --git a/src/scripts/checkCron.php b/src/scripts/checkCron.php index a5e2b42..d946b59 100644 --- a/src/scripts/checkCron.php +++ b/src/scripts/checkCron.php @@ -7,8 +7,14 @@ echo "Checking cron." . PHP_EOL; $abSettings = new ABSettings(); -$abSettings->checkCron(); +list($code, $out) = $abSettings->checkCron(); + +if ($code == 0) { + echo "Checking cron succeeded!" . PHP_EOL; +} else { + echo "Error occurred: " . implode('; ', $out); +} + -echo "Checking cron succeeded!" . PHP_EOL; exit(0); \ No newline at end of file