Catch \Throwable in BackgroundQueueHandler
authorTim Düsterhus <duesterhus@woltlab.com>
Wed, 6 Jan 2016 17:04:57 +0000 (18:04 +0100)
committerTim Düsterhus <duesterhus@woltlab.com>
Wed, 6 Jan 2016 17:04:57 +0000 (18:04 +0100)
wcfsetup/install/files/lib/system/background/BackgroundQueueHandler.class.php

index 071161a84f039c08fb413f1e9d7677e082b3a573..1d300f8e99d58876f1c97b5262c9eff1d5ce6ebb 100644 (file)
@@ -92,6 +92,18 @@ class BackgroundQueueHandler extends SingletonFactory {
                        SessionHandler::getInstance()->changeUser(new User(null), true);
                        $job->perform();
                }
+               catch (\Throwable $e) {
+                       // gotta catch 'em all
+                       $job->fail();
+                       
+                       if ($job->getFailures() <= $job::MAX_FAILURES) {
+                               $this->enqueueIn($job, $job->retryAfter());
+                       }
+                       else {
+                               // job failed too often: log
+                               \wcf\functions\exception\logThrowable($e);
+                       }
+               }
                catch (\Exception $e) {
                        // gotta catch 'em all
                        $job->fail();
@@ -168,6 +180,10 @@ class BackgroundQueueHandler extends SingletonFactory {
                                $this->performJob($job);
                        }
                }
+               catch (\Throwable $e) {
+                       // job is completely broken: log
+                       \wcf\functions\exception\logThrowable($e);
+               }
                catch (\Exception $e) {
                        // job is completely broken: log
                        \wcf\functions\exception\logThrowable($e);