Skip to content

Commit d289beb

Browse files
authored
Merge pull request #6317 from WoltLab/6.1-cache-shared-template-groupID
Get the `templateGroupID` for the shared templates from the cache
2 parents e33bc1e + e219e9e commit d289beb

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

wcfsetup/install/files/lib/system/template/TemplateEngine.class.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44

55
use Laminas\Diactoros\Stream;
66
use Psr\Http\Message\StreamInterface;
7+
use wcf\data\template\group\TemplateGroup;
78
use wcf\data\template\Template;
89
use wcf\system\cache\builder\TemplateGroupCacheBuilder;
910
use wcf\system\cache\builder\TemplateListenerCodeCacheBuilder;
1011
use wcf\system\event\EventHandler;
1112
use wcf\system\exception\SystemException;
1213
use wcf\system\Regex;
1314
use wcf\system\SingletonFactory;
14-
use wcf\system\WCF;
1515
use wcf\util\DirectoryUtil;
1616
use wcf\util\HeaderUtil;
1717
use wcf\util\StringUtil;
@@ -1045,14 +1045,18 @@ protected function getCompileFilePrefix(string $templateName): string
10451045
private function getSharedTemplateGroupID(): int
10461046
{
10471047
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+
);
10531052

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;
10551058
}
1059+
10561060
return $this->sharedTemplateGroupID;
10571061
}
10581062
}

0 commit comments

Comments
 (0)