From 55b3584958c99d87bfab9ca6fde334cd21cfa196 Mon Sep 17 00:00:00 2001 From: Cyperghost Date: Thu, 25 Jan 2024 15:28:04 +0100 Subject: [PATCH] Register default values for `SharedTemplateEngine` --- .../install/files/lib/system/WCF.class.php | 40 ++++++++++++------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/wcfsetup/install/files/lib/system/WCF.class.php b/wcfsetup/install/files/lib/system/WCF.class.php index 2489c54947..a4b7d70c50 100644 --- a/wcfsetup/install/files/lib/system/WCF.class.php +++ b/wcfsetup/install/files/lib/system/WCF.class.php @@ -31,6 +31,7 @@ use wcf\system\session\SessionFactory; use wcf\system\session\SessionHandler; use wcf\system\style\StyleHandler; use wcf\system\template\EmailTemplateEngine; +use wcf\system\template\SharedTemplateEngine; use wcf\system\template\TemplateEngine; use wcf\system\user\storage\UserStorageHandler; use wcf\util\DirectoryUtil; @@ -658,6 +659,7 @@ class WCF static::getTPL()->addApplication($abbreviation, $packageDir . 'templates/'); } EmailTemplateEngine::getInstance()->addApplication($abbreviation, $packageDir . 'templates/'); + SharedTemplateEngine::getInstance()->addApplication($abbreviation, $packageDir . 'templates/'); // init application and assign it as template variable self::$applicationObjects[$application->packageID] = \call_user_func([$className, 'getInstance']); @@ -666,6 +668,10 @@ class WCF '__' . $abbreviation, self::$applicationObjects[$application->packageID] ); + SharedTemplateEngine::getInstance()->assign( + '__' . $abbreviation, + self::$applicationObjects[$application->packageID] + ); } else { unset(self::$autoloadDirectories[$abbreviation]); throw new SystemException("Unable to run '" . $package->package . "', '" . $className . "' is missing or does not implement '" . IApplication::class . "'."); @@ -743,21 +749,24 @@ class WCF if (ENABLE_ENTERPRISE_MODE) { $wcf = new TemplateScriptingCore($wcf); } - - self::getTPL()->registerPrefilter(['event', 'hascontent', 'lang', 'jsphrase', 'jslang', 'csrfToken', 'icon']); - self::getTPL()->assign([ - '__wcf' => $wcf, - ]); - - $isAjax = isset($_SERVER['HTTP_X_REQUESTED_WITH']) && ($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'); - // Execute background queue in this request, if it was requested and AJAX isn't used. - if (!$isAjax) { - if (self::getSession()->getVar('forceBackgroundQueuePerform')) { - self::getTPL()->assign([ - 'forceBackgroundQueuePerform' => true, - ]); - - self::getSession()->unregister('forceBackgroundQueuePerform'); + $tplEngines = [self::getTPL(), SharedTemplateEngine::getInstance()]; + + foreach ($tplEngines as $tplEngine) { + $tplEngine->registerPrefilter(['event', 'hascontent', 'lang', 'jsphrase', 'jslang', 'csrfToken', 'icon']); + $tplEngine->assign([ + '__wcf' => $wcf, + ]); + + $isAjax = isset($_SERVER['HTTP_X_REQUESTED_WITH']) && ($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'); + // Execute background queue in this request, if it was requested and AJAX isn't used. + if (!$isAjax) { + if (self::getSession()->getVar('forceBackgroundQueuePerform')) { + $tplEngine->assign([ + 'forceBackgroundQueuePerform' => true, + ]); + + self::getSession()->unregister('forceBackgroundQueuePerform'); + } } } @@ -807,6 +816,7 @@ class WCF if (self::$tplObj !== null) { self::getTPL()->setLanguageID(self::getLanguage()->languageID); EmailTemplateEngine::getInstance()->setLanguageID(self::getLanguage()->languageID); + SharedTemplateEngine::getInstance()->setLanguageID(self::getLanguage()->languageID); } } -- 2.20.1