From 54de7a5f630ec14d728a8a1838f6c0d6db5af334 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Wed, 19 Apr 2017 15:25:31 +0200 Subject: [PATCH] Make BackgroundQueueHandler::forceCheck() more resilient Closes #2251 --- wcfsetup/install/files/lib/system/WCF.class.php | 13 +++++++++++++ .../background/BackgroundQueueHandler.class.php | 2 ++ 2 files changed, 15 insertions(+) diff --git a/wcfsetup/install/files/lib/system/WCF.class.php b/wcfsetup/install/files/lib/system/WCF.class.php index b4694238ef..1552710914 100644 --- a/wcfsetup/install/files/lib/system/WCF.class.php +++ b/wcfsetup/install/files/lib/system/WCF.class.php @@ -620,6 +620,19 @@ class WCF { '__wcf' => $this, '__wcfVersion' => LAST_UPDATE_TIME // @deprecated 2.1, use LAST_UPDATE_TIME directly ]); + + $isAjax = isset($_SERVER['HTTP_X_REQUESTED_WITH']) && ($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'); + // Execute background queue in this request, if it was requested and AJAX isn't used. + if (!$isAjax) { + if (self::getSession()->getVar('forceBackgroundQueuePerform')) { + self::getTPL()->assign([ + 'forceBackgroundQueuePerform' => true + ]); + + self::getSession()->unregister('forceBackgroundQueuePerform'); + } + } + EmailTemplateEngine::getInstance()->registerPrefilter(['event', 'hascontent', 'lang']); EmailTemplateEngine::getInstance()->assign([ '__wcf' => $this diff --git a/wcfsetup/install/files/lib/system/background/BackgroundQueueHandler.class.php b/wcfsetup/install/files/lib/system/background/BackgroundQueueHandler.class.php index c2b62efd1d..6ae3f32f1b 100644 --- a/wcfsetup/install/files/lib/system/background/BackgroundQueueHandler.class.php +++ b/wcfsetup/install/files/lib/system/background/BackgroundQueueHandler.class.php @@ -22,6 +22,8 @@ class BackgroundQueueHandler extends SingletonFactory { * This means that the AJAX request to BackgroundQueuePerformAction is triggered. */ public function forceCheck() { + WCF::getSession()->register('forceBackgroundQueuePerform', true); + WCF::getTPL()->assign([ 'forceBackgroundQueuePerform' => true ]); -- 2.20.1