Skip to content

Commit 4f07584

Browse files
authored
Merge pull request #6565 from WoltLab/62-last-update-time-command
Add a command for the update of `LAST_UPDATE_TIME`
2 parents ff42166 + c68a2b8 commit 4f07584

4 files changed

Lines changed: 42 additions & 18 deletions

File tree

wcfsetup/install/files/lib/command/language/preload/ResetPreloadCache.class.php

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

33
namespace wcf\command\language\preload;
44

5+
use wcf\command\package\SetLastUpdateTime;
56
use wcf\data\language\Language;
67

78
/**
@@ -25,5 +26,7 @@ public function __invoke(): void
2526
if (\file_exists($filename)) {
2627
\unlink($filename);
2728
}
29+
30+
(new SetLastUpdateTime())();
2831
}
2932
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
namespace wcf\command\package;
4+
5+
use wcf\data\option\OptionEditor;
6+
use wcf\system\WCF;
7+
8+
/**
9+
* Updates the `LAST_UPDATE_TIME` constant.
10+
*
11+
* @author Marcel Werk
12+
* @copyright 2001-2026 WoltLab GmbH
13+
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
14+
* @since 6.2
15+
*/
16+
final class SetLastUpdateTime
17+
{
18+
public function __construct(
19+
private readonly int $time = \TIME_NOW
20+
) {}
21+
22+
public function __invoke(): void
23+
{
24+
$sql = "UPDATE wcf1_option
25+
SET optionValue = ?
26+
WHERE optionName = ?";
27+
$statement = WCF::getDB()->prepare($sql);
28+
$statement->execute([
29+
$this->time,
30+
'last_update_time',
31+
]);
32+
33+
OptionEditor::resetCache();
34+
}
35+
}

wcfsetup/install/files/lib/data/package/installation/plugin/PackageInstallationPluginAction.class.php

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

33
namespace wcf\data\package\installation\plugin;
44

5+
use wcf\command\package\SetLastUpdateTime;
56
use wcf\data\AbstractDatabaseObjectAction;
67
use wcf\data\devtools\project\DevtoolsProject;
78
use wcf\data\option\OptionEditor;
@@ -132,15 +133,7 @@ public function invoke()
132133
case 'file':
133134
StyleHandler::resetStylesheets(false);
134135

135-
$sql = "UPDATE wcf1_option
136-
SET optionValue = ?
137-
WHERE optionName = ?";
138-
$statement = WCF::getDB()->prepare($sql);
139-
$statement->execute([
140-
\TIME_NOW,
141-
'last_update_time',
142-
]);
143-
OptionEditor::resetCache();
136+
(new SetLastUpdateTime())();
144137
break;
145138

146139
case 'language':

wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use wcf\event\package\PackageListChanged;
1717
use wcf\system\application\ApplicationHandler;
1818
use wcf\command\cache\ClearCache;
19+
use wcf\command\package\SetLastUpdateTime;
1920
use wcf\system\database\statement\PreparedStatement;
2021
use wcf\system\devtools\DevtoolsSetup;
2122
use wcf\system\Environment;
@@ -174,15 +175,7 @@ public function install(string $node): PackageInstallationStep
174175

175176
$this->logInstallationStep([], 'start cleanup');
176177

177-
// update "last update time" option
178-
$sql = "UPDATE wcf1_option
179-
SET optionValue = ?
180-
WHERE optionName = ?";
181-
$statement = WCF::getDB()->prepare($sql);
182-
$statement->execute([
183-
TIME_NOW,
184-
'last_update_time',
185-
]);
178+
(new SetLastUpdateTime())();
186179

187180
if ($this->action == 'install') {
188181
// save localized package infos

0 commit comments

Comments
 (0)