From a784f34c5216b523caaad7196a3d2aee4b60fe4e Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Thu, 9 Jul 2015 18:51:36 +0200 Subject: [PATCH] Moved background queue invocation into `BootstrapFrontend` --- .../templates/headIncludeJavaScript.tpl | 13 +------------ .../files/js/WoltLab/WCF/BootstrapFrontend.js | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/com.woltlab.wcf/templates/headIncludeJavaScript.tpl b/com.woltlab.wcf/templates/headIncludeJavaScript.tpl index 31d878d4c5..7c73cbe892 100644 --- a/com.woltlab.wcf/templates/headIncludeJavaScript.tpl +++ b/com.woltlab.wcf/templates/headIncludeJavaScript.tpl @@ -102,6 +102,7 @@ requirejs.config({ }); BootstrapFrontend.setup({ + backgroundQueueUrl: '{link controller="BackgroundQueuePerform"}{/link}', styleChanger: {if $__wcf->getStyleHandler()->countStyles() > 1}true{else}false{/if} }); }); @@ -193,18 +194,6 @@ requirejs.config({ }); {/if} - {* invoke background queue roughly every 10th request *} - if (Math.random() < 0.1) { - 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/js/WoltLab/WCF/BootstrapFrontend.js b/wcfsetup/install/files/js/WoltLab/WCF/BootstrapFrontend.js index b223f21115..c1784db8da 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/BootstrapFrontend.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/BootstrapFrontend.js @@ -37,6 +37,7 @@ define( } this._initUserPopover(); + this._invokeBackgroundQueue(options.backgroundQueueUrl); }, /** @@ -59,6 +60,22 @@ define( }, callback, callback); } }); + }, + + /** + * Invokes the background queue roughly every 10th request. + * + * @param {string} url background queue url + */ + _invokeBackgroundQueue: function(url) { + if (Math.random() < 0.1) { + // 'fire and forget' background queue perform task + Ajax.apiOnce({ + url: url, + ignoreError: true, + silent: true + }); + } } }; -- 2.20.1