From: Tim Düsterhus Date: Sun, 21 Jun 2015 12:26:38 +0000 (+0200) Subject: Perform background tasks via AJAX request X-Git-Tag: 3.0.0_Beta_1~2249^2~3^2~2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=1b0e255b8f23a1306efc92db96d1a563e94c8866;p=GitHub%2FWoltLab%2FWCF.git Perform background tasks via AJAX request --- diff --git a/com.woltlab.wcf/templates/headIncludeJavaScript.tpl b/com.woltlab.wcf/templates/headIncludeJavaScript.tpl index 580f9c5fc2..c29524d520 100644 --- a/com.woltlab.wcf/templates/headIncludeJavaScript.tpl +++ b/com.woltlab.wcf/templates/headIncludeJavaScript.tpl @@ -226,6 +226,16 @@ requirejs.config({ } }); {/if} + + require(['Ajax'], function(Ajax) { + // fire and forget background queue perform task + Ajax.apiOnce({ + url: '{link controller="BackgroundQueuePerform"}{/link}', + ignoreError: true, + silent: true + }); + }); + {if $__sessionKeepAlive|isset} new WCF.System.KeepAlive({@$__sessionKeepAlive}); {/if} diff --git a/wcfsetup/install/files/lib/action/BackgroundQueuePerformAction.class.php b/wcfsetup/install/files/lib/action/BackgroundQueuePerformAction.class.php new file mode 100644 index 0000000000..beffea8a47 --- /dev/null +++ b/wcfsetup/install/files/lib/action/BackgroundQueuePerformAction.class.php @@ -0,0 +1,26 @@ + + * @package com.woltlab.wcf + * @subpackage action + * @category Community Framework + */ +class BackgroundQueuePerformAction extends AbstractAction { + /** + * @see \wcf\action\IAction::execute() + */ + public function execute() { + parent::execute(); + + @header('HTTP/1.1 204 No Content'); + BackgroundQueueHandler::getInstance()->performNextJob(); + exit; + } +}