From f7688a224bec8600fcf653dd3442badd5be333d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Mon, 28 Aug 2023 11:09:11 +0200 Subject: [PATCH] Added try-catch to shell/extendedgitgraph_refresh --- www/shell/extendedgitgraph_refresh.php | 107 +++++++++++++++---------- 1 file changed, 63 insertions(+), 44 deletions(-) diff --git a/www/shell/extendedgitgraph_refresh.php b/www/shell/extendedgitgraph_refresh.php index a71010a..ad1be2b 100644 --- a/www/shell/extendedgitgraph_refresh.php +++ b/www/shell/extendedgitgraph_refresh.php @@ -9,58 +9,77 @@ ini_set("display_errors", 1); ini_set("display_startup_errors", 1); error_reporting(E_ALL); -echo "\n"; -echo "==================================== Init ====================================\n"; -echo "\n"; +try { -$config = (require (__DIR__ . '/../config.php'))['extendedgitgraph']; -$config['output_session'] = false; -$config['output_file'] = false; -$config['output_stdout'] = true; + echo "\n"; + echo "==================================== Init ====================================\n"; + echo "\n"; -require_once __DIR__ .'/../internals/modules/mikeschergitgraph.php'; + $config = (require (__DIR__ . '/../config.php'))['extendedgitgraph']; + $config['output_session'] = false; + $config['output_file'] = false; + $config['output_stdout'] = true; -$egg = new MikescherGitGraph($config); + require_once __DIR__ .'/../internals/modules/mikeschergitgraph.php'; -echo "\n"; -echo "================================ Start Update ================================\n"; -echo "\n"; + $egg = new MikescherGitGraph($config); -$r1 = $egg->update(); -if (!$r1) -{ - echo "EGG::update failed.\n"; - exit(99); -} + echo "\n"; + echo "================================ Start Update ================================\n"; + echo "\n"; -echo "\n"; -echo "============================= Check Consistency =============================\n"; -echo "\n"; - -$r2 = $egg->checkDatabaseConsistency(); -if (count($r2) > 0) -{ - echo "EGG::updateCache failed.\n"; - foreach ($r2 as $msg) { - echo " > $msg\n"; + $r1 = $egg->update(); + if (!$r1) + { + echo "EGG::update failed.\n"; + exit(99); } - exit(99); -} -echo "\n"; -echo "============================= Update Cache =============================\n"; -echo "\n"; + echo "\n"; + echo "============================= Check Consistency =============================\n"; + echo "\n"; -$r3 = $egg->updateCache(); -if (!$r3) -{ - echo "EGG::updateCache failed."; - exit(99); -} + $r2 = $egg->checkDatabaseConsistency(); + if (count($r2) > 0) + { + echo "EGG::updateCache failed.\n"; + foreach ($r2 as $msg) { + echo " > $msg\n"; + } + exit(99); + } -echo "\n"; -echo "==============================================================================\n"; -echo "\n"; + echo "\n"; + echo "============================= Update Cache =============================\n"; + echo "\n"; -echo "Done.\n"; -exit(0); \ No newline at end of file + $r3 = $egg->updateCache(); + if (!$r3) + { + echo "EGG::updateCache failed."; + exit(99); + } + + echo "\n"; + echo "==============================================================================\n"; + echo "\n"; + + echo "Done.\n"; + exit(0); + +} catch (Throwable $throwable) { + + echo ""; + echo "[!] Caught Eception"; + echo ""; + + echo $throwable->getMessage(); + echo $throwable->getFile() . " : " . $throwable->getLine(); + echo ""; + echo $throwable->getTraceAsString(); + + echo ""; + echo ""; + + throw $throwable; +} \ No newline at end of file