Skip to content

Commit

Permalink
migrate to WSC 6 api
Browse files Browse the repository at this point in the history
  • Loading branch information
mutec committed Sep 14, 2024
1 parent e48ae61 commit e1096bb
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
16 changes: 10 additions & 6 deletions files/cron.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<?php

// phpcs:disable PSR1.Files.SideEffects

\define('PACKAGE_ID', 1);
require_once(__DIR__ . '/global.php');

use wcf\data\application\ApplicationList;
use wcf\data\cronjob\CronjobAction;
use wcf\data\user\User;
use wcf\system\background\BackgroundQueueHandler;
use wcf\system\cronjob\CronjobScheduler;
use wcf\system\WCF;

if (!\defined('OFFLINE') || !OFFLINE) {
Expand All @@ -17,8 +16,13 @@
WCF::loadRuntimeApplication($application->packageID);
}

$action = new CronjobAction([], 'executeCronjobs');
$action->executeAction();
WCF::getSession()->changeUser(new User(null, [
'userID' => 0,
'username' => 'System',
]), true);
WCF::getSession()->disableUpdate();

CronjobScheduler::getInstance()->executeCronjobs();

// send up to 5 outstanding mails
$limit = \min(5, BackgroundQueueHandler::getInstance()->getRunnableCount());
Expand Down
13 changes: 10 additions & 3 deletions files/lib/action/CronjobExecuteAction.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

namespace wcf\action;

use wcf\data\cronjob\CronjobAction;
use wcf\data\user\User;
use wcf\system\cronjob\CronjobScheduler;
use wcf\system\WCF;

/**
* executes cronjobs on page calls - or prevents execution
Expand All @@ -22,7 +24,12 @@ public function execute()
{
parent::execute();

$action = new CronjobAction([], 'executeCronjobs');
$action->executeAction();
WCF::getSession()->changeUser(new User(null, [
'userID' => 0,
'username' => 'System',
]), true);
WCF::getSession()->disableUpdate();

CronjobScheduler::getInstance()->executeCronjobs();
}
}
11 changes: 7 additions & 4 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
<!-- de.mysterycode.wcf.cron -->
<packagename>External Cronjob Execution API</packagename>
<packagedescription>Disables automatic cronjob execution and implements a script callable via browser or shell.</packagedescription>
<version>1.1.4</version>
<date>2023-03-31</date>
<version>1.1.5</version>
<date>2024-09-14</date>
</packageinformation>
<authorinformation>
<author>Florian Gail, Morik</author>
<authorurl>https://www.mysterycode.de</authorurl>
</authorinformation>
<requiredpackages>
<requiredpackage minversion="5.5.0">com.woltlab.wcf</requiredpackage>
<requiredpackage minversion="6.0.17">com.woltlab.wcf</requiredpackage>
</requiredpackages>
<excludedpackages>
<excludedpackage version="6.1.0 Alpha 1">com.woltlab.wcf</excludedpackage>
<excludedpackage version="6.2.0 dev 1">com.woltlab.wcf</excludedpackage>
</excludedpackages>
<instructions type="install">
<instruction type="file"/>
Expand All @@ -27,4 +27,7 @@
<instruction type="file"/>
<instruction type="language"/>
</instructions>
<instructions type="update" fromversion="1.1.4">
<instruction type="file"/>
</instructions>
</package>

0 comments on commit e1096bb

Please sign in to comment.