From b35e2cb8a078d809976b2191d6bc18791ec7d9c9 Mon Sep 17 00:00:00 2001 From: Natanael Arndt Date: Thu, 26 May 2016 18:59:02 +0200 Subject: [PATCH] Refactor usage of exit to using return --- application/shell.worker.client.php | 12 ++++++++---- application/shell.worker.php | 13 ++++++++----- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/application/shell.worker.client.php b/application/shell.worker.client.php index 37e76fb56..6aadc9782 100755 --- a/application/shell.worker.client.php +++ b/application/shell.worker.client.php @@ -119,7 +119,7 @@ function initApp() header('HTTP/1.1 500 Internal Server Error'); echo 'Fatal Error: Could not load Zend library.
' . PHP_EOL . 'Maybe you need to install it with apt-get or with "make zend"?' . PHP_EOL; - exit; + return false; } // create application @@ -135,7 +135,7 @@ function initApp() } catch (Exception $e) { echo 'Fatal Error: Could not load the OntoWiki Application Framework classes.' . PHP_EOL; echo 'Your installation directory seems to be screwed.' . PHP_EOL; - exit; + return false; } /* check/include Erfurt_App */ @@ -145,7 +145,7 @@ function initApp() } catch (Exception $e) { echo 'Fatal Error: Could not load the Erfurt Framework classes.' . PHP_EOL; echo 'Maybe you should install it with apt-get or with "make deploy"?' . PHP_EOL; - exit; + return false; } // restore old error handler @@ -156,12 +156,16 @@ function initApp() $application->bootstrap(); } catch (Exception $e) { echo 'Error on bootstrapping application: ' . $e->getMessage() . PHP_EOL; - exit; + return false; } return $application; } $application = initApp(); +if ($application === false) { + return 1; +} + $ontowiki = OntoWiki::getInstance(); echo $ontowiki->config->version->label . ' ' . $ontowiki->config->version->number . PHP_EOL; diff --git a/application/shell.worker.php b/application/shell.worker.php index 3a686a2ed..a443f4c4d 100755 --- a/application/shell.worker.php +++ b/application/shell.worker.php @@ -114,7 +114,7 @@ function initApp() header('HTTP/1.1 500 Internal Server Error'); echo 'Fatal Error: Could not load Zend library.
' . PHP_EOL . 'Maybe you need to install it with apt-get or with "make zend"?' . PHP_EOL; - exit; + return false; } // create application @@ -130,7 +130,7 @@ function initApp() } catch (Exception $e) { echo 'Fatal Error: Could not load the OntoWiki Application Framework classes.' . PHP_EOL; echo 'Your installation directory seems to be screwed.' . PHP_EOL; - exit; + return false; } /* check/include Erfurt_App */ @@ -140,7 +140,7 @@ function initApp() } catch (Exception $e) { echo 'Fatal Error: Could not load the Erfurt Framework classes.' . PHP_EOL; echo 'Maybe you should install it with apt-get or with "make deploy"?' . PHP_EOL; - exit; + return false; } // restore old error handler @@ -151,12 +151,15 @@ function initApp() $application->bootstrap(); } catch (Exception $e) { echo 'Error on bootstrapping application: ' . $e->getMessage() . PHP_EOL; - exit; + return false; } return $application; } $application = initApp(); +if ($application === false) { + return 1; +} $bootstrap = $application->getBootstrap(); $ontoWiki = OntoWiki::getInstance(); @@ -175,7 +178,7 @@ function initApp() $event->trigger(); if (!count($workerRegistry->getJobs())) { echo 'No jobs registered - nothing to do or wait for.' . PHP_EOL; - exit; + return; } // register jobs manually