* don't want to miss the automated error handling mechanism of the
* queue.
*
- * @param AbstractBackgroundJob $job The job to perform.
+ * @param AbstractBackgroundJob $job The job to perform.
+ * @param boolean $debugSynchronousExecution Disables fail-safe mechanisms, errors will no longer be suppressed.
*/
- public function performJob(AbstractBackgroundJob $job) {
+ public function performJob(AbstractBackgroundJob $job, $debugSynchronousExecution = false) {
$user = WCF::getUser();
try {
$job->perform();
}
catch (\Throwable $e) {
+ // do not suppress exceptions for debugging purposes, see https://github.com/WoltLab/WCF/issues/2501
+ if ($debugSynchronousExecution) {
+ throw $e;
+ }
+
// gotta catch 'em all
$job->fail();
}
}
catch (\Exception $e) {
+ // do not suppress exceptions for debugging purposes, see https://github.com/WoltLab/WCF/issues/2501
+ if ($debugSynchronousExecution) {
+ throw $e;
+ }
+
// gotta catch 'em all
$job->fail();
*/
public function send() {
$jobs = $this->getJobs();
- BackgroundQueueHandler::getInstance()->enqueueIn($jobs);
- BackgroundQueueHandler::getInstance()->forceCheck();
+
+ // force synchronous execution, see https://github.com/WoltLab/WCF/issues/2501
+ if (ENABLE_DEBUG_MODE && ENABLE_DEVELOPER_TOOLS) {
+ foreach ($jobs as $job) {
+ BackgroundQueueHandler::getInstance()->performJob($job);
+ }
+ }
+ else {
+ BackgroundQueueHandler::getInstance()->enqueueIn($jobs);
+ BackgroundQueueHandler::getInstance()->forceCheck();
+ }
}
/**