diff --git a/typo3/sysext/core/Classes/TypoScript/TemplateService.php b/typo3/sysext/core/Classes/TypoScript/TemplateService.php
index 064b28e93e9d333c65e6410a3c0e5b36c8c230a3..64b3c587e6e9a09c8902fed3588423a71a973a73 100644
--- a/typo3/sysext/core/Classes/TypoScript/TemplateService.php
+++ b/typo3/sysext/core/Classes/TypoScript/TemplateService.php
@@ -1212,7 +1212,7 @@ class TemplateService
 
             // adding constants from site settings
             $siteConstants = '';
-            if ($this->getTypoScriptFrontendController()) {
+            if ($this->getTypoScriptFrontendController() instanceof TypoScriptFrontendController) {
                 $site = $this->getTypoScriptFrontendController()->getSite();
             } else {
                 $currentPage = end($this->absoluteRootLine);