diff options
author | Jakob Sack <mail@jakobsack.de> | 2012-08-09 23:49:20 +0200 |
---|---|---|
committer | Jakob Sack <mail@jakobsack.de> | 2012-08-09 23:49:20 +0200 |
commit | 7b3c35107d95b3b3ea391e0131ae794411a97128 (patch) | |
tree | ce1b62137cf5c173863cb49695e7f0b4027922fc /cron.php | |
parent | f46fdfd814de7a43af94cad1dcf456e65350f254 (diff) | |
download | nextcloud-server-7b3c35107d95b3b3ea391e0131ae794411a97128.tar.gz nextcloud-server-7b3c35107d95b3b3ea391e0131ae794411a97128.zip |
Error handling works better now
Diffstat (limited to 'cron.php')
-rw-r--r-- | cron.php | 28 |
1 files changed, 16 insertions, 12 deletions
@@ -20,17 +20,19 @@ * */ -function handleCliShutdown() { - $error = error_get_last(); - if($error !== NULL){ - echo 'Unexpected error!'.PHP_EOL; - } +// Unfortunately we need this class for shutdown function +class my_temporary_cron_class { + public static $sent = false; } -function handleWebShutdown(){ - $error = error_get_last(); - if($error !== NULL){ - OC_JSON::error( array( 'data' => array( 'message' => 'Unexpected error!'))); +function handleUnexpectedShutdown() { + if( !my_temporary_cron_class::$sent ){ + if( OC::$CLI ){ + echo 'Unexpected error!'.PHP_EOL; + } + else{ + OC_JSON::error( array( 'data' => array( 'message' => 'Unexpected error!'))); + } } } @@ -59,9 +61,11 @@ else{ register_shutdown_function('handleWebShutdown'); if( $appmode == 'cron' ){ OC_JSON::error( array( 'data' => array( 'message' => 'Backgroundjobs are using system cron!'))); - exit(); } - OC_BackgroundJob_Worker::doNextStep(); - OC_JSON::success(); + else{ + OC_BackgroundJob_Worker::doNextStep(); + OC_JSON::success(); + } } +my_temporary_cron_class::$sent = true; exit(); |