|
4 | 4 |
|
5 | 5 | use Laminas\Diactoros\Stream; |
6 | 6 | use Psr\Http\Message\StreamInterface; |
| 7 | +use wcf\data\template\group\TemplateGroup; |
7 | 8 | use wcf\data\template\Template; |
8 | 9 | use wcf\system\cache\builder\TemplateGroupCacheBuilder; |
9 | 10 | use wcf\system\cache\builder\TemplateListenerCodeCacheBuilder; |
10 | 11 | use wcf\system\event\EventHandler; |
11 | 12 | use wcf\system\exception\SystemException; |
12 | 13 | use wcf\system\Regex; |
13 | 14 | use wcf\system\SingletonFactory; |
14 | | -use wcf\system\WCF; |
15 | 15 | use wcf\util\DirectoryUtil; |
16 | 16 | use wcf\util\HeaderUtil; |
17 | 17 | use wcf\util\StringUtil; |
@@ -1045,14 +1045,18 @@ protected function getCompileFilePrefix(string $templateName): string |
1045 | 1045 | private function getSharedTemplateGroupID(): int |
1046 | 1046 | { |
1047 | 1047 | if (!isset($this->sharedTemplateGroupID)) { |
1048 | | - $sql = "SELECT templateGroupID |
1049 | | - FROM wcf1_template_group |
1050 | | - WHERE templateGroupFolderName = ?"; |
1051 | | - $statement = WCF::getDB()->prepare($sql); |
1052 | | - $statement->execute(['_wcf_shared/']); |
| 1048 | + $templateGroup = \array_find( |
| 1049 | + $this->templateGroupCache, |
| 1050 | + static fn(TemplateGroup $group) => $group->templateGroupFolderName === '_wcf_shared/' |
| 1051 | + ); |
1053 | 1052 |
|
1054 | | - $this->sharedTemplateGroupID = $statement->fetchSingleColumn(); |
| 1053 | + if ($templateGroup === null) { |
| 1054 | + throw new \RuntimeException('Shared template group not found'); |
| 1055 | + } |
| 1056 | + |
| 1057 | + $this->sharedTemplateGroupID = $templateGroup->templateGroupID; |
1055 | 1058 | } |
| 1059 | + |
1056 | 1060 | return $this->sharedTemplateGroupID; |
1057 | 1061 | } |
1058 | 1062 | } |
0 commit comments