Move cronjob execution to `BootstrapFrontend` and use `Ajax` module
authorMatthias Schmidt <gravatronics@live.com>
Sat, 20 Mar 2021 12:37:38 +0000 (13:37 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Sat, 20 Mar 2021 12:37:38 +0000 (13:37 +0100)
com.woltlab.wcf/templates/headIncludeJavaScript.tpl
ts/WoltLabSuite/Core/BootstrapFrontend.ts
wcfsetup/install/files/js/WoltLabSuite/Core/BootstrapFrontend.js

index 814fef7aae066b32fb12d829e1b64a029acf9987..ae8b25ec12c2ed25ec14be962e76b0d387a5ed6a 100644 (file)
@@ -151,6 +151,7 @@ window.addEventListener('pageshow', function(event) {
                                force: {if $forceBackgroundQueuePerform|isset}true{else}false{/if}
                        },
                        enableUserPopover: {if $__wcf->getSession()->getPermission('user.profile.canViewUserProfile')}true{else}false{/if},
+                       executeCronjobs: {if $executeCronjobs}true{else}false{/if},
                        styleChanger: {if $__wcf->getStyleHandler()->showStyleChanger()}true{else}false{/if}
                });
                
@@ -225,20 +226,6 @@ window.addEventListener('pageshow', function(event) {
                
                {event name='javascriptInit'}
                
-               {if $executeCronjobs}
-                       new WCF.Action.Proxy({
-                               autoSend: true,
-                               data: {
-                                       className: 'wcf\\data\\cronjob\\CronjobAction',
-                                       actionName: 'executeCronjobs'
-                               },
-                               showLoadingOverlay: false,
-                               failure: function() {
-                                       return false;
-                               }
-                       });
-               {/if}
-               
                {if ENABLE_POLLING && $__wcf->user->userID}
                        require(['WoltLabSuite/Core/Notification/Handler'], function(NotificationHandler) {
                                NotificationHandler.setup({
index 07c2e563eff390dccf42827b0d5e47e6b423b9e6..658626f7e12242b0df34bef73d61be94200412bb 100644 (file)
@@ -14,6 +14,7 @@ import * as ControllerPopover from "./Controller/Popover";
 import * as UiUserIgnore from "./Ui/User/Ignore";
 import * as UiPageHeaderMenu from "./Ui/Page/Header/Menu";
 import * as UiMessageUserConsent from "./Ui/Message/UserConsent";
+import * as Ajax from "./Ajax";
 
 interface BoostrapOptions {
   backgroundQueue: {
@@ -21,6 +22,7 @@ interface BoostrapOptions {
     force: boolean;
   };
   enableUserPopover: boolean;
+  executeCronjobs: boolean;
   styleChanger: boolean;
 }
 
@@ -61,6 +63,17 @@ export function setup(options: BoostrapOptions): void {
     _initUserPopover();
   }
 
+  if (options.executeCronjobs) {
+    Ajax.apiOnce({
+      data: {
+        className: "wcf\\data\\cronjob\\CronjobAction",
+        actionName: "executeCronjobs",
+      },
+      failure: () => false,
+      silent: true,
+    });
+  }
+
   BackgroundQueue.setUrl(options.backgroundQueue.url);
   if (Math.random() < 0.1 || options.backgroundQueue.force) {
     // invoke the queue roughly every 10th request or on demand
index 2c370e197053974f72a6a089723afa855a65eeb7..381c737dc7718fa392a20e3955920c9988fa034a 100644 (file)
@@ -6,7 +6,7 @@
  * @license  GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @module  WoltLabSuite/Core/BootstrapFrontend
  */
-define(["require", "exports", "tslib", "./BackgroundQueue", "./Bootstrap", "./Controller/Style/Changer", "./Controller/Popover", "./Ui/User/Ignore", "./Ui/Page/Header/Menu", "./Ui/Message/UserConsent"], function (require, exports, tslib_1, BackgroundQueue, Bootstrap, ControllerStyleChanger, ControllerPopover, UiUserIgnore, UiPageHeaderMenu, UiMessageUserConsent) {
+define(["require", "exports", "tslib", "./BackgroundQueue", "./Bootstrap", "./Controller/Style/Changer", "./Controller/Popover", "./Ui/User/Ignore", "./Ui/Page/Header/Menu", "./Ui/Message/UserConsent", "./Ajax"], function (require, exports, tslib_1, BackgroundQueue, Bootstrap, ControllerStyleChanger, ControllerPopover, UiUserIgnore, UiPageHeaderMenu, UiMessageUserConsent, Ajax) {
     "use strict";
     Object.defineProperty(exports, "__esModule", { value: true });
     exports.setup = void 0;
@@ -17,6 +17,7 @@ define(["require", "exports", "tslib", "./BackgroundQueue", "./Bootstrap", "./Co
     UiUserIgnore = tslib_1.__importStar(UiUserIgnore);
     UiPageHeaderMenu = tslib_1.__importStar(UiPageHeaderMenu);
     UiMessageUserConsent = tslib_1.__importStar(UiMessageUserConsent);
+    Ajax = tslib_1.__importStar(Ajax);
     /**
      * Initializes user profile popover.
      */
@@ -48,6 +49,16 @@ define(["require", "exports", "tslib", "./BackgroundQueue", "./Bootstrap", "./Co
         if (options.enableUserPopover) {
             _initUserPopover();
         }
+        if (options.executeCronjobs) {
+            Ajax.apiOnce({
+                data: {
+                    className: "wcf\\data\\cronjob\\CronjobAction",
+                    actionName: "executeCronjobs",
+                },
+                failure: () => false,
+                silent: true,
+            });
+        }
         BackgroundQueue.setUrl(options.backgroundQueue.url);
         if (Math.random() < 0.1 || options.backgroundQueue.force) {
             // invoke the queue roughly every 10th request or on demand