]> source.dussan.org Git - nextcloud-server.git/commitdiff
Error handling works better now
authorJakob Sack <mail@jakobsack.de>
Thu, 9 Aug 2012 21:49:20 +0000 (23:49 +0200)
committerJakob Sack <mail@jakobsack.de>
Thu, 9 Aug 2012 21:49:20 +0000 (23:49 +0200)
cron.php

index 646e37e4c1c93cfe2b4901568e4eee7bbc7c8109..cb01152360be797a078bde21d886279cdad06869 100644 (file)
--- a/cron.php
+++ b/cron.php
 *
 */
 
-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();