Skip to content

Commit e1096bb

Browse files
committed
migrate to WSC 6 api
1 parent e48ae61 commit e1096bb

File tree

3 files changed

+27
-13
lines changed

3 files changed

+27
-13
lines changed

files/cron.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
<?php
22

3-
// phpcs:disable PSR1.Files.SideEffects
4-
5-
\define('PACKAGE_ID', 1);
63
require_once(__DIR__ . '/global.php');
4+
75
use wcf\data\application\ApplicationList;
8-
use wcf\data\cronjob\CronjobAction;
6+
use wcf\data\user\User;
97
use wcf\system\background\BackgroundQueueHandler;
8+
use wcf\system\cronjob\CronjobScheduler;
109
use wcf\system\WCF;
1110

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

20-
$action = new CronjobAction([], 'executeCronjobs');
21-
$action->executeAction();
19+
WCF::getSession()->changeUser(new User(null, [
20+
'userID' => 0,
21+
'username' => 'System',
22+
]), true);
23+
WCF::getSession()->disableUpdate();
24+
25+
CronjobScheduler::getInstance()->executeCronjobs();
2226

2327
// send up to 5 outstanding mails
2428
$limit = \min(5, BackgroundQueueHandler::getInstance()->getRunnableCount());

files/lib/action/CronjobExecuteAction.class.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
namespace wcf\action;
44

5-
use wcf\data\cronjob\CronjobAction;
5+
use wcf\data\user\User;
6+
use wcf\system\cronjob\CronjobScheduler;
7+
use wcf\system\WCF;
68

79
/**
810
* executes cronjobs on page calls - or prevents execution
@@ -22,7 +24,12 @@ public function execute()
2224
{
2325
parent::execute();
2426

25-
$action = new CronjobAction([], 'executeCronjobs');
26-
$action->executeAction();
27+
WCF::getSession()->changeUser(new User(null, [
28+
'userID' => 0,
29+
'username' => 'System',
30+
]), true);
31+
WCF::getSession()->disableUpdate();
32+
33+
CronjobScheduler::getInstance()->executeCronjobs();
2734
}
2835
}

package.xml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44
<!-- de.mysterycode.wcf.cron -->
55
<packagename>External Cronjob Execution API</packagename>
66
<packagedescription>Disables automatic cronjob execution and implements a script callable via browser or shell.</packagedescription>
7-
<version>1.1.4</version>
8-
<date>2023-03-31</date>
7+
<version>1.1.5</version>
8+
<date>2024-09-14</date>
99
</packageinformation>
1010
<authorinformation>
1111
<author>Florian Gail, Morik</author>
1212
<authorurl>https://www.mysterycode.de</authorurl>
1313
</authorinformation>
1414
<requiredpackages>
15-
<requiredpackage minversion="5.5.0">com.woltlab.wcf</requiredpackage>
15+
<requiredpackage minversion="6.0.17">com.woltlab.wcf</requiredpackage>
1616
</requiredpackages>
1717
<excludedpackages>
18-
<excludedpackage version="6.1.0 Alpha 1">com.woltlab.wcf</excludedpackage>
18+
<excludedpackage version="6.2.0 dev 1">com.woltlab.wcf</excludedpackage>
1919
</excludedpackages>
2020
<instructions type="install">
2121
<instruction type="file"/>
@@ -27,4 +27,7 @@
2727
<instruction type="file"/>
2828
<instruction type="language"/>
2929
</instructions>
30+
<instructions type="update" fromversion="1.1.4">
31+
<instruction type="file"/>
32+
</instructions>
3033
</package>

0 commit comments

Comments
 (0)