[BUGFIX] Do not force content_fallback to default page language
[Packages/TYPO3.CMS.git] / typo3 / sysext / frontend / Classes / Controller / TypoScriptFrontendController.php
index ab36b57..edba1ff 100644 (file)
@@ -14,31 +14,40 @@ namespace TYPO3\CMS\Frontend\Controller;
  * The TYPO3 project - inspiring people to share!
  */
 
+use Doctrine\DBAL\Exception\ConnectionException;
+use Psr\Log\LoggerAwareInterface;
+use Psr\Log\LoggerAwareTrait;
 use TYPO3\CMS\Backend\FrontendBackendUserAuthentication;
 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
 use TYPO3\CMS\Core\Cache\CacheManager;
 use TYPO3\CMS\Core\Charset\CharsetConverter;
+use TYPO3\CMS\Core\Controller\ErrorPageController;
+use TYPO3\CMS\Core\Database\ConnectionPool;
+use TYPO3\CMS\Core\Database\Query\QueryHelper;
+use TYPO3\CMS\Core\Database\Query\Restriction\DefaultRestrictionContainer;
+use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
+use TYPO3\CMS\Core\Database\Query\Restriction\EndTimeRestriction;
+use TYPO3\CMS\Core\Database\Query\Restriction\StartTimeRestriction;
 use TYPO3\CMS\Core\Error\Http\PageNotFoundException;
 use TYPO3\CMS\Core\Error\Http\ServiceUnavailableException;
-use TYPO3\CMS\Core\Localization\Locales;
-use TYPO3\CMS\Core\Localization\LocalizationFactory;
+use TYPO3\CMS\Core\Localization\LanguageService;
 use TYPO3\CMS\Core\Locking\Exception\LockAcquireWouldBlockException;
-use TYPO3\CMS\Core\Locking\Locker;
-use TYPO3\CMS\Core\Messaging\ErrorpageMessage;
+use TYPO3\CMS\Core\Locking\LockFactory;
+use TYPO3\CMS\Core\Locking\LockingStrategyInterface;
+use TYPO3\CMS\Core\Log\LogManager;
 use TYPO3\CMS\Core\Page\PageRenderer;
 use TYPO3\CMS\Core\Resource\StorageRepository;
+use TYPO3\CMS\Core\Service\DependencyOrderingService;
+use TYPO3\CMS\Core\TimeTracker\TimeTracker;
 use TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser;
 use TYPO3\CMS\Core\TypoScript\TemplateService;
 use TYPO3\CMS\Core\Utility\ArrayUtility;
-use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
-use TYPO3\CMS\Core\Locking\LockingStrategyInterface;
-use TYPO3\CMS\Core\Locking\LockFactory;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\HttpUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
-use TYPO3\CMS\Core\Utility\StringUtility;
 use TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication;
 use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
+use TYPO3\CMS\Frontend\Http\UrlHandlerInterface;
 use TYPO3\CMS\Frontend\Page\CacheHashCalculator;
 use TYPO3\CMS\Frontend\Page\PageGenerator;
 use TYPO3\CMS\Frontend\Page\PageRepository;
@@ -46,3018 +55,2901 @@ use TYPO3\CMS\Frontend\View\AdminPanelView;
 
 /**
  * Class for the built TypoScript based frontend. Instantiated in
- * index_ts.php script as the global object TSFE.
+ * \TYPO3\CMS\Frontend\Http\RequestHandler as the global object TSFE.
  *
- * Main frontend class, instantiated in the index_ts.php script as the global
- * object TSFE.
+ * Main frontend class, instantiated in \TYPO3\CMS\Frontend\Http\RequestHandler
+ * as the global object TSFE.
  *
  * This class has a lot of functions and internal variable which are used from
- * index_ts.php.
+ * \TYPO3\CMS\Frontend\Http\RequestHandler
  *
- * The class is instantiated as $GLOBALS['TSFE'] in index_ts.php.
+ * The class is instantiated as $GLOBALS['TSFE'] in \TYPO3\CMS\Frontend\Http\RequestHandler.
  *
  * The use of this class should be inspired by the order of function calls as
- * found in index_ts.php.
+ * found in \TYPO3\CMS\Frontend\Http\RequestHandler.
  */
-class TypoScriptFrontendController {
-
-       /**
-        * The page id (int)
-        * @var string
-        */
-       public $id = '';
-
-       /**
-        * The type (read-only)
-        * @var int
-        */
-       public $type = '';
-
-       /**
-        * The submitted cHash
-        * @var string
-        */
-       public $cHash = '';
-
-       /**
-        * Page will not be cached. Write only TRUE. Never clear value (some other
-        * code might have reasons to set it TRUE).
-        * @var bool
-        */
-       public $no_cache = FALSE;
-
-       /**
-        * The rootLine (all the way to tree root, not only the current site!)
-        * @var array
-        */
-       public $rootLine = '';
-
-       /**
-        * The pagerecord
-        * @var array
-        */
-       public $page = '';
-
-       /**
-        * This will normally point to the same value as id, but can be changed to
-        * point to another page from which content will then be displayed instead.
-        * @var int
-        */
-       public $contentPid = 0;
-
-       /**
-        * Gets set when we are processing a page of type mounpoint with enabled overlay in getPageAndRootline()
-        * Used later in checkPageForMountpointRedirect() to determine the final target URL where the user
-        * should be redirected to.
-        *
-        * @var array|NULL
-        */
-       protected $originalMountPointPage = NULL;
-
-       /**
-        * Gets set when we are processing a page of type shortcut in the early stages
-        * of the request when we do not know about languages yet, used later in the request
-        * to determine the correct shortcut in case a translation changes the shortcut
-        * target
-        * @var array|NULL
-        * @see checkTranslatedShortcut()
-        */
-       protected $originalShortcutPage = NULL;
-
-       /**
-        * sys_page-object, pagefunctions
-        *
-        * @var PageRepository
-        */
-       public $sys_page = '';
-
-       /**
-        * @var string
-        */
-       public $jumpurl = '';
-
-       /**
-        * Is set to 1 if a pageNotFound handler could have been called.
-        * @var int
-        */
-       public $pageNotFound = 0;
-
-       /**
-        * Domain start page
-        * @var int
-        */
-       public $domainStartPage = 0;
-
-       /**
-        * Array containing a history of why a requested page was not accessible.
-        * @var array
-        */
-       public $pageAccessFailureHistory = array();
-
-       /**
-        * @var string
-        */
-       public $MP = '';
-
-       /**
-        * @var string
-        */
-       public $RDCT = '';
-
-       /**
-        * This can be set from applications as a way to tag cached versions of a page
-        * and later perform some external cache management, like clearing only a part
-        * of the cache of a page...
-        * @var int
-        */
-       public $page_cache_reg1 = 0;
-
-       /**
-        * Contains the value of the current script path that activated the frontend.
-        * Typically "index.php" but by rewrite rules it could be something else! Used
-        * for Speaking Urls / Simulate Static Documents.
-        * @var string
-        */
-       public $siteScript = '';
-
-       /**
-        * The frontend user
-        *
-        * @var FrontendUserAuthentication
-        */
-       public $fe_user = '';
-
-       /**
-        * Global flag indicating that a frontend user is logged in. This is set only if
-        * a user really IS logged in. The group-list may show other groups (like added
-        * by IP filter or so) even though there is no user.
-        * @var bool
-        */
-       public $loginUser = FALSE;
-
-       /**
-        * (RO=readonly) The group list, sorted numerically. Group '0,-1' is the default
-        * group, but other groups may be added by other means than a user being logged
-        * in though...
-        * @var string
-        */
-       public $gr_list = '';
-
-       /**
-        * Flag that indicates if a backend user is logged in!
-        * @var bool
-        */
-       public $beUserLogin = FALSE;
-
-       /**
-        * Integer, that indicates which workspace is being previewed.
-        * @var int
-        */
-       public $workspacePreview = 0;
-
-       /**
-        * Shows whether logins are allowed in branch
-        * @var bool
-        */
-       public $loginAllowedInBranch = TRUE;
-
-       /**
-        * Shows specific mode (all or groups)
-        * @var string
-        */
-       public $loginAllowedInBranch_mode = '';
-
-       /**
-        * Set to backend user ID to initialize when keyword-based preview is used
-        * @var int
-        */
-       public $ADMCMD_preview_BEUSER_uid = 0;
-
-       /**
-        * Flag indication that preview is active. This is based on the login of a
-        * backend user and whether the backend user has read access to the current
-        * page. A value of 1 means ordinary preview, 2 means preview of a non-live
-        * workspace
-        * @var int
-        */
-       public $fePreview = 0;
-
-       /**
-        * Flag indicating that hidden pages should be shown, selected and so on. This
-        * goes for almost all selection of pages!
-        * @var bool
-        */
-       public $showHiddenPage = FALSE;
-
-       /**
-        * Flag indicating that hidden records should be shown. This includes
-        * sys_template, pages_language_overlay and even fe_groups in addition to all
-        * other regular content. So in effect, this includes everything except pages.
-        * @var bool
-        */
-       public $showHiddenRecords = FALSE;
-
-       /**
-        * Value that contains the simulated usergroup if any
-        * @var int
-        */
-       public $simUserGroup = 0;
-
-       /**
-        * Copy of $GLOBALS['TYPO3_CONF_VARS']
-        *
-        * @var array
-        */
-       public $TYPO3_CONF_VARS = array();
-
-       /**
-        * "CONFIG" object from TypoScript. Array generated based on the TypoScript
-        * configuration of the current page. Saved with the cached pages.
-        * @var array
-        */
-       public $config = '';
-
-       /**
-        * The TypoScript template object. Used to parse the TypoScript template
-        *
-        * @var TemplateService
-        */
-       public $tmpl = NULL;
-
-       /**
-        * Is set to the time-to-live time of cached pages. If FALSE, default is
-        * 60*60*24, which is 24 hours.
-        * @var bool|int
-        */
-       public $cacheTimeOutDefault = FALSE;
-
-       /**
-        * Set internally if cached content is fetched from the database
-        * @var bool
-        * @internal
-        */
-       public $cacheContentFlag = FALSE;
-
-       /**
-        * Set to the expire time of cached content
-        * @var int
-        */
-       public $cacheExpires = 0;
-
-       /**
-        * Set if cache headers allowing caching are sent.
-        * @var bool
-        */
-       public $isClientCachable = FALSE;
-
-       /**
-        * Used by template fetching system. This array is an identification of
-        * the template. If $this->all is empty it's because the template-data is not
-        * cached, which it must be.
-        * @var array
-        */
-       public $all = array();
-
-       /**
-        * Toplevel - objArrayName, eg 'page'
-        * @var string
-        */
-       public $sPre = '';
-
-       /**
-        * TypoScript configuration of the page-object pointed to by sPre.
-        * $this->tmpl->setup[$this->sPre.'.']
-        * @var array
-        */
-       public $pSetup = '';
-
-       /**
-        * This hash is unique to the template, the $this->id and $this->type vars and
-        * the gr_list (list of groups). Used to get and later store the cached data
-        * @var string
-        */
-       public $newHash = '';
-
-       /**
-        * If config.ftu (Frontend Track User) is set in TypoScript for the current
-        * page, the string value of this var is substituted in the rendered source-code
-        * with the string, '&ftu=[token...]' which enables GET-method usertracking as
-        * opposed to cookie based
-        * @var string
-        */
-       public $getMethodUrlIdToken = '';
-
-       /**
-        * This flag is set before inclusion of pagegen.php IF no_cache is set. If this
-        * flag is set after the inclusion of pagegen.php, no_cache is forced to be set.
-        * This is done in order to make sure that php-code from pagegen does not falsely
-        * clear the no_cache flag.
-        * @var bool
-        */
-       public $no_cacheBeforePageGen = FALSE;
-
-       /**
-        * This flag indicates if temporary content went into the cache during
-        * page-generation.
-        * @var mixed
-        */
-       public $tempContent = FALSE;
-
-       /**
-        * Passed to TypoScript template class and tells it to force template rendering
-        * @var bool
-        */
-       public $forceTemplateParsing = FALSE;
-
-       /**
-        * The array which cHash_calc is based on, see ->makeCacheHash().
-        * @var array
-        */
-       public $cHash_array = array();
-
-       /**
-        * May be set to the pagesTSconfig
-        * @var array
-        */
-       public $pagesTSconfig = '';
-
-       /**
-        * Eg. insert JS-functions in this array ($additionalHeaderData) to include them
-        * once. Use associative keys.
-        *
-        * Keys in use:
-        *
-        * JSFormValidate: <script type="text/javascript" src="'.$GLOBALS["TSFE"]->absRefPrefix.'typo3/sysext/frontend/Resources/Public/JavaScript/jsfunc.validateform.js"></script>
-        * JSMenuCode, JSMenuCode_menu: JavaScript for the JavaScript menu
-        * JSCode: reserved
-        *
-        * used to accumulate additional HTML-code for the header-section,
-        * <head>...</head>. Insert either associative keys (like
-        * additionalHeaderData['myStyleSheet'], see reserved keys above) or num-keys
-        * (like additionalHeaderData[] = '...')
-        *
-        * @var array
-        */
-       public $additionalHeaderData = array();
-
-       /**
-        * Used to accumulate additional HTML-code for the footer-section of the template
-        * @var array
-        */
-       public $additionalFooterData = array();
-
-       /**
-        * Used to accumulate additional JavaScript-code. Works like
-        * additionalHeaderData. Reserved keys at 'openPic' and 'mouseOver'
-        *
-        * @var array
-        */
-       public $additionalJavaScript = array();
-
-       /**
-        * Used to accumulate additional Style code. Works like additionalHeaderData.
-        *
-        * @var array
-        */
-       public $additionalCSS = array();
-
-       /**
-        * You can add JavaScript functions to each entry in these arrays. Please see
-        * how this is done in the GMENU_LAYERS script. The point is that many
-        * applications on a page can set handlers for onload, onmouseover and onmouseup
-        *
-        * @var array
-        * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8
-        */
-       public $JSeventFuncCalls = array(
-               'onmousemove' => array(),
-               'onmouseup' => array(),
-               'onkeydown' => array(),
-               'onkeyup' => array(),
-               'onkeypress' => array(),
-               'onload' => array(),
-               'onunload' => array()
-       );
-
-       /**
-        * Used to accumulate DHTML-layers.
-        * @var string
-        */
-       public $divSection = '';
-
-       /**
-        * Default bodytag, if nothing else is set. This can be overridden by
-        * applications like TemplaVoila.
-        * @var string
-        */
-       public $defaultBodyTag = '<body>';
-
-       /**
-        * Debug flag, may output special debug html-code.
-        * @var string
-        */
-       public $debug = '';
-
-       /**
-        * Default internal target
-        * @var string
-        */
-       public $intTarget = '';
-
-       /**
-        * Default external target
-        * @var string
-        */
-       public $extTarget = '';
-
-       /**
-        * Default file link target
-        * @var string
-        */
-       public $fileTarget = '';
-
-       /**
-        * Keys are page ids and values are default &MP (mount point) values to set
-        * when using the linking features...)
-        * @var array
-        */
-       public $MP_defaults = array();
-
-       /**
-        * If set, typolink() function encrypts email addresses. Is set in pagegen-class.
-        * @var string|int
-        */
-       public $spamProtectEmailAddresses = 0;
-
-       /**
-        * Absolute Reference prefix
-        * @var string
-        */
-       public $absRefPrefix = '';
-
-       /**
-        * Factor for form-field widths compensation
-        * @var string
-        */
-       public $compensateFieldWidth = '';
-
-       /**
-        * Lock file path
-        * @var string
-        */
-       public $lockFilePath = '';
-
-       /**
-        * <A>-tag parameters
-        * @var string
-        */
-       public $ATagParams = '';
-
-       /**
-        * Search word regex, calculated if there has been search-words send. This is
-        * used to mark up the found search words on a page when jumped to from a link
-        * in a search-result.
-        * @var string
-        */
-       public $sWordRegEx = '';
-
-       /**
-        * Is set to the incoming array sword_list in case of a page-view jumped to from
-        * a search-result.
-        * @var string
-        */
-       public $sWordList = '';
-
-       /**
-        * A string prepared for insertion in all links on the page as url-parameters.
-        * Based on configuration in TypoScript where you defined which GET_VARS you
-        * would like to pass on.
-        * @var string
-        */
-       public $linkVars = '';
-
-       /**
-        * A string set with a comma list of additional GET vars which should NOT be
-        * included in the cHash calculation. These vars should otherwise be detected
-        * and involved in caching, eg. through a condition in TypoScript.
-        * @var string
-        */
-       public $excludeCHashVars = '';
-
-       /**
-        * If set, edit icons are rendered aside content records. Must be set only if
-        * the ->beUserLogin flag is set and set_no_cache() must be called as well.
-        * @var string
-        */
-       public $displayEditIcons = '';
-
-       /**
-        * If set, edit icons are rendered aside individual fields of content. Must be
-        * set only if the ->beUserLogin flag is set and set_no_cache() must be called as
-        * well.
-        * @var string
-        */
-       public $displayFieldEditIcons = '';
-
-       /**
-        * Site language, 0 (zero) is default, int+ is uid pointing to a sys_language
-        * record. Should reflect which language menus, templates etc is displayed in
-        * (master language) - but not necessarily the content which could be falling
-        * back to default (see sys_language_content)
-        * @var int
-        */
-       public $sys_language_uid = 0;
-
-       /**
-        * Site language mode for content fall back.
-        * @var string
-        */
-       public $sys_language_mode = '';
-
-       /**
-        * Site content selection uid (can be different from sys_language_uid if content
-        * is to be selected from a fall-back language. Depends on sys_language_mode)
-        * @var int
-        */
-       public $sys_language_content = 0;
-
-       /**
-        * Site content overlay flag; If set - and sys_language_content is > 0 - ,
-        * records selected will try to look for a translation pointing to their uid. (If
-        * configured in [ctrl][languageField] / [ctrl][transOrigP...]
-        * @var int
-        */
-       public $sys_language_contentOL = 0;
-
-       /**
-        * Is set to the iso code of the sys_language_content if that is properly defined
-        * by the sys_language record representing the sys_language_uid.
-        * @var string
-        */
-       public $sys_language_isocode = '';
-
-       /**
-        * 'Global' Storage for various applications. Keys should be 'tx_'.extKey for
-        * extensions.
-        * @var array
-        */
-       public $applicationData = array();
-
-       /**
-        * @var array
-        */
-       public $register = array();
-
-       /**
-        * Stack used for storing array and retrieving register arrays (see
-        * LOAD_REGISTER and RESTORE_REGISTER)
-        * @var array
-        */
-       public $registerStack = array();
-
-       /**
-        * Checking that the function is not called eternally. This is done by
-        * interrupting at a depth of 50
-        * @var int
-        */
-       public $cObjectDepthCounter = 50;
-
-       /**
-        * Used by RecordContentObject and ContentContentObject to ensure the a records is NOT
-        * rendered twice through it!
-        * @var array
-        */
-       public $recordRegister = array();
-
-       /**
-        * This is set to the [table]:[uid] of the latest record rendered. Note that
-        * class ContentObjectRenderer has an equal value, but that is pointing to the
-        * record delivered in the $data-array of the ContentObjectRenderer instance, if
-        * the cObjects CONTENT or RECORD created that instance
-        * @var string
-        */
-       public $currentRecord = '';
-
-       /**
-        * Used by class \TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuContentObject
-        * to keep track of access-keys.
-        * @var array
-        */
-       public $accessKey = array();
-
-       /**
-        * Numerical array where image filenames are added if they are referenced in the
-        * rendered document. This includes only TYPO3 generated/inserted images.
-        * @var array
-        */
-       public $imagesOnPage = array();
-
-       /**
-        * Is set in ContentObjectRenderer->cImage() function to the info-array of the
-        * most recent rendered image. The information is used in ImageTextContentObject
-        * @var array
-        */
-       public $lastImageInfo = array();
-
-       /**
-        * Used to generate page-unique keys. Point is that uniqid() functions is very
-        * slow, so a unikey key is made based on this, see function uniqueHash()
-        * @var int
-        */
-       public $uniqueCounter = 0;
-
-       /**
-        * @var string
-        */
-       public $uniqueString = '';
-
-       /**
-        * This value will be used as the title for the page in the indexer (if
-        * indexing happens)
-        * @var string
-        */
-       public $indexedDocTitle = '';
-
-       /**
-        * Alternative page title (normally the title of the page record). Can be set
-        * from applications you make.
-        * @var string
-        */
-       public $altPageTitle = '';
-
-       /**
-        * The base URL set for the page header.
-        * @var string
-        */
-       public $baseUrl = '';
-
-       /**
-        * The proper anchor prefix needed when using speaking urls. (only set if
-        * baseUrl is set)
-        * @deprecated since TYPO3 CMS 7, will be removed with TYPO3 CMS 8, use substr(GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'), strlen(GeneralUtility::getIndpEnv('TYPO3_SITE_URL'))) directly
-        * @var string
-        */
-       public $anchorPrefix = '';
-
-       /**
-        * IDs we already rendered for this page (to make sure they are unique)
-        * @var array
-        */
-       private $usedUniqueIds = array();
-
-       /**
-        * Page content render object
-        *
-        * @var ContentObjectRenderer
-        */
-       public $cObj = '';
-
-       /**
-        * All page content is accumulated in this variable. See pagegen.php
-        * @var string
-        */
-       public $content = '';
-
-       /**
-        * Set to the browser: net / msie if 4+ browsers
-        * @var string
-        */
-       public $clientInfo = '';
-
-       /**
-        * @var int
-        */
-       public $scriptParseTime = 0;
-
-       /**
-        * Character set (charset) conversion object:
-        * charset conversion class. May be used by any application.
-        *
-        * @var CharsetConverter
-        */
-       public $csConvObj;
-
-       /**
-        * The default charset used in the frontend if nothing else is set.
-        * @var string
-        */
-       public $defaultCharSet = 'utf-8';
-
-       /**
-        * Internal charset of the frontend during rendering. (Default: UTF-8)
-        * @var string
-        */
-       public $renderCharset = 'utf-8';
-
-       /**
-        * Output charset of the websites content. This is the charset found in the
-        * header, meta tag etc. If different from $renderCharset a conversion
-        * happens before output to browser. Defaults to ->renderCharset if not set.
-        * @var string
-        */
-       public $metaCharset = 'utf-8';
-
-       /**
-        * Assumed charset of locale strings.
-        * @var string
-        */
-       public $localeCharset = '';
-
-       /**
-        * Set to the system language key (used on the site)
-        * @var string
-        */
-       public $lang = '';
-
-       /**
-        * @var array
-        */
-       public $LL_labels_cache = array();
-
-       /**
-        * @var array
-        */
-       public $LL_files_cache = array();
-
-       /**
-        * List of language dependencies for actual language. This is used for local
-        * variants of a language that depend on their "main" language, like Brazilian,
-        * Portuguese or Canadian French.
-        *
-        * @var array
-        */
-       protected $languageDependencies = array();
-
-       /**
-        * @var LockingStrategyInterface[][]
-        */
-       protected $locks = [];
-
-       /**
-        * @var PageRenderer
-        */
-       protected $pageRenderer = NULL;
-
-       /**
-        * The page cache object, use this to save pages to the cache and to
-        * retrieve them again
-        *
-        * @var \TYPO3\CMS\Core\Cache\Backend\AbstractBackend
-        */
-       protected $pageCache;
-
-       /**
-        * @var array
-        */
-       protected $pageCacheTags = array();
-
-       /**
-        * The cHash Service class used for cHash related functionality
-        *
-        * @var CacheHashCalculator
-        */
-       protected $cacheHash;
-
-       /**
-        * Runtime cache of domains per processed page ids.
-        *
-        * @var array
-        */
-       protected $domainDataCache = array();
-
-       /**
-        * Content type HTTP header being sent in the request.
-        * @todo Ticket: #63642 Should be refactored to a request/response model later
-        * @internal Should only be used by TYPO3 core for now
-        *
-        * @var string
-        */
-       protected $contentType = 'text/html';
-
-       /**
-        * Doctype to use
-        *
-        * Currently set via PageGenerator
-        *
-        * @var string
-        */
-       public $xhtmlDoctype = '';
-
-       /**
-        * Originally requested id from the initial $_GET variable
-        *
-        * @var int
-        */
-       protected $requestedId;
-
-       /**
-        * Class constructor
-        * Takes a number of GET/POST input variable as arguments and stores them internally.
-        * The processing of these variables goes on later in this class.
-        * Also sets internal clientInfo array (browser information) and a unique string (->uniqueString) for this script instance; A md5 hash of the microtime()
-        *
-        * @param array $TYPO3_CONF_VARS The global $TYPO3_CONF_VARS array. Will be set internally in ->TYPO3_CONF_VARS
-        * @param mixed $id The value of GeneralUtility::_GP('id')
-        * @param int $type The value of GeneralUtility::_GP('type')
-        * @param bool|string $no_cache The value of GeneralUtility::_GP('no_cache'), evaluated to 1/0
-        * @param string $cHash The value of GeneralUtility::_GP('cHash')
-        * @param string $jumpurl The value of GeneralUtility::_GP('jumpurl')
-        * @param string $MP The value of GeneralUtility::_GP('MP')
-        * @param string $RDCT The value of GeneralUtility::_GP('RDCT')
-        * @see index_ts.php
-        */
-       public function __construct($TYPO3_CONF_VARS, $id, $type, $no_cache = '', $cHash = '', $jumpurl = '', $MP = '', $RDCT = '') {
-               // Setting some variables:
-               $this->TYPO3_CONF_VARS = $TYPO3_CONF_VARS;
-               $this->id = $id;
-               $this->type = $type;
-               if ($no_cache) {
-                       if ($this->TYPO3_CONF_VARS['FE']['disableNoCacheParameter']) {
-                               $warning = '&no_cache=1 has been ignored because $TYPO3_CONF_VARS[\'FE\'][\'disableNoCacheParameter\'] is set!';
-                               $GLOBALS['TT']->setTSlogMessage($warning, 2);
-                       } else {
-                               $warning = '&no_cache=1 has been supplied, so caching is disabled! URL: "' . GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL') . '"';
-                               $this->disableCache();
-                       }
-                       GeneralUtility::sysLog($warning, 'cms', GeneralUtility::SYSLOG_SEVERITY_WARNING);
-               }
-               $this->cHash = $cHash;
-               $this->jumpurl = $jumpurl;
-               $this->MP = $this->TYPO3_CONF_VARS['FE']['enable_mount_pids'] ? (string)$MP : '';
-               $this->RDCT = $RDCT;
-               $this->clientInfo = GeneralUtility::clientInfo();
-               $this->uniqueString = md5(microtime());
-               $this->csConvObj = GeneralUtility::makeInstance(CharsetConverter::class);
-               $this->initPageRenderer();
-               // Call post processing function for constructor:
-               if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['tslib_fe-PostProc'])) {
-                       $_params = array('pObj' => &$this);
-                       foreach ($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['tslib_fe-PostProc'] as $_funcRef) {
-                               GeneralUtility::callUserFunction($_funcRef, $_params, $this);
-                       }
-               }
-               $this->cacheHash = GeneralUtility::makeInstance(CacheHashCalculator::class);
-               $this->initCaches();
-       }
-
-       /**
-        * Initializes the page renderer object
-        */
-       protected function initPageRenderer() {
-               if ($this->pageRenderer !== NULL) {
-                       return;
-               }
-               $this->pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
-               $this->pageRenderer->setTemplateFile('EXT:frontend/Resources/Private/Templates/MainPage.html');
-               $this->pageRenderer->setBackPath(TYPO3_mainDir);
-       }
-
-       /**
-        * @param string $contentType
-        * @internal Should only be used by TYPO3 core for now
-        */
-       public function setContentType($contentType) {
-               $this->contentType = $contentType;
-       }
-
-       /**
-        * Connect to SQL database. May exit after outputting an error message
-        * or some JavaScript redirecting to the install tool.
-        *
-        * @throws \RuntimeException
-        * @throws ServiceUnavailableException
-        * @return void
-        */
-       public function connectToDB() {
-               try {
-                       $GLOBALS['TYPO3_DB']->connectDB();
-               } catch (\RuntimeException $exception) {
-                       switch ($exception->getCode()) {
-                               case 1270853883:
-                                       // Cannot connect to current database
-                                       $message = 'Cannot connect to the configured database "' . TYPO3_db . '"';
-                                       if ($this->checkPageUnavailableHandler()) {
-                                               $this->pageUnavailableAndExit($message);
-                                       } else {
-                                               GeneralUtility::sysLog($message, 'cms', GeneralUtility::SYSLOG_SEVERITY_ERROR);
-                                               throw new ServiceUnavailableException($message, 1301648782);
-                                       }
-                                       break;
-                               case 1270853884:
-                                       // Username / password not accepted
-                                       $message = 'The current username, password or host was not accepted when' . ' the connection to the database was attempted to be established!';
-                                       if ($this->checkPageUnavailableHandler()) {
-                                               $this->pageUnavailableAndExit($message);
-                                       } else {
-                                               GeneralUtility::sysLog($message, 'cms', GeneralUtility::SYSLOG_SEVERITY_ERROR);
-                                               throw new ServiceUnavailableException('Database Error: ' . $message, 1301648945);
-                                       }
-                                       break;
-                               default:
-                                       throw $exception;
-                       }
-               }
-               // Call post processing function for DB connection:
-               if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['connectToDB'])) {
-                       $_params = array('pObj' => &$this);
-                       foreach ($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['connectToDB'] as $_funcRef) {
-                               GeneralUtility::callUserFunction($_funcRef, $_params, $this);
-                       }
-               }
-       }
-
-       /**
-        * Looks up the value of $this->RDCT in the database and if it is
-        * found to be associated with a redirect URL then the redirection
-        * is carried out with a 'Location:' header
-        * May exit after sending a location-header.
-        *
-        * @return void
-        */
-       public function sendRedirect() {
-               if ($this->RDCT) {
-                       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('params', 'cache_md5params', 'md5hash=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($this->RDCT, 'cache_md5params'));
-                       if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
-                               $this->updateMD5paramsRecord($this->RDCT);
-                               header('Location: ' . $row['params']);
-                               die;
-                       }
-               }
-       }
-
-       /**
-        * Gets instance of PageRenderer
-        *
-        * @return PageRenderer
-        * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8.
-        */
-       public function getPageRenderer() {
-               GeneralUtility::logDeprecatedFunction();
-               $this->initPageRenderer();
-
-               return $this->pageRenderer;
-       }
-
-       /********************************************
-        *
-        * Initializing, resolving page id
-        *
-        ********************************************/
-       /**
-        * Initializes the caching system.
-        *
-        * @return void
-        */
-       protected function initCaches() {
-               $this->pageCache = GeneralUtility::makeInstance(CacheManager::class)->getCache('cache_pages');
-       }
-
-       /**
-        * Initializes the front-end login user.
-        *
-        * @return void
-        */
-       public function initFEuser() {
-               $this->fe_user = GeneralUtility::makeInstance(FrontendUserAuthentication::class);
-               $this->fe_user->lockIP = $this->TYPO3_CONF_VARS['FE']['lockIP'];
-               $this->fe_user->checkPid = $this->TYPO3_CONF_VARS['FE']['checkFeUserPid'];
-               $this->fe_user->lifetime = (int)$this->TYPO3_CONF_VARS['FE']['lifetime'];
-               // List of pid's acceptable
-               $pid = GeneralUtility::_GP('pid');
-               $this->fe_user->checkPid_value = $pid ? $GLOBALS['TYPO3_DB']->cleanIntList($pid) : 0;
-               // Check if a session is transferred:
-               if (GeneralUtility::_GP('FE_SESSION_KEY')) {
-                       $fe_sParts = explode('-', GeneralUtility::_GP('FE_SESSION_KEY'));
-                       // If the session key hash check is OK:
-                       if (md5(($fe_sParts[0] . '/' . $this->TYPO3_CONF_VARS['SYS']['encryptionKey'])) === (string)$fe_sParts[1]) {
-                               $cookieName = FrontendUserAuthentication::getCookieName();
-                               $_COOKIE[$cookieName] = $fe_sParts[0];
-                               if (isset($_SERVER['HTTP_COOKIE'])) {
-                                       // See http://forge.typo3.org/issues/27740
-                                       $_SERVER['HTTP_COOKIE'] .= ';' . $cookieName . '=' . $fe_sParts[0];
-                               }
-                               $this->fe_user->forceSetCookie = 1;
-                               $this->fe_user->dontSetCookie = FALSE;
-                               unset($cookieName);
-                       }
-               }
-               $this->fe_user->start();
-               $this->fe_user->unpack_uc('');
-               // Gets session data
-               $this->fe_user->fetchSessionData();
-               $recs = GeneralUtility::_GP('recs');
-               // If any record registration is submitted, register the record.
-               if (is_array($recs)) {
-                       $this->fe_user->record_registration($recs, $this->TYPO3_CONF_VARS['FE']['maxSessionDataSize']);
-               }
-               // Call hook for possible manipulation of frontend user object
-               if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['initFEuser'])) {
-                       $_params = array('pObj' => &$this);
-                       foreach ($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['initFEuser'] as $_funcRef) {
-                               GeneralUtility::callUserFunction($_funcRef, $_params, $this);
-                       }
-               }
-               // For every 60 seconds the is_online timestamp is updated.
-               if (is_array($this->fe_user->user) && $this->fe_user->user['uid'] && $this->fe_user->user['is_online'] < $GLOBALS['EXEC_TIME'] - 60) {
-                       $GLOBALS['TYPO3_DB']->exec_UPDATEquery('fe_users', 'uid=' . (int)$this->fe_user->user['uid'], array('is_online' => $GLOBALS['EXEC_TIME']));
-               }
-       }
-
-       /**
-        * Initializes the front-end user groups.
-        * Sets ->loginUser and ->gr_list based on front-end user status.
-        *
-        * @return void
-        */
-       public function initUserGroups() {
-               // This affects the hidden-flag selecting the fe_groups for the user!
-               $this->fe_user->showHiddenRecords = $this->showHiddenRecords;
-               // no matter if we have an active user we try to fetch matching groups which can be set without an user (simulation for instance!)
-               $this->fe_user->fetchGroupData();
-               if (is_array($this->fe_user->user) && !empty($this->fe_user->groupData['uid'])) {
-                       // global flag!
-                       $this->loginUser = TRUE;
-                       // group -2 is not an existing group, but denotes a 'default' group when a user IS logged in. This is used to let elements be shown for all logged in users!
-                       $this->gr_list = '0,-2';
-                       $gr_array = $this->fe_user->groupData['uid'];
-               } else {
-                       $this->loginUser = FALSE;
-                       // group -1 is not an existing group, but denotes a 'default' group when not logged in. This is used to let elements be hidden, when a user is logged in!
-                       $this->gr_list = '0,-1';
-                       if ($this->loginAllowedInBranch) {
-                               // For cases where logins are not banned from a branch usergroups can be set based on IP masks so we should add the usergroups uids.
-                               $gr_array = $this->fe_user->groupData['uid'];
-                       } else {
-                               // Set to blank since we will NOT risk any groups being set when no logins are allowed!
-                               $gr_array = array();
-                       }
-               }
-               // Clean up.
-               // Make unique...
-               $gr_array = array_unique($gr_array);
-               // sort
-               sort($gr_array);
-               if (!empty($gr_array) && !$this->loginAllowedInBranch_mode) {
-                       $this->gr_list .= ',' . implode(',', $gr_array);
-               }
-               if ($this->fe_user->writeDevLog) {
-                       GeneralUtility::devLog('Valid usergroups for TSFE: ' . $this->gr_list, __CLASS__);
-               }
-       }
-
-       /**
-        * Checking if a user is logged in or a group constellation different from "0,-1"
-        *
-        * @return bool TRUE if either a login user is found (array fe_user->user) OR if the gr_list is set to something else than '0,-1' (could be done even without a user being logged in!)
-        */
-       public function isUserOrGroupSet() {
-               return is_array($this->fe_user->user) || $this->gr_list !== '0,-1';
-       }
-
-       /**
-        * Provides ways to bypass the '?id=[xxx]&type=[xx]' format, using either PATH_INFO or virtual HTML-documents (using Apache mod_rewrite)
-        *
-        * Two options:
-        * 1) Use PATH_INFO (also Apache) to extract id and type from that var. Does not require any special modules compiled with apache. (less typical)
-        * 2) Using hook which enables features like those provided from "realurl" extension (AKA "Speaking URLs")
-        *
-        * @return void
-        */
-       public function checkAlternativeIdMethods() {
-               $this->siteScript = GeneralUtility::getIndpEnv('TYPO3_SITE_SCRIPT');
-               // Call post processing function for custom URL methods.
-               if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['checkAlternativeIdMethods-PostProc'])) {
-                       $_params = array('pObj' => &$this);
-                       foreach ($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['checkAlternativeIdMethods-PostProc'] as $_funcRef) {
-                               GeneralUtility::callUserFunction($_funcRef, $_params, $this);
-                       }
-               }
-       }
-
-       /**
-        * Clears the preview-flags, sets sim_exec_time to current time.
-        * Hidden pages must be hidden as default, $GLOBALS['SIM_EXEC_TIME'] is set to $GLOBALS['EXEC_TIME']
-        * in bootstrap initializeGlobalTimeVariables(). Alter it by adding or subtracting seconds.
-        *
-        * @return void
-        */
-       public function clear_preview() {
-               $this->showHiddenPage = FALSE;
-               $this->showHiddenRecords = FALSE;
-               $GLOBALS['SIM_EXEC_TIME'] = $GLOBALS['EXEC_TIME'];
-               $GLOBALS['SIM_ACCESS_TIME'] = $GLOBALS['ACCESS_TIME'];
-               $this->fePreview = 0;
-       }
-
-       /**
-        * Checks if a backend user is logged in
-        *
-        * @return bool whether a backend user is logged in
-        */
-       public function isBackendUserLoggedIn() {
-               return (bool)$this->beUserLogin;
-       }
-
-       /**
-        * Creates the backend user object and returns it.
-        *
-        * @return FrontendBackendUserAuthentication the backend user object
-        */
-       public function initializeBackendUser() {
-               // PRE BE_USER HOOK
-               if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/index_ts.php']['preBeUser'])) {
-                       foreach ($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/index_ts.php']['preBeUser'] as $_funcRef) {
-                               $_params = array();
-                               GeneralUtility::callUserFunction($_funcRef, $_params, $this);
-                       }
-               }
-               /** @var $BE_USER FrontendBackendUserAuthentication */
-               $BE_USER = NULL;
-               // If the backend cookie is set,
-               // we proceed and check if a backend user is logged in.
-               if ($_COOKIE[BackendUserAuthentication::getCookieName()]) {
-                       $GLOBALS['TYPO3_MISC']['microtime_BE_USER_start'] = microtime(TRUE);
-                       $GLOBALS['TT']->push('Back End user initialized', '');
-                       // @todo validate the comment below: is this necessary? if so,
-                       //   formfield_status should be set to "" in \TYPO3\CMS\Backend\FrontendBackendUserAuthentication
-                       //   which is a subclass of \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
-                       // ----
-                       // the value this->formfield_status is set to empty in order to
-                       // disable login-attempts to the backend account through this script
-                       // New backend user object
-                       $BE_USER = GeneralUtility::makeInstance(FrontendBackendUserAuthentication::class);
-                       $BE_USER->lockIP = $this->TYPO3_CONF_VARS['BE']['lockIP'];
-                       // Object is initialized
-                       $BE_USER->start();
-                       $BE_USER->unpack_uc('');
-                       if (!empty($BE_USER->user['uid'])) {
-                               $BE_USER->fetchGroupData();
-                               $this->beUserLogin = TRUE;
-                       }
-                       // Unset the user initialization.
-                       if (!$BE_USER->checkLockToIP() || !$BE_USER->checkBackendAccessSettingsFromInitPhp() || empty($BE_USER->user['uid'])) {
-                               $BE_USER = NULL;
-                               $this->beUserLogin = FALSE;
-                       }
-                       $GLOBALS['TT']->pull();
-                       $GLOBALS['TYPO3_MISC']['microtime_BE_USER_end'] = microtime(TRUE);
-               }
-               // POST BE_USER HOOK
-               if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/index_ts.php']['postBeUser'])) {
-                       $_params = array(
-                               'BE_USER' => &$BE_USER
-                       );
-                       foreach ($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/index_ts.php']['postBeUser'] as $_funcRef) {
-                               GeneralUtility::callUserFunction($_funcRef, $_params, $this);
-                       }
-               }
-               return $BE_USER;
-       }
-
-       /**
-        * Determines the id and evaluates any preview settings
-        * Basically this function is about determining whether a backend user is logged in, if he has read access to the page and if he's previewing the page. That all determines which id to show and how to initialize the id.
-        *
-        * @return void
-        */
-       public function determineId() {
-               // Call pre processing function for id determination
-               if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['determineId-PreProcessing'])) {
-                       foreach ($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['determineId-PreProcessing'] as $functionReference) {
-                               $parameters = array('parentObject' => $this);
-                               GeneralUtility::callUserFunction($functionReference, $parameters, $this);
-                       }
-               }
-               // Getting ARG-v values if some
-               $this->setIDfromArgV();
-               // If there is a Backend login we are going to check for any preview settings:
-               $GLOBALS['TT']->push('beUserLogin', '');
-               $originalFrontendUser = NULL;
-               if ($this->beUserLogin || $this->doWorkspacePreview()) {
-                       // Backend user preview features:
-                       if ($this->beUserLogin && $GLOBALS['BE_USER']->adminPanel instanceof AdminPanelView) {
-                               $this->fePreview = (bool)$GLOBALS['BE_USER']->adminPanel->extGetFeAdminValue('preview');
-                               // If admin panel preview is enabled...
-                               if ($this->fePreview) {
-                                       if ($this->fe_user->user) {
-                                               $originalFrontendUser = $this->fe_user->user;
-                                       }
-                                       $this->showHiddenPage = (bool)$GLOBALS['BE_USER']->adminPanel->extGetFeAdminValue('preview', 'showHiddenPages');
-                                       $this->showHiddenRecords = (bool)$GLOBALS['BE_USER']->adminPanel->extGetFeAdminValue('preview', 'showHiddenRecords');
-                                       // Simulate date
-                                       $simTime = $GLOBALS['BE_USER']->adminPanel->extGetFeAdminValue('preview', 'simulateDate');
-                                       if ($simTime) {
-                                               $GLOBALS['SIM_EXEC_TIME'] = $simTime;
-                                               $GLOBALS['SIM_ACCESS_TIME'] = $simTime - $simTime % 60;
-                                       }
-                                       // simulate user
-                                       $simUserGroup = $GLOBALS['BE_USER']->adminPanel->extGetFeAdminValue('preview', 'simulateUserGroup');
-                                       $this->simUserGroup = $simUserGroup;
-                                       if ($simUserGroup) {
-                                               if ($this->fe_user->user) {
-                                                       $this->fe_user->user[$this->fe_user->usergroup_column] = $simUserGroup;
-                                               } else {
-                                                       $this->fe_user->user = array(
-                                                               $this->fe_user->usergroup_column => $simUserGroup
-                                                       );
-                                               }
-                                       }
-                                       if (!$simUserGroup && !$simTime && !$this->showHiddenPage && !$this->showHiddenRecords) {
-                                               $this->fePreview = 0;
-                                       }
-                               }
-                       }
-                       if ($this->id) {
-                               if ($this->determineIdIsHiddenPage()) {
-                                       // The preview flag is set only if the current page turns out to actually be hidden!
-                                       $this->fePreview = 1;
-                                       $this->showHiddenPage = TRUE;
-                               }
-                               // For Live workspace: Check root line for proper connection to tree root (done because of possible preview of page / branch versions)
-                               if (!$this->fePreview && $this->whichWorkspace() === 0) {
-                                       // Initialize the page-select functions to check rootline:
-                                       $temp_sys_page = GeneralUtility::makeInstance(PageRepository::class);
-                                       $temp_sys_page->init($this->showHiddenPage);
-                                       // If root line contained NO records and ->error_getRootLine_failPid tells us that it was because of a pid=-1 (indicating a "version" record)...:
-                                       if (empty($temp_sys_page->getRootLine($this->id, $this->MP)) && $temp_sys_page->error_getRootLine_failPid == -1) {
-                                               // Setting versioningPreview flag and try again:
-                                               $temp_sys_page->versioningPreview = TRUE;
-                                               if (!empty($temp_sys_page->getRootLine($this->id, $this->MP))) {
-                                                       // Finally, we got a root line (meaning that it WAS due to versioning preview of a page somewhere) and we set the fePreview flag which in itself will allow sys_page class to display previews of versionized records.
-                                                       $this->fePreview = 1;
-                                               }
-                                       }
-                               }
-                       }
-                       // The preview flag will be set if a backend user is in an offline workspace
-                       if (
-                                       (
-                                               $GLOBALS['BE_USER']->user['workspace_preview']
-                                               || GeneralUtility::_GP('ADMCMD_view')
-                                               || $this->doWorkspacePreview()
-                                       )
-                                       && (
-                                               $this->whichWorkspace() === -1
-                                               || $this->whichWorkspace() > 0
-                                       )
-                                       && !GeneralUtility::_GP('ADMCMD_noBeUser')
-                       ) {
-                               // Will show special preview message.
-                               $this->fePreview = 2;
-                       }
-                       // If the front-end is showing a preview, caching MUST be disabled.
-                       if ($this->fePreview) {
-                               $this->disableCache();
-                       }
-               }
-               $GLOBALS['TT']->pull();
-               // Now, get the id, validate access etc:
-               $this->fetch_the_id();
-               // Check if backend user has read access to this page. If not, recalculate the id.
-               if ($this->beUserLogin && $this->fePreview) {
-                       if (!$GLOBALS['BE_USER']->doesUserHaveAccess($this->page, 1)) {
-                               // Resetting
-                               $this->clear_preview();
-                               $this->fe_user->user = $originalFrontendUser;
-                               // Fetching the id again, now with the preview settings reset.
-                               $this->fetch_the_id();
-                       }
-               }
-               // Checks if user logins are blocked for a certain branch and if so, will unset user login and re-fetch ID.
-               $this->loginAllowedInBranch = $this->checkIfLoginAllowedInBranch();
-               // Logins are not allowed:
-               if (!$this->loginAllowedInBranch) {
-                       // Only if there is a login will we run this...
-                       if ($this->isUserOrGroupSet()) {
-                               if ($this->loginAllowedInBranch_mode == 'all') {
-                                       // Clear out user and group:
-                                       $this->fe_user->hideActiveLogin();
-                                       $this->gr_list = '0,-1';
-                               } else {
-                                       $this->gr_list = '0,-2';
-                               }
-                               // Fetching the id again, now with the preview settings reset.
-                               $this->fetch_the_id();
-                       }
-               }
-               // Final cleaning.
-               // Make sure it's an integer
-               $this->id = ($this->contentPid = (int)$this->id);
-               // Make sure it's an integer
-               $this->type = (int)$this->type;
-               // Call post processing function for id determination:
-               if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['determineId-PostProc'])) {
-                       $_params = array('pObj' => &$this);
-                       foreach ($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['determineId-PostProc'] as $_funcRef) {
-                               GeneralUtility::callUserFunction($_funcRef, $_params, $this);
-                       }
-               }
-       }
-
-       /**
-        * Checks if the page is hidden in the active workspace.
-        * If it is hidden, preview flags will be set.
-        *
-        * @return bool
-        */
-       protected function determineIdIsHiddenPage() {
-               $field = MathUtility::canBeInterpretedAsInteger($this->id) ? 'uid' : 'alias';
-               $pageSelectCondition = $field . '=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($this->id, 'pages');
-               $page = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('uid,hidden,starttime,endtime', 'pages', $pageSelectCondition . ' AND pid>=0 AND deleted=0');
-               $workspace = $this->whichWorkspace();
-               if ($workspace !== 0 && $workspace !== FALSE) {
-                       // Fetch overlay of page if in workspace and check if it is hidden
-                       $pageSelectObject = GeneralUtility::makeInstance(PageRepository::class);
-                       $pageSelectObject->versioningPreview = TRUE;
-                       $pageSelectObject->init(FALSE);
-                       $targetPage = $pageSelectObject->getWorkspaceVersionOfRecord($this->whichWorkspace(), 'pages', $page['uid']);
-                       $result = $targetPage === -1 || $targetPage === -2;
-               } else {
-                       $result = is_array($page) && ($page['hidden'] || $page['starttime'] > $GLOBALS['SIM_EXEC_TIME'] || $page['endtime'] != 0 && $page['endtime'] <= $GLOBALS['SIM_EXEC_TIME']);
-               }
-               return $result;
-       }
-
-       /**
-        * Get The Page ID
-        * This gets the id of the page, checks if the page is in the domain and if the page is accessible
-        * Sets variables such as $this->sys_page, $this->loginUser, $this->gr_list, $this->id, $this->type, $this->domainStartPage
-        *
-        * @throws ServiceUnavailableException
-        * @return void
-        * @access private
-        */
-       public function fetch_the_id() {
-               $GLOBALS['TT']->push('fetch_the_id initialize/', '');
-               // Initialize the page-select functions.
-               $this->sys_page = GeneralUtility::makeInstance(PageRepository::class);
-               $this->sys_page->versioningPreview = $this->fePreview === 2 || (int)$this->workspacePreview || (bool)GeneralUtility::_GP('ADMCMD_view');
-               $this->sys_page->versioningWorkspaceId = $this->whichWorkspace();
-               $this->sys_page->init($this->showHiddenPage);
-               // Set the valid usergroups for FE
-               $this->initUserGroups();
-               // Sets sys_page where-clause
-               $this->setSysPageWhereClause();
-               // Splitting $this->id by a period (.).
-               // First part is 'id' and second part (if exists) will overrule the &type param
-               $idParts = explode('.', $this->id, 2);
-               $this->id = $idParts[0];
-               if (isset($idParts[1])) {
-                       $this->type = $idParts[1];
-               }
-
-               // If $this->id is a string, it's an alias
-               $this->checkAndSetAlias();
-               // The id and type is set to the integer-value - just to be sure...
-               $this->id = (int)$this->id;
-               $this->type = (int)$this->type;
-               $GLOBALS['TT']->pull();
-               // We find the first page belonging to the current domain
-               $GLOBALS['TT']->push('fetch_the_id domain/', '');
-               // The page_id of the current domain
-               $this->domainStartPage = $this->findDomainRecord($this->TYPO3_CONF_VARS['SYS']['recursiveDomainSearch']);
-               if (!$this->id) {
-                       if ($this->domainStartPage) {
-                               // If the id was not previously set, set it to the id of the domain.
-                               $this->id = $this->domainStartPage;
-                       } else {
-                               // Find the first 'visible' page in that domain
-                               $theFirstPage = $this->sys_page->getFirstWebPage($this->id);
-                               if ($theFirstPage) {
-                                       $this->id = $theFirstPage['uid'];
-                               } else {
-                                       $message = 'No pages are found on the rootlevel!';
-                                       if ($this->checkPageUnavailableHandler()) {
-                                               $this->pageUnavailableAndExit($message);
-                                       } else {
-                                               GeneralUtility::sysLog($message, 'cms', GeneralUtility::SYSLOG_SEVERITY_ERROR);
-                                               throw new ServiceUnavailableException($message, 1301648975);
-                                       }
-                               }
-                       }
-               }
-               $GLOBALS['TT']->pull();
-               $GLOBALS['TT']->push('fetch_the_id rootLine/', '');
-               // We store the originally requested id
-               $this->requestedId = $this->id;
-               $this->getPageAndRootlineWithDomain($this->domainStartPage);
-               $GLOBALS['TT']->pull();
-               if ($this->pageNotFound && $this->TYPO3_CONF_VARS['FE']['pageNotFound_handling']) {
-                       $pNotFoundMsg = array(
-                               1 => 'ID was not an accessible page',
-                               2 => 'Subsection was found and not accessible',
-                               3 => 'ID was outside the domain',
-                               4 => 'The requested page alias does not exist'
-                       );
-                       $this->pageNotFoundAndExit($pNotFoundMsg[$this->pageNotFound]);
-               }
-               if ($this->page['url_scheme'] > 0) {
-                       $newUrl = '';
-                       $requestUrlScheme = parse_url(GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'), PHP_URL_SCHEME);
-                       if ((int)$this->page['url_scheme'] === HttpUtility::SCHEME_HTTP && $requestUrlScheme == 'https') {
-                               $newUrl = 'http://' . substr(GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'), 8);
-                       } elseif ((int)$this->page['url_scheme'] === HttpUtility::SCHEME_HTTPS && $requestUrlScheme == 'http') {
-                               $newUrl = 'https://' . substr(GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'), 7);
-                       }
-                       if ($newUrl !== '') {
-                               if ($_SERVER['REQUEST_METHOD'] === 'POST') {
-                                       $headerCode = HttpUtility::HTTP_STATUS_303;
-                               } else {
-                                       $headerCode = HttpUtility::HTTP_STATUS_301;
-                               }
-                               HttpUtility::redirect($newUrl, $headerCode);
-                       }
-               }
-               // Set no_cache if set
-               if ($this->page['no_cache']) {
-                       $this->set_no_cache('no_cache is set in page properties');
-               }
-               // Init SYS_LASTCHANGED
-               $this->register['SYS_LASTCHANGED'] = (int)$this->page['tstamp'];
-               if ($this->register['SYS_LASTCHANGED'] < (int)$this->page['SYS_LASTCHANGED']) {
-                       $this->register['SYS_LASTCHANGED'] = (int)$this->page['SYS_LASTCHANGED'];
-               }
-               if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['fetchPageId-PostProcessing'])) {
-                       foreach ($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['fetchPageId-PostProcessing'] as $functionReference) {
-                               $parameters = array('parentObject' => $this);
-                               GeneralUtility::callUserFunction($functionReference, $parameters, $this);
-                       }
-               }
-       }
-
-       /**
-        * Gets the page and rootline arrays based on the id, $this->id
-        *
-        * If the id does not correspond to a proper page, the 'previous' valid page in the rootline is found
-        * If the page is a shortcut (doktype=4), the ->id is loaded with that id
-        *
-        * Whether or not the ->id is changed to the shortcut id or the previous id in rootline (eg if a page is hidden), the ->page-array and ->rootline is found and must also be valid.
-        *
-        * Sets or manipulates internal variables such as: $this->id, $this->page, $this->rootLine, $this->MP, $this->pageNotFound
-        *
-        * @throws ServiceUnavailableException
-        * @throws PageNotFoundException
-        * @return void
-        * @access private
-        */
-       public function getPageAndRootline() {
-               $this->page = $this->sys_page->getPage($this->id);
-               if (empty($this->page)) {
-                       // If no page, we try to find the page before in the rootLine.
-                       // Page is 'not found' in case the id itself was not an accessible page. code 1
-                       $this->pageNotFound = 1;
-                       $this->rootLine = $this->sys_page->getRootLine($this->id, $this->MP);
-                       if (!empty($this->rootLine)) {
-                               $c = count($this->rootLine) - 1;
-                               while ($c > 0) {
-                                       // Add to page access failure history:
-                                       $this->pageAccessFailureHistory['direct_access'][] = $this->rootLine[$c];
-                                       // Decrease to next page in rootline and check the access to that, if OK, set as page record and ID value.
-                                       $c--;
-                                       $this->id = $this->rootLine[$c]['uid'];
-                                       $this->page = $this->sys_page->getPage($this->id);
-                                       if (!empty($this->page)) {
-                                               break;
-                                       }
-                               }
-                       }
-                       // If still no page...
-                       if (empty($this->page)) {
-                               $message = 'The requested page does not exist!';
-                               if ($this->TYPO3_CONF_VARS['FE']['pageNotFound_handling']) {
-                                       $this->pageNotFoundAndExit($message);
-                               } else {
-                                       GeneralUtility::sysLog($message, 'cms', GeneralUtility::SYSLOG_SEVERITY_ERROR);
-                                       throw new PageNotFoundException($message, 1301648780);
-                               }
-                       }
-               }
-               // Spacer is not accessible in frontend
-               if ($this->page['doktype'] == PageRepository::DOKTYPE_SPACER) {
-                       $message = 'The requested page does not exist!';
-                       if ($this->TYPO3_CONF_VARS['FE']['pageNotFound_handling']) {
-                               $this->pageNotFoundAndExit($message);
-                       } else {
-                               GeneralUtility::sysLog($message, 'cms', GeneralUtility::SYSLOG_SEVERITY_ERROR);
-                               throw new PageNotFoundException($message, 1301648781);
-                       }
-               }
-               // Is the ID a link to another page??
-               if ($this->page['doktype'] == PageRepository::DOKTYPE_SHORTCUT) {
-                       // We need to clear MP if the page is a shortcut. Reason is if the short cut goes to another page, then we LEAVE the rootline which the MP expects.
-                       $this->MP = '';
-                       // saving the page so that we can check later - when we know
-                       // about languages - whether we took the correct shortcut or
-                       // whether a translation of the page overwrites the shortcut
-                       // target and we need to follow the new target
-                       $this->originalShortcutPage = $this->page;
-                       $this->page = $this->getPageShortcut($this->page['shortcut'], $this->page['shortcut_mode'], $this->page['uid']);
-                       $this->id = $this->page['uid'];
-               }
-               // If the page is a mountpoint which should be overlaid with the contents of the mounted page,
-               // it must never be accessible directly, but only in the mountpoint context. Therefore we change
-               // the current ID and the user is redirected by checkPageForMountpointRedirect().
-               if ($this->page['doktype'] == PageRepository::DOKTYPE_MOUNTPOINT && $this->page['mount_pid_ol']) {
-                       $this->originalMountPointPage = $this->page;
-                       $this->page = $this->sys_page->getPage($this->page['mount_pid']);
-                       if (empty($this->page)) {
-                               $message = 'This page (ID ' . $this->originalMountPointPage['uid'] . ') is of type "Mount point" and '
-                                       . 'mounts a page which is not accessible (ID ' . $this->originalMountPointPage['mount_pid'] . ').';
-                               throw new PageNotFoundException($message, 1402043263);
-                       }
-                       $this->MP = $this->page['uid'] . '-' . $this->originalMountPointPage['uid'];
-                       $this->id = $this->page['uid'];
-               }
-               // Gets the rootLine
-               $this->rootLine = $this->sys_page->getRootLine($this->id, $this->MP);
-               // If not rootline we're off...
-               if (empty($this->rootLine)) {
-                       $ws = $this->whichWorkspace();
-                       if ($this->sys_page->error_getRootLine_failPid == -1 && $ws) {
-                               $this->sys_page->versioningPreview = TRUE;
-                               $this->sys_page->versioningWorkspaceId = $ws;
-                               $this->rootLine = $this->sys_page->getRootLine($this->id, $this->MP);
-                       }
-                       if (empty($this->rootLine)) {
-                               $message = 'The requested page didn\'t have a proper connection to the tree-root!';
-                               if ($this->checkPageUnavailableHandler()) {
-                                       $this->pageUnavailableAndExit($message);
-                               } else {
-                                       $rootline = '(' . $this->sys_page->error_getRootLine . ')';
-                                       GeneralUtility::sysLog($message, 'cms', GeneralUtility::SYSLOG_SEVERITY_ERROR);
-                                       throw new ServiceUnavailableException($message . '<br /><br />' . $rootline, 1301648167);
-                               }
-                       }
-                       $this->fePreview = 1;
-               }
-               // Checking for include section regarding the hidden/starttime/endtime/fe_user (that is access control of a whole subbranch!)
-               if ($this->checkRootlineForIncludeSection()) {
-                       if (empty($this->rootLine)) {
-                               $message = 'The requested page was not accessible!';
-                               if ($this->checkPageUnavailableHandler()) {
-                                       $this->pageUnavailableAndExit($message);
-                               } else {
-                                       GeneralUtility::sysLog($message, 'cms', GeneralUtility::SYSLOG_SEVERITY_ERROR);
-                                       throw new ServiceUnavailableException($message, 1301648234);
-                               }
-                       } else {
-                               $el = reset($this->rootLine);
-                               $this->id = $el['uid'];
-                               $this->page = $this->sys_page->getPage($this->id);
-                               $this->rootLine = $this->sys_page->getRootLine($this->id, $this->MP);
-                       }
-               }
-       }
-
-       /**
-        * Get page shortcut; Finds the records pointed to by input value $SC (the shortcut value)
-        *
-        * @param int $SC The value of the "shortcut" field from the pages record
-        * @param int $mode The shortcut mode: 1 will select first subpage, 2 a random subpage, 3 the parent page; default is the page pointed to by $SC
-        * @param int $thisUid The current page UID of the page which is a shortcut
-        * @param int $itera Safety feature which makes sure that the function is calling itself recursively max 20 times (since this function can find shortcuts to other shortcuts to other shortcuts...)
-        * @param array $pageLog An array filled with previous page uids tested by the function - new page uids are evaluated against this to avoid going in circles.
-        * @param bool $disableGroupCheck If true, the group check is disabled when fetching the target page (needed e.g. for menu generation)
-        * @throws \RuntimeException
-        * @throws PageNotFoundException
-        * @return mixed Returns the page record of the page that the shortcut pointed to.
-        * @access private
-        * @see getPageAndRootline()
-        */
-       public function getPageShortcut($SC, $mode, $thisUid, $itera = 20, $pageLog = array(), $disableGroupCheck = FALSE) {
-               $idArray = GeneralUtility::intExplode(',', $SC);
-               // Find $page record depending on shortcut mode:
-               switch ($mode) {
-                       case PageRepository::SHORTCUT_MODE_FIRST_SUBPAGE:
-
-                       case PageRepository::SHORTCUT_MODE_RANDOM_SUBPAGE:
-                               $pageArray = $this->sys_page->getMenu($idArray[0] ? $idArray[0] : $thisUid, '*', 'sorting', 'AND pages.doktype<199 AND pages.doktype!=' . PageRepository::DOKTYPE_BE_USER_SECTION);
-                               $pO = 0;
-                               if ($mode == PageRepository::SHORTCUT_MODE_RANDOM_SUBPAGE && !empty($pageArray)) {
-                                       $randval = (int)rand(0, count($pageArray) - 1);
-                                       $pO = $randval;
-                               }
-                               $c = 0;
-                               foreach ($pageArray as $pV) {
-                                       if ($c == $pO) {
-                                               $page = $pV;
-                                               break;
-                                       }
-                                       $c++;
-                               }
-                               if (empty($page)) {
-                                       $message = 'This page (ID ' . $thisUid . ') is of type "Shortcut" and configured to redirect to a subpage. ' . 'However, this page has no accessible subpages.';
-                                       throw new PageNotFoundException($message, 1301648328);
-                               }
-                               break;
-                       case PageRepository::SHORTCUT_MODE_PARENT_PAGE:
-                               $parent = $this->sys_page->getPage($idArray[0] ? $idArray[0] : $thisUid, $disableGroupCheck);
-                               $page = $this->sys_page->getPage($parent['pid'], $disableGroupCheck);
-                               if (empty($page)) {
-                                       $message = 'This page (ID ' . $thisUid . ') is of type "Shortcut" and configured to redirect to its parent page. ' . 'However, the parent page is not accessible.';
-                                       throw new PageNotFoundException($message, 1301648358);
-                               }
-                               break;
-                       default:
-                               $page = $this->sys_page->getPage($idArray[0], $disableGroupCheck);
-                               if (empty($page)) {
-                                       $message = 'This page (ID ' . $thisUid . ') is of type "Shortcut" and configured to redirect to a page, which is not accessible (ID ' . $idArray[0] . ').';
-                                       throw new PageNotFoundException($message, 1301648404);
-                               }
-               }
-               // Check if short cut page was a shortcut itself, if so look up recursively:
-               if ($page['doktype'] == PageRepository::DOKTYPE_SHORTCUT) {
-                       if (!in_array($page['uid'], $pageLog) && $itera > 0) {
-                               $pageLog[] = $page['uid'];
-                               $page = $this->getPageShortcut($page['shortcut'], $page['shortcut_mode'], $page['uid'], $itera - 1, $pageLog, $disableGroupCheck);
-                       } else {
-                               $pageLog[] = $page['uid'];
-                               $message = 'Page shortcuts were looping in uids ' . implode(',', $pageLog) . '...!';
-                               GeneralUtility::sysLog($message, 'cms', GeneralUtility::SYSLOG_SEVERITY_ERROR);
-                               throw new \RuntimeException($message, 1294587212);
-                       }
-               }
-               // Return resulting page:
-               return $page;
-       }
-
-       /**
-        * Checks the current rootline for defined sections.
-        *
-        * @return bool
-        * @access private
-        */
-       public function checkRootlineForIncludeSection() {
-               $c = count($this->rootLine);
-               $removeTheRestFlag = 0;
-               for ($a = 0; $a < $c; $a++) {
-                       if (!$this->checkPagerecordForIncludeSection($this->rootLine[$a])) {
-                               // Add to page access failure history:
-                               $this->pageAccessFailureHistory['sub_section'][] = $this->rootLine[$a];
-                               $removeTheRestFlag = 1;
-                       }
-                       if ($this->rootLine[$a]['doktype'] == PageRepository::DOKTYPE_BE_USER_SECTION) {
-                               // If there is a backend user logged in, check if he has read access to the page:
-                               if ($this->beUserLogin) {
-                                       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'pages', 'uid=' . (int)$this->id . ' AND ' . $GLOBALS['BE_USER']->getPagePermsClause(1));
-                                       // versionOL()?
-                                       list($isPage) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
-                                       if (!$isPage) {
-                                               // If there was no page selected, the user apparently did not have read access to the current PAGE (not position in rootline) and we set the remove-flag...
-                                               $removeTheRestFlag = 1;
-                                       }
-                               } else {
-                                       // Dont go here, if there is no backend user logged in.
-                                       $removeTheRestFlag = 1;
-                               }
-                       }
-                       if ($removeTheRestFlag) {
-                               // Page is 'not found' in case a subsection was found and not accessible, code 2
-                               $this->pageNotFound = 2;
-                               unset($this->rootLine[$a]);
-                       }
-               }
-               return $removeTheRestFlag;
-       }
-
-       /**
-        * Checks page record for enableFields
-        * Returns TRUE if enableFields does not disable the page record.
-        * Takes notice of the ->showHiddenPage flag and uses SIM_ACCESS_TIME for start/endtime evaluation
-        *
-        * @param array $row The page record to evaluate (needs fields: hidden, starttime, endtime, fe_group)
-        * @param bool $bypassGroupCheck Bypass group-check
-        * @return bool TRUE, if record is viewable.
-        * @see TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer::getTreeList(), checkPagerecordForIncludeSection()
-        */
-       public function checkEnableFields($row, $bypassGroupCheck = FALSE) {
-               if (isset($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['hook_checkEnableFields']) && is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['hook_checkEnableFields'])) {
-                       $_params = array('pObj' => $this, 'row' => &$row, 'bypassGroupCheck' => &$bypassGroupCheck);
-                       foreach ($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['hook_checkEnableFields'] as $_funcRef) {
-                               // Call hooks: If one returns FALSE, method execution is aborted with result "This record is not available"
-                               $return = GeneralUtility::callUserFunction($_funcRef, $_params, $this);
-                               if ($return === FALSE) {
-                                       return FALSE;
-                               }
-                       }
-               }
-               if ((!$row['hidden'] || $this->showHiddenPage) && $row['starttime'] <= $GLOBALS['SIM_ACCESS_TIME'] && ($row['endtime'] == 0 || $row['endtime'] > $GLOBALS['SIM_ACCESS_TIME']) && ($bypassGroupCheck || $this->checkPageGroupAccess($row))) {
-                       return TRUE;
-               }
-       }
-
-       /**
-        * Check group access against a page record
-        *
-        * @param array $row The page record to evaluate (needs field: fe_group)
-        * @param mixed $groupList List of group id's (comma list or array). Default is $this->gr_list
-        * @return bool TRUE, if group access is granted.
-        * @access private
-        */
-       public function checkPageGroupAccess($row, $groupList = NULL) {
-               if (is_null($groupList)) {
-                       $groupList = $this->gr_list;
-               }
-               if (!is_array($groupList)) {
-                       $groupList = explode(',', $groupList);
-               }
-               $pageGroupList = explode(',', $row['fe_group'] ?: 0);
-               return count(array_intersect($groupList, $pageGroupList)) > 0;
-       }
-
-       /**
-        * Checks page record for include section
-        *
-        * @param array $row The page record to evaluate (needs fields: extendToSubpages + hidden, starttime, endtime, fe_group)
-        * @return bool Returns TRUE if either extendToSubpages is not checked or if the enableFields does not disable the page record.
-        * @access private
-        * @see checkEnableFields(), TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer::getTreeList(), checkRootlineForIncludeSection()
-        */
-       public function checkPagerecordForIncludeSection($row) {
-               return !$row['extendToSubpages'] || $this->checkEnableFields($row) ? 1 : 0;
-       }
-
-       /**
-        * Checks if logins are allowed in the current branch of the page tree. Traverses the full root line and returns TRUE if logins are OK, otherwise FALSE (and then the login user must be unset!)
-        *
-        * @return bool returns TRUE if logins are OK, otherwise FALSE (and then the login user must be unset!)
-        */
-       public function checkIfLoginAllowedInBranch() {
-               // Initialize:
-               $c = count($this->rootLine);
-               $disable = FALSE;
-               // Traverse root line from root and outwards:
-               for ($a = 0; $a < $c; $a++) {
-                       // If a value is set for login state:
-                       if ($this->rootLine[$a]['fe_login_mode'] > 0) {
-                               // Determine state from value:
-                               if ((int)$this->rootLine[$a]['fe_login_mode'] === 1) {
-                                       $disable = TRUE;
-                                       $this->loginAllowedInBranch_mode = 'all';
-                               } elseif ((int)$this->rootLine[$a]['fe_login_mode'] === 3) {
-                                       $disable = TRUE;
-                                       $this->loginAllowedInBranch_mode = 'groups';
-                               } else {
-                                       $disable = FALSE;
-                               }
-                       }
-               }
-               return !$disable;
-       }
-
-       /**
-        * Analysing $this->pageAccessFailureHistory into a summary array telling which features disabled display and on which pages and conditions. That data can be used inside a page-not-found handler
-        *
-        * @return array Summary of why page access was not allowed.
-        */
-       public function getPageAccessFailureReasons() {
-               $output = array();
-               $combinedRecords = array_merge(is_array($this->pageAccessFailureHistory['direct_access']) ? $this->pageAccessFailureHistory['direct_access'] : array(array('fe_group' => 0)), is_array($this->pageAccessFailureHistory['sub_section']) ? $this->pageAccessFailureHistory['sub_section'] : array());
-               if (!empty($combinedRecords)) {
-                       foreach ($combinedRecords as $k => $pagerec) {
-                               // If $k=0 then it is the very first page the original ID was pointing at and that will get a full check of course
-                               // If $k>0 it is parent pages being tested. They are only significant for the access to the first page IF they had the extendToSubpages flag set, hence checked only then!
-                               if (!$k || $pagerec['extendToSubpages']) {
-                                       if ($pagerec['hidden']) {
-                                               $output['hidden'][$pagerec['uid']] = TRUE;
-                                       }
-                                       if ($pagerec['starttime'] > $GLOBALS['SIM_ACCESS_TIME']) {
-                                               $output['starttime'][$pagerec['uid']] = $pagerec['starttime'];
-                                       }
-                                       if ($pagerec['endtime'] != 0 && $pagerec['endtime'] <= $GLOBALS['SIM_ACCESS_TIME']) {
-                                               $output['endtime'][$pagerec['uid']] = $pagerec['endtime'];
-                                       }
-                                       if (!$this->checkPageGroupAccess($pagerec)) {
-                                               $output['fe_group'][$pagerec['uid']] = $pagerec['fe_group'];
-                                       }
-                               }
-                       }
-               }
-               return $output;
-       }
-
-       /**
-        * This checks if there are ARGV-parameters in the QUERY_STRING and if so, those are used for the id
-        * $this->id must be 'FALSE' in order for any processing to happen in here
-        * If an id/alias value is extracted from the QUERY_STRING it is set in $this->id
-        *
-        * @return void
-        * @access private
-        */
-       public function setIDfromArgV() {
-               if (!$this->id) {
-                       list($theAlias) = explode('&', GeneralUtility::getIndpEnv('QUERY_STRING'));
-                       $theAlias = trim($theAlias);
-                       $this->id = $theAlias != '' && strpos($theAlias, '=') === FALSE ? $theAlias : 0;
-               }
-       }
-
-       /**
-        * Gets ->page and ->rootline information based on ->id. ->id may change during this operation.
-        * If not inside domain, then default to first page in domain.
-        *
-        * @param int $domainStartPage Page uid of the page where the found domain record is (pid of the domain record)
-        * @return void
-        * @access private
-        */
-       public function getPageAndRootlineWithDomain($domainStartPage) {
-               $this->getPageAndRootline();
-               // Checks if the $domain-startpage is in the rootLine. This is necessary so that references to page-id's from other domains are not possible.
-               if ($domainStartPage && is_array($this->rootLine)) {
-                       $idFound = 0;
-                       foreach ($this->rootLine as $key => $val) {
-                               if ($val['uid'] == $domainStartPage) {
-                                       $idFound = 1;
-                                       break;
-                               }
-                       }
-                       if (!$idFound) {
-                               // Page is 'not found' in case the id was outside the domain, code 3
-                               $this->pageNotFound = 3;
-                               $this->id = $domainStartPage;
-                               // re-get the page and rootline if the id was not found.
-                               $this->getPageAndRootline();
-                       }
-               }
-       }
-
-       /**
-        * Sets sys_page where-clause
-        *
-        * @return void
-        * @access private
-        */
-       public function setSysPageWhereClause() {
-               $this->sys_page->where_hid_del .= ' AND pages.doktype<200';
-               $this->sys_page->where_groupAccess = $this->sys_page->getMultipleGroupsWhereClause('pages.fe_group', 'pages');
-       }
-
-       /**
-        * Looking up a domain record based on HTTP_HOST
-        *
-        * @param bool $recursive If set, it looks "recursively" meaning that a domain like "123.456.typo3.com" would find a domain record like "typo3.com" if "123.456.typo3.com" or "456.typo3.com" did not exist.
-        * @return int Returns the page id of the page where the domain record was found.
-        * @access private
-        */
-       public function findDomainRecord($recursive = FALSE) {
-               if ($recursive) {
-                       $host = explode('.', GeneralUtility::getIndpEnv('HTTP_HOST'));
-                       while (count($host)) {
-                               $pageUid = $this->sys_page->getDomainStartPage(implode('.', $host), GeneralUtility::getIndpEnv('SCRIPT_NAME'), GeneralUtility::getIndpEnv('REQUEST_URI'));
-                               if ($pageUid) {
-                                       return $pageUid;
-                               } else {
-                                       array_shift($host);
-                               }
-                       }
-                       return $pageUid;
-               } else {
-                       return $this->sys_page->getDomainStartPage(GeneralUtility::getIndpEnv('HTTP_HOST'), GeneralUtility::getIndpEnv('SCRIPT_NAME'), GeneralUtility::getIndpEnv('REQUEST_URI'));
-               }
-       }
-
-       /**
-        * Page unavailable handler for use in frontend plugins from extensions.
-        *
-        * @param string $reason Reason text
-        * @param string $header HTTP header to send
-        * @return void Function exits.
-        */
-       public function pageUnavailableAndExit($reason = '', $header = '') {
-               $header = $header ?: $this->TYPO3_CONF_VARS['FE']['pageUnavailable_handling_statheader'];
-               $this->pageUnavailableHandler($this->TYPO3_CONF_VARS['FE']['pageUnavailable_handling'], $header, $reason);
-               die;
-       }
-
-       /**
-        * Page-not-found handler for use in frontend plugins from extensions.
-        *
-        * @param string $reason Reason text
-        * @param string $header HTTP header to send
-        * @return void Function exits.
-        */
-       public function pageNotFoundAndExit($reason = '', $header = '') {
-               $header = $header ?: $this->TYPO3_CONF_VARS['FE']['pageNotFound_handling_statheader'];
-               $this->pageNotFoundHandler($this->TYPO3_CONF_VARS['FE']['pageNotFound_handling'], $header, $reason);
-               die;
-       }
-
-       /**
-        * Checks whether the pageUnavailableHandler should be used. To be used, pageUnavailable_handling must be set
-        * and devIPMask must not match the current visitor's IP address.
-        *
-        * @return bool TRUE/FALSE whether the pageUnavailable_handler should be used.
-        */
-       public function checkPageUnavailableHandler() {
-               if (
-                       $this->TYPO3_CONF_VARS['FE']['pageUnavailable_handling']
-                       && !GeneralUtility::cmpIP(
-                               GeneralUtility::getIndpEnv('REMOTE_ADDR'),
-                               $this->TYPO3_CONF_VARS['SYS']['devIPmask']
-                       )
-               ) {
-                       $checkPageUnavailableHandler = TRUE;
-               } else {
-                       $checkPageUnavailableHandler = FALSE;
-               }
-               return $checkPageUnavailableHandler;
-       }
-
-       /**
-        * Page unavailable handler. Acts a wrapper for the pageErrorHandler method.
-        *
-        * @param mixed $code Which type of handling; If a true PHP-boolean or TRUE then a \TYPO3\CMS\Core\Messaging\ErrorpageMessage is outputted. If integer an error message with that number is shown. Otherwise the $code value is expected to be a "Location:" header value.
-        * @param string $header If set, this is passed directly to the PHP function, header()
-        * @param string $reason If set, error messages will also mention this as the reason for the page-not-found.
-        * @return void (The function exits!)
-        */
-       public function pageUnavailableHandler($code, $header, $reason) {
-               $this->pageErrorHandler($code, $header, $reason);
-       }
-
-       /**
-        * Page not found handler. Acts a wrapper for the pageErrorHandler method.
-        *
-        * @param mixed $code Which type of handling; If a true PHP-boolean or TRUE then a \TYPO3\CMS\Core\Messaging\ErrorpageMessage is outputted. If integer an error message with that number is shown. Otherwise the $code value is expected to be a "Location:" header value.
-        * @param string $header If set, this is passed directly to the PHP function, header()
-        * @param string $reason If set, error messages will also mention this as the reason for the page-not-found.
-        * @return void (The function exits!)
-        */
-       public function pageNotFoundHandler($code, $header = '', $reason = '') {
-               $this->pageErrorHandler($code, $header, $reason);
-       }
-
-       /**
-        * Generic error page handler.
-        * Exits.
-        *
-        * @param mixed $code Which type of handling; If a true PHP-boolean or TRUE then a \TYPO3\CMS\Core\Messaging\ErrorpageMessage is outputted. If integer an error message with that number is shown. Otherwise the $code value is expected to be a "Location:" header value.
-        * @param string $header If set, this is passed directly to the PHP function, header()
-        * @param string $reason If set, error messages will also mention this as the reason for the page-not-found.
-        * @throws \RuntimeException
-        * @return void (The function exits!)
-        */
-       public function pageErrorHandler($code, $header = '', $reason = '') {
-               // Issue header in any case:
-               if ($header) {
-                       $headerArr = preg_split('/\\r|\\n/', $header, -1, PREG_SPLIT_NO_EMPTY);
-                       foreach ($headerArr as $header) {
-                               header($header);
-                       }
-               }
-               // Create response:
-               // Simply boolean; Just shows TYPO3 error page with reason:
-               if (gettype($code) == 'boolean' || (string)$code === '1') {
-                       $title = 'Page Not Found';
-                       $message = 'The page did not exist or was inaccessible.' . ($reason ? ' Reason: ' . htmlspecialchars($reason) : '');
-                       $messagePage = GeneralUtility::makeInstance(ErrorpageMessage::class, $message, $title);
-                       $messagePage->output();
-                       die;
-               } elseif (GeneralUtility::isFirstPartOfStr($code, 'USER_FUNCTION:')) {
-                       $funcRef = trim(substr($code, 14));
-                       $params = array(
-                               'currentUrl' => GeneralUtility::getIndpEnv('REQUEST_URI'),
-                               'reasonText' => $reason,
-                               'pageAccessFailureReasons' => $this->getPageAccessFailureReasons()
-                       );
-                       echo GeneralUtility::callUserFunction($funcRef, $params, $this);
-               } elseif (GeneralUtility::isFirstPartOfStr($code, 'READFILE:')) {
-                       $readFile = GeneralUtility::getFileAbsFileName(trim(substr($code, 9)));
-                       if (@is_file($readFile)) {
-                               echo str_replace(
-                                       array(
-                                               '###CURRENT_URL###',
-                                               '###REASON###'
-                                       ),
-                                       array(
-                                               GeneralUtility::getIndpEnv('REQUEST_URI'),
-                                               htmlspecialchars($reason)
-                                       ),
-                                       GeneralUtility::getUrl($readFile)
-                               );
-                       } else {
-                               throw new \RuntimeException('Configuration Error: 404 page "' . $readFile . '" could not be found.', 1294587214);
-                       }
-               } elseif (GeneralUtility::isFirstPartOfStr($code, 'REDIRECT:')) {
-                       HttpUtility::redirect(substr($code, 9));
-               } elseif ($code !== '') {
-                       // Check if URL is relative
-                       $url_parts = parse_url($code);
-                       if ($url_parts['host'] == '') {
-                               $url_parts['host'] = GeneralUtility::getIndpEnv('HTTP_HOST');
-                               if ($code[0] === '/') {
-                                       $code = GeneralUtility::getIndpEnv('TYPO3_REQUEST_HOST') . $code;
-                               } else {
-                                       $code = GeneralUtility::getIndpEnv('TYPO3_REQUEST_DIR') . $code;
-                               }
-                               $checkBaseTag = FALSE;
-                       } else {
-                               $checkBaseTag = TRUE;
-                       }
-                       // Check recursion
-                       if ($code == GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL')) {
-                               if ($reason == '') {
-                                       $reason = 'Page cannot be found.';
-                               }
-                               $reason .= LF . LF . 'Additionally, ' . $code . ' was not found while trying to retrieve the error document.';
-                               throw new \RuntimeException(nl2br(htmlspecialchars($reason)), 1294587215);
-                       }
-                       // Prepare headers
-                       $headerArr = array(
-                               'User-agent: ' . GeneralUtility::getIndpEnv('HTTP_USER_AGENT'),
-                               'Referer: ' . GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL')
-                       );
-                       $res = GeneralUtility::getUrl($code, 1, $headerArr);
-                       // Header and content are separated by an empty line
-                       list($header, $content) = explode(CRLF . CRLF, $res, 2);
-                       $content .= CRLF;
-                       if (FALSE === $res) {
-                               // Last chance -- redirect
-                               HttpUtility::redirect($code);
-                       } else {
-                               // Forward these response headers to the client
-                               $forwardHeaders = array(
-                                       'Content-Type:'
-                               );
-                               $headerArr = preg_split('/\\r|\\n/', $header, -1, PREG_SPLIT_NO_EMPTY);
-                               foreach ($headerArr as $header) {
-                                       foreach ($forwardHeaders as $h) {
-                                               if (preg_match('/^' . $h . '/', $header)) {
-                                                       header($header);
-                                               }
-                                       }
-                               }
-                               // Put <base> if necesary
-                               if ($checkBaseTag) {
-                                       // If content already has <base> tag, we do not need to do anything
-                                       if (FALSE === stristr($content, '<base ')) {
-                                               // Generate href for base tag
-                                               $base = $url_parts['scheme'] . '://';
-                                               if ($url_parts['user'] != '') {
-                                                       $base .= $url_parts['user'];
-                                                       if ($url_parts['pass'] != '') {
-                                                               $base .= ':' . $url_parts['pass'];
-                                                       }
-                                                       $base .= '@';
-                                               }
-                                               $base .= $url_parts['host'];
-                                               // Add path portion skipping possible file name
-                                               $base .= preg_replace('/(.*\\/)[^\\/]*/', '${1}', $url_parts['path']);
-                                               // Put it into content (generate also <head> if necessary)
-                                               $replacement = LF . '<base href="' . htmlentities($base) . '" />' . LF;
-                                               if (stristr($content, '<head>')) {
-                                                       $content = preg_replace('/(<head>)/i', '\\1' . $replacement, $content);
-                                               } else {
-                                                       $content = preg_replace('/(<html[^>]*>)/i', '\\1<head>' . $replacement . '</head>', $content);
-                                               }
-                                       }
-                               }
-                               // Output the content
-                               echo $content;
-                       }
-               } else {
-                       $title = 'Page Not Found';
-                       $message = $reason ? 'Reason: ' . htmlspecialchars($reason) : 'Page cannot be found.';
-                       $messagePage = GeneralUtility::makeInstance(ErrorpageMessage::class, $message, $title);
-                       $messagePage->output();
-               }
-               die;
-       }
-
-       /**
-        * Fetches the integer page id for a page alias.
-        * Looks if ->id is not an integer and if so it will search for a page alias and if found the page uid of that page is stored in $this->id
-        *
-        * @return void
-        * @access private
-        */
-       public function checkAndSetAlias() {
-               if ($this->id && !MathUtility::canBeInterpretedAsInteger($this->id)) {
-                       $aid = $this->sys_page->getPageIdFromAlias($this->id);
-                       if ($aid) {
-                               $this->id = $aid;
-                       } else {
-                               $this->pageNotFound = 4;
-                       }
-               }
-       }
-
-       /**
-        * Merging values into the global $_GET
-        *
-        * @param array $GET_VARS Array of key/value pairs that will be merged into the current GET-vars. (Non-escaped values)
-        * @return void
-        */
-       public function mergingWithGetVars($GET_VARS) {
-               if (is_array($GET_VARS)) {
-                       // Getting $_GET var, unescaped.
-                       $realGet = GeneralUtility::_GET();
-                       if (!is_array($realGet)) {
-                               $realGet = array();
-                       }
-                       // Merge new values on top:
-                       ArrayUtility::mergeRecursiveWithOverrule($realGet, $GET_VARS);
-                       // Write values back to $_GET:
-                       GeneralUtility::_GETset($realGet);
-                       // Setting these specifically (like in the init-function):
-                       if (isset($GET_VARS['type'])) {
-                               $this->type = (int)$GET_VARS['type'];
-                       }
-                       if (isset($GET_VARS['cHash'])) {
-                               $this->cHash = $GET_VARS['cHash'];
-                       }
-                       if (isset($GET_VARS['jumpurl'])) {
-                               $this->jumpurl = $GET_VARS['jumpurl'];
-                       }
-                       if (isset($GET_VARS['MP'])) {
-                               $this->MP = $this->TYPO3_CONF_VARS['FE']['enable_mount_pids'] ? $GET_VARS['MP'] : '';
-                       }
-                       if (isset($GET_VARS['no_cache']) && $GET_VARS['no_cache']) {
-                               $this->set_no_cache('no_cache is requested via GET parameter');
-                       }
-               }
-       }
-
-       /********************************************
-        *
-        * Template and caching related functions.
-        *
-        *******************************************/
-       /**
-        * Calculates a hash string based on additional parameters in the url.
-        *
-        * Calculated hash is stored in $this->cHash_array.
-        * This is used to cache pages with more parameters than just id and type.
-        *
-        * @return void
-        * @see reqCHash()
-        */
-       public function makeCacheHash() {
-               // No need to test anything if caching was already disabled.
-               if ($this->no_cache && !$this->TYPO3_CONF_VARS['FE']['pageNotFoundOnCHashError']) {
-                       return;
-               }
-               $GET = GeneralUtility::_GET();
-               if ($this->cHash && is_array($GET)) {
-                       $this->cHash_array = $this->cacheHash->getRelevantParameters(GeneralUtility::implodeArrayForUrl('', $GET));
-                       $cHash_calc = $this->cacheHash->calculateCacheHash($this->cHash_array);
-                       if ($cHash_calc != $this->cHash) {
-                               if ($this->TYPO3_CONF_VARS['FE']['pageNotFoundOnCHashError']) {
-                                       $this->pageNotFoundAndExit('Request parameters could not be validated (&cHash comparison failed)');
-                               } else {
-                                       $this->disableCache();
-                                       $GLOBALS['TT']->setTSlogMessage('The incoming cHash "' . $this->cHash . '" and calculated cHash "' . $cHash_calc . '" did not match, so caching was disabled. The fieldlist used was "' . implode(',', array_keys($this->cHash_array)) . '"', 2);
-                               }
-                       }
-               } elseif (is_array($GET)) {
-                       // No cHash is set, check if that is correct
-                       if ($this->cacheHash->doParametersRequireCacheHash(GeneralUtility::implodeArrayForUrl('', $GET))) {
-                               $this->reqCHash();
-                       }
-               }
-       }
-
-       /**
-        * Will disable caching if the cHash value was not set.
-        * This function should be called to check the _existence_ of "&cHash" whenever a plugin generating cacheable output is using extra GET variables. If there _is_ a cHash value the validation of it automatically takes place in makeCacheHash() (see above)
-        *
-        * @return void
-        * @see makeCacheHash(), \TYPO3\CMS\Frontend\Plugin\AbstractPlugin::pi_cHashCheck()
-        */
-       public function reqCHash() {
-               if (!$this->cHash) {
-                       if ($this->TYPO3_CONF_VARS['FE']['pageNotFoundOnCHashError']) {
-                               if ($this->tempContent) {
-                                       $this->clearPageCacheContent();
-                               }
-                               $this->pageNotFoundAndExit('Request parameters could not be validated (&cHash empty)');
-                       } else {
-                               $this->disableCache();
-                               $GLOBALS['TT']->setTSlogMessage('TSFE->reqCHash(): No &cHash parameter was sent for GET vars though required so caching is disabled', 2);
-                       }
-               }
-       }
-
-       /**
-        * Initialize the TypoScript template parser
-        *
-        * @return void
-        */
-       public function initTemplate() {
-               $this->tmpl = GeneralUtility::makeInstance(TemplateService::class);
-               $this->tmpl->setVerbose((bool)$this->beUserLogin);
-               $this->tmpl->init();
-               $this->tmpl->tt_track = (bool)$this->beUserLogin;
-       }
-
-       /**
-        * See if page is in cache and get it if so
-        * Stores the page content in $this->content if something is found.
-        *
-        * @throws \InvalidArgumentException
-        * @throws \RuntimeException
-        */
-       public function getFromCache() {
-               // clearing the content-variable, which will hold the pagecontent
-               $this->content = '';
-               // Unsetting the lowlevel config
-               unset($this->config);
-               $this->cacheContentFlag = FALSE;
-
-               if ($this->no_cache) {
-                       return;
-               }
-
-               $pageSectionCacheContent = $this->tmpl->getCurrentPageData();
-               if (!is_array($pageSectionCacheContent)) {
-                       // Nothing in the cache, we acquire an "exclusive lock" for the key now.
-                       // We use the Registry to store this lock centrally,
-                       // but we protect the access again with a global exclusive lock to avoid race conditions
-
-                       $this->acquireLock('pagesection', $this->id . '::' . $this->MP);
-                       //
-                       // from this point on we're the only one working on that page ($key)
-                       //
-
-                       // query the cache again to see if the page data are there meanwhile
-                       $pageSectionCacheContent = $this->tmpl->getCurrentPageData();
-                       if (is_array($pageSectionCacheContent)) {
-                               // we have the content, nice that some other process did the work for us already
-                               $this->releaseLock('pagesection');
-                       } else {
-                               // We keep the lock set, because we are the ones generating the page now
-                               // and filling the cache.
-                               // This indicates that we have to release the lock in the Registry later in releaseLocks()
-                       }
-               }
-
-               if (is_array($pageSectionCacheContent)) {
-                       // BE CAREFUL to change the content of the cc-array. This array is serialized and an md5-hash based on this is used for caching the page.
-                       // If this hash is not the same in here in this section and after page-generation, then the page will not be properly cached!
-                       // This array is an identification of the template. If $this->all is empty it's because the template-data is not cached, which it must be.
-                       $pageSectionCacheContent = $this->tmpl->matching($pageSectionCacheContent);
-                       ksort($pageSectionCacheContent);
-                       $this->all = $pageSectionCacheContent;
-               }
-               unset($pageSectionCacheContent);
-
-               // Look for page in cache only if a shift-reload is not sent to the server.
-               $lockHash = $this->getLockHash();
-               if (!$this->headerNoCache()) {
-                       if ($this->all) {
-                               // we got page section information
-                               $this->newHash = $this->getHash();
-                               $GLOBALS['TT']->push('Cache Row', '');
-                               $row = $this->getFromCache_queryRow();
-                               if (!is_array($row)) {
-                                       // nothing in the cache, we acquire an exclusive lock now
-
-                                       $this->acquireLock('pages', $lockHash);
-                                       //
-                                       // from this point on we're the only one working on that page ($lockHash)
-                                       //
-
-                                       // query the cache again to see if the data are there meanwhile
-                                       $row = $this->getFromCache_queryRow();
-                                       if (is_array($row)) {
-                                               // we have the content, nice that some other process did the work for us
-                                               $this->releaseLock('pages');
-                                       } else {
-                                               // We keep the lock set, because we are the ones generating the page now
-                                               // and filling the cache.
-                                               // This indicates that we have to release the lock in the Registry later in releaseLocks()
-                                       }
-                               }
-                               if (is_array($row)) {
-                                       // we have data from cache
-
-                                       // Call hook when a page is retrieved from cache:
-                                       if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['pageLoadedFromCache'])) {
-                                               $_params = array('pObj' => &$this, 'cache_pages_row' => &$row);
-                                               foreach ($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['pageLoadedFromCache'] as $_funcRef) {
-                                                       GeneralUtility::callUserFunction($_funcRef, $_params, $this);
-                                               }
-                                       }
-                                       // Fetches the lowlevel config stored with the cached data
-                                       $this->config = $row['cache_data'];
-                                       // Getting the content
-                                       $this->content = $row['content'];
-                                       // Flag for temp content
-                                       $this->tempContent = $row['temp_content'];
-                                       // Setting flag, so we know, that some cached content has been loaded
-                                       $this->cacheContentFlag = TRUE;
-                                       $this->cacheExpires = $row['expires'];
-
-                                       // Restore page title information, this is needed to generate the page title for
-                                       // partially cached pages.
-                                       $this->page['title'] = $row['pageTitleInfo']['title'];
-                                       $this->altPageTitle = $row['pageTitleInfo']['altPageTitle'];
-                                       $this->indexedDocTitle = $row['pageTitleInfo']['indexedDocTitle'];
-
-                                       if (isset($this->config['config']['debug'])) {
-                                               $debugCacheTime = (bool)$this->config['config']['debug'];
-                                       } else {
-                                               $debugCacheTime = !empty($this->TYPO3_CONF_VARS['FE']['debug']);
-                                       }
-                                       if ($debugCacheTime) {
-                                               $dateFormat = $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'];
-                                               $timeFormat = $GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'];
-                                               $this->content .= LF . '<!-- Cached page generated ' . date(($dateFormat . ' ' . $timeFormat), $row['tstamp']) . '. Expires ' . Date(($dateFormat . ' ' . $timeFormat), $row['expires']) . ' -->';
-                                       }
-                               }
-                               $GLOBALS['TT']->pull();
-
-                               return;
-                       }
-               }
-               // the user forced rebuilding the page cache or there was no pagesection information
-               // get a lock for the page content so other processes will not interrupt the regeneration
-               $this->acquireLock('pages', $lockHash);
-       }
-
-       /**
-        * Returning the cached version of page with hash = newHash
-        *
-        * @return array Cached row, if any. Otherwise void.
-        */
-       public function getFromCache_queryRow() {
-               $GLOBALS['TT']->push('Cache Query', '');
-               $row = $this->pageCache->get($this->newHash);
-               $GLOBALS['TT']->pull();
-               return $row;
-       }
-
-       /**
-        * Detecting if shift-reload has been clicked
-        * Will not be called if re-generation of page happens by other reasons (for instance that the page is not in cache yet!)
-        * Also, a backend user MUST be logged in for the shift-reload to be detected due to DoS-attack-security reasons.
-        *
-        * @return bool If shift-reload in client browser has been clicked, disable getting cached page (and regenerate it).
-        */
-       public function headerNoCache() {
-               $disableAcquireCacheData = FALSE;
-               if ($this->beUserLogin) {
-                       if (strtolower($_SERVER['HTTP_CACHE_CONTROL']) === 'no-cache' || strtolower($_SERVER['HTTP_PRAGMA']) === 'no-cache') {
-                               $disableAcquireCacheData = TRUE;
-                       }
-               }
-               // Call hook for possible by-pass of requiring of page cache (for recaching purpose)
-               if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['headerNoCache'])) {
-                       $_params = array('pObj' => &$this, 'disableAcquireCacheData' => &$disableAcquireCacheData);
-                       foreach ($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['headerNoCache'] as $_funcRef) {
-                               GeneralUtility::callUserFunction($_funcRef, $_params, $this);
-                       }
-               }
-               return $disableAcquireCacheData;
-       }
-
-       /**
-        * Calculates the cache-hash
-        * This hash is unique to the template, the variables ->id, ->type, ->gr_list (list of groups), ->MP (Mount Points) and cHash array
-        * Used to get and later store the cached data.
-        *
-        * @return string MD5 hash of serialized hash base from createHashBase()
-        * @access private
-        * @see getFromCache(), getLockHash()
-        */
-       public function getHash() {
-               return md5($this->createHashBase(FALSE));
-       }
-
-       /**
-        * Calculates the lock-hash
-        * This hash is unique to the above hash, except that it doesn't contain the template information in $this->all.
-        *
-        * @return string MD5 hash
-        * @access private
-        * @see getFromCache(), getHash()
-        */
-       public function getLockHash() {
-               $lockHash = $this->createHashBase(TRUE);
-               return md5($lockHash);
-       }
-
-       /**
-        * Calculates the cache-hash (or the lock-hash)
-        * This hash is unique to the template,
-        * the variables ->id, ->type, ->gr_list (list of groups),
-        * ->MP (Mount Points) and cHash array
-        * Used to get and later store the cached data.
-        *
-        * @param bool $createLockHashBase Whether to create the lock hash, which doesn't contain the "this->all" (the template information)
-        * @return string the serialized hash base
-        */
-       protected function createHashBase($createLockHashBase = FALSE) {
-               $hashParameters = array(
-                       'id' => (int)$this->id,
-                       'type' => (int)$this->type,
-                       'gr_list' => (string)$this->gr_list,
-                       'MP' => (string)$this->MP,
-                       'cHash' => $this->cHash_array,
-                       'domainStartPage' => $this->domainStartPage
-               );
-               // Include the template information if we shouldn't create a lock hash
-               if (!$createLockHashBase) {
-                       $hashParameters['all'] = $this->all;
-               }
-               // Call hook to influence the hash calculation
-               if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['createHashBase'])) {
-                       $_params = array(
-                               'hashParameters' => &$hashParameters,
-                               'createLockHashBase' => $createLockHashBase
-                       );
-                       foreach ($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['createHashBase'] as $_funcRef) {
-                               GeneralUtility::callUserFunction($_funcRef, $_params, $this);
-                       }
-               }
-               return serialize($hashParameters);
-       }
-
-       /**
-        * Checks if config-array exists already but if not, gets it
-        *
-        * @throws ServiceUnavailableException
-        * @return void
-        */
-       public function getConfigArray() {
-               $setStatPageName = FALSE;
-               // If config is not set by the cache (which would be a major mistake somewhere) OR if INTincScripts-include-scripts have been registered, then we must parse the template in order to get it
-               if (!is_array($this->config) || is_array($this->config['INTincScript']) || $this->forceTemplateParsing) {
-                       $GLOBALS['TT']->push('Parse template', '');
-                       // Force parsing, if set?:
-                       $this->tmpl->forceTemplateParsing = $this->forceTemplateParsing;
-                       // Start parsing the TS template. Might return cached version.
-                       $this->tmpl->start($this->rootLine);
-                       $GLOBALS['TT']->pull();
-                       if ($this->tmpl->loaded) {
-                               $GLOBALS['TT']->push('Setting the config-array', '');
-                               // toplevel - objArrayName
-                               $this->sPre = $this->tmpl->setup['types.'][$this->type];
-                               $this->pSetup = $this->tmpl->setup[$this->sPre . '.'];
-                               if (!is_array($this->pSetup)) {
-                                       $message = 'The page is not configured! [type=' . $this->type . '][' . $this->sPre . '].';
-                                       if ($this->checkPageUnavailableHandler()) {
-                                               $this->pageUnavailableAndExit($message);
-                                       } else {
-                                               $explanation = 'This means that there is no TypoScript object of type PAGE with typeNum=' . $this->type . ' configured.';
-                                               GeneralUtility::sysLog($message, 'cms', GeneralUtility::SYSLOG_SEVERITY_ERROR);
-                                               throw new ServiceUnavailableException($message . ' ' . $explanation, 1294587217);
-                                       }
-                               } else {
-                                       if (!isset($this->config['config'])) {
-                                               $this->config['config'] = array();
-                                       }
-                                       // Filling the config-array, first with the main "config." part
-                                       if (is_array($this->tmpl->setup['config.'])) {
-                                               ArrayUtility::mergeRecursiveWithOverrule($this->tmpl->setup['config.'], $this->config['config']);
-                                               $this->config['config'] = $this->tmpl->setup['config.'];
-                                       }
-                                       // override it with the page/type-specific "config."
-                                       if (is_array($this->pSetup['config.'])) {
-                                               ArrayUtility::mergeRecursiveWithOverrule($this->config['config'], $this->pSetup['config.']);
-                                       }
-                                       if ($this->config['config']['typolinkEnableLinksAcrossDomains']) {
-                                               $this->config['config']['typolinkCheckRootline'] = TRUE;
-                                       }
-                                       // Set default values for removeDefaultJS and inlineStyle2TempFile so CSS and JS are externalized if compatversion is higher than 4.0
-                                       if (!isset($this->config['config']['removeDefaultJS'])) {
-                                               $this->config['config']['removeDefaultJS'] = 'external';
-                                       }
-                                       if (!isset($this->config['config']['inlineStyle2TempFile'])) {
-                                               $this->config['config']['inlineStyle2TempFile'] = 1;
-                                       }
-
-                                       if (!isset($this->config['config']['compressJs'])) {
-                                               $this->config['config']['compressJs'] = 0;
-                                       }
-                                       // Processing for the config_array:
-                                       $this->config['rootLine'] = $this->tmpl->rootLine;
-                                       $this->config['mainScript'] = trim($this->config['config']['mainScript']) ?: 'index.php';
-                                       // Class for render Header and Footer parts
-                                       $template = '';
-                                       if ($this->pSetup['pageHeaderFooterTemplateFile']) {
-                                               $file = $this->tmpl->getFileName($this->pSetup['pageHeaderFooterTemplateFile']);
-                                               if ($file) {
-                                                       $this->pageRenderer->setTemplateFile($file);
-                                               }
-                                       }
-                               }
-                               $GLOBALS['TT']->pull();
-                       } else {
-                               if ($this->checkPageUnavailableHandler()) {
-                                       $this->pageUnavailableAndExit('No TypoScript template found!');
-                               } else {
-                                       $message = 'No TypoScript template found!';
-                                       GeneralUtility::sysLog($message, 'cms', GeneralUtility::SYSLOG_SEVERITY_ERROR);
-                                       throw new ServiceUnavailableException($message, 1294587218);
-                               }
-                       }
-               }
-
-               // No cache
-               // Set $this->no_cache TRUE if the config.no_cache value is set!
-               if ($this->config['config']['no_cache']) {
-                       $this->set_no_cache('config.no_cache is set');
-               }
-               // Merge GET with defaultGetVars
-               if (!empty($this->config['config']['defaultGetVars.'])) {
-                       $modifiedGetVars = GeneralUtility::removeDotsFromTS($this->config['config']['defaultGetVars.']);
-                       ArrayUtility::mergeRecursiveWithOverrule($modifiedGetVars, GeneralUtility::_GET());
-                       GeneralUtility::_GETset($modifiedGetVars);
-               }
-               // Hook for postProcessing the configuration array
-               if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['configArrayPostProc'])) {
-                       $params = array('config' => &$this->config['config']);
-                       foreach ($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['configArrayPostProc'] as $funcRef) {
-                               GeneralUtility::callUserFunction($funcRef, $params, $this);
-                       }
-               }
-       }
-
-       /********************************************
-        *
-        * Further initialization and data processing
-        * (jumpurl/submission of forms)
-        *
-        *******************************************/
-
-       /**
-        * Setting the language key that will be used by the current page.
-        * In this function it should be checked, 1) that this language exists, 2) that a page_overlay_record exists, .. and if not the default language, 0 (zero), should be set.
-        *
-        * @return void
-        * @access private
-        */
-       public function settingLanguage() {
-               if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['settingLanguage_preProcess'])) {
-                       $_params = array();
-                       foreach ($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['settingLanguage_preProcess'] as $_funcRef) {
-                               GeneralUtility::callUserFunction($_funcRef, $_params, $this);
-                       }
-               }
-
-               // Initialize charset settings etc.
-               $this->initLLvars();
-
-               // Get values from TypoScript:
-               $this->sys_language_uid = ($this->sys_language_content = (int)$this->config['config']['sys_language_uid']);
-               list($this->sys_language_mode, $sys_language_content) = GeneralUtility::trimExplode(';', $this->config['config']['sys_language_mode']);
-               $this->sys_language_contentOL = $this->config['config']['sys_language_overlay'];
-               // If sys_language_uid is set to another language than default:
-               if ($this->sys_language_uid > 0) {
-                       // check whether a shortcut is overwritten by a translated page
-                       // we can only do this now, as this is the place where we get
-                       // to know about translations
-                       $this->checkTranslatedShortcut();
-                       // Request the overlay record for the sys_language_uid:
-                       $olRec = $this->sys_page->getPageOverlay($this->id, $this->sys_language_uid);
-                       if (empty($olRec)) {
-                               // If no OL record exists and a foreign language is asked for...
-                               if ($this->sys_language_uid) {
-                                       // If requested translation is not available:
-                                       if (GeneralUtility::hideIfNotTranslated($this->page['l18n_cfg'])) {
-                                               $this->pageNotFoundAndExit('Page is not available in the requested language.');
-                                       } else {
-                                               switch ((string)$this->sys_language_mode) {
-                                                       case 'strict':
-                                                               $this->pageNotFoundAndExit('Page is not available in the requested language (strict).');
-                                                               break;
-                                                       case 'content_fallback':
-                                                               $fallBackOrder = GeneralUtility::intExplode(',', $sys_language_content);
-                                                               foreach ($fallBackOrder as $orderValue) {
-                                                                       if ((string)$orderValue === '0' || !empty($this->sys_page->getPageOverlay($this->id, $orderValue))) {
-                                                                               $this->sys_language_content = $orderValue;
-                                                                               // Setting content uid (but leaving the sys_language_uid)
-                                                                               break;
-                                                                       }
-                                                               }
-                                                               break;
-                                                       case 'ignore':
-                                                               $this->sys_language_content = $this->sys_language_uid;
-                                                               break;
-                                                       default:
-                                                               // Default is that everything defaults to the default language...
-                                                               $this->sys_language_uid = ($this->sys_language_content = 0);
-                                               }
-                                       }
-                               }
-                       } else {
-                               // Setting sys_language if an overlay record was found (which it is only if a language is used)
-                               $this->page = $this->sys_page->getPageOverlay($this->page, $this->sys_language_uid);
-                       }
-               }
-               // Setting sys_language_uid inside sys-page:
-               $this->sys_page->sys_language_uid = $this->sys_language_uid;
-               // If default translation is not available:
-               if ((!$this->sys_language_uid || !$this->sys_language_content) && $this->page['l18n_cfg'] & 1) {
-                       $message = 'Page is not available in default language.';
-                       GeneralUtility::sysLog($message, 'cms', GeneralUtility::SYSLOG_SEVERITY_ERROR);
-                       $this->pageNotFoundAndExit($message);
-               }
-               $this->updateRootLinesWithTranslations();
-
-               // Finding the ISO code for the currently selected language
-               // fetched by the sys_language record when not fetching content from the default language
-               if ($this->sys_language_content > 0) {
-                       // using sys_language_content because the ISO code only (currently) affect content selection from FlexForms - which should follow "sys_language_content"
-                       // Set the fourth parameter to TRUE in the next two getRawRecord() calls to
-                       // avoid versioning overlay to be applied as it generates an SQL error
-                       $sys_language_row = $this->sys_page->getRawRecord('sys_language', $this->sys_language_content, 'language_isocode,static_lang_isocode', TRUE);
-                       if (is_array($sys_language_row)) {
-                               if (!empty($sys_language_row['language_isocode'])) {
-                                       $this->sys_language_isocode = $sys_language_row['language_isocode'];
-                               } elseif ($sys_language_row['static_lang_isocode'] && ExtensionManagementUtility::isLoaded('static_info_tables')) {
-                                       GeneralUtility::deprecationLog('Usage of the field "static_lang_isocode" is discouraged, and will stop working with CMS 8. Use the built-in language field "language_isocode" in your sys_language records.');
-                                       $stLrow = $this->sys_page->getRawRecord('static_languages', $sys_language_row['static_lang_isocode'], 'lg_iso_2', TRUE);
-                                       $this->sys_language_isocode = $stLrow['lg_iso_2'];
-                               }
-                       }
-                       // the DB value is overriden by TypoScript
-                       if (!empty($this->config['config']['sys_language_isocode'])) {
-                               $this->sys_language_isocode = $this->config['config']['sys_language_isocode'];
-                       }
-               } else {
-                       // fallback to the TypoScript option when rendering with sys_language_uid=0
-                       // also: use "en" by default
-                       if (!empty($this->config['config']['sys_language_isocode_default'])) {
-                               $this->sys_language_isocode = $this->config['config']['sys_language_isocode_default'];
-                       } else {
-                               $this->sys_language_isocode = $this->lang != 'default' ? $this->lang : 'en';
-                       }
-               }
-
-
-               // Setting softMergeIfNotBlank:
-               $table_fields = GeneralUtility::trimExplode(',', $this->config['config']['sys_language_softMergeIfNotBlank'], TRUE);
-               foreach ($table_fields as $TF) {
-                       list($tN, $fN) = explode(':', $TF);
-                       $GLOBALS['TCA'][$tN]['columns'][$fN]['l10n_mode'] = 'mergeIfNotBlank';
-               }
-               // Setting softExclude:
-               $table_fields = GeneralUtility::trimExplode(',', $this->config['config']['sys_language_softExclude'], TRUE);
-               foreach ($table_fields as $TF) {
-                       list($tN, $fN) = explode(':', $TF);
-                       $GLOBALS['TCA'][$tN]['columns'][$fN]['l10n_mode'] = 'exclude';
-               }
-               if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['settingLanguage_postProcess'])) {
-                       $_params = array();
-                       foreach ($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['settingLanguage_postProcess'] as $_funcRef) {
-                               GeneralUtility::callUserFunction($_funcRef, $_params, $this);
-                       }
-               }
-       }
-
-       /**
-        * Updating content of the two rootLines IF the language key is set!
-        */
-       protected function updateRootLinesWithTranslations() {
-               if ($this->sys_language_uid) {
-                       $this->rootLine = $this->sys_page->getRootLine($this->id, $this->MP);
-                       $this->tmpl->updateRootlineData($this->rootLine);
-               }
-       }
-
-       /**
-        * Setting locale for frontend rendering
-        *
-        * @return void
-        */
-       public function settingLocale() {
-               // Setting locale
-               if ($this->config['config']['locale_all']) {
-                       // There's a problem that PHP parses float values in scripts wrong if the
-                       // locale LC_NUMERIC is set to something with a comma as decimal point
-                       // Do we set all except LC_NUMERIC
-                       $locale = setlocale(LC_COLLATE, $this->config['config']['locale_all']);
-                       if ($locale) {
-                               setlocale(LC_CTYPE, $this->config['config']['locale_all']);
-                               setlocale(LC_MONETARY, $this->config['config']['locale_all']);
-                               setlocale(LC_TIME, $this->config['config']['locale_all']);
-                               $this->localeCharset = $this->csConvObj->get_locale_charset($this->config['config']['locale_all']);
-                       } else {
-                               $GLOBALS['TT']->setTSlogMessage('Locale "' . htmlspecialchars($this->config['config']['locale_all']) . '" not found.', 3);
-                       }
-               }
-       }
-
-       /**
-        * Checks whether a translated shortcut page has a different shortcut
-        * target than the original language page.
-        * If that is the case, things get corrected to follow that alternative
-        * shortcut
-        *
-        * @return void
-        */
-       protected function checkTranslatedShortcut() {
-               if (!is_null($this->originalShortcutPage)) {
-                       $originalShortcutPageOverlay = $this->sys_page->getPageOverlay($this->originalShortcutPage['uid'], $this->sys_language_uid);
-                       if (!empty($originalShortcutPageOverlay['shortcut']) && $originalShortcutPageOverlay['shortcut'] != $this->id) {
-                               // the translation of the original shortcut page has a different shortcut target!
-                               // set the correct page and id
-                               $shortcut = $this->getPageShortcut($originalShortcutPageOverlay['shortcut'], $originalShortcutPageOverlay['shortcut_mode'], $originalShortcutPageOverlay['uid']);
-                               $this->id = ($this->contentPid = $shortcut['uid']);
-                               $this->page = $this->sys_page->getPage($this->id);
-                               // Fix various effects on things like menus f.e.
-                               $this->fetch_the_id();
-                               $this->tmpl->rootLine = array_reverse($this->rootLine);
-                       }
-               }
-       }
-
-       /**
-        * Handle data submission
-        * This is done at this point, because we need the config values
-        *
-        * @return void
-        */
-       public function handleDataSubmission() {
-               // Hook for processing data submission to extensions
-               if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['checkDataSubmission'])) {
-                       foreach ($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['checkDataSubmission'] as $_classRef) {
-                               $_procObj = GeneralUtility::getUserObj($_classRef);
-                               $_procObj->checkDataSubmission($this);
-                       }
-               }
-       }
-
-       /**
-        * Checks if a formmail submission can be sent as email, also used for JumpURLs
-        * should be removed once JumpURL is handled outside TypoScriptFrontendController
-        *
-        * @param string $locationData The input from $_POST['locationData']
-        * @return void|int
-        */
-       protected function locDataCheck($locationData) {
-               $locData = explode(':', $locationData);
-               if (!$locData[1] || $this->sys_page->checkRecord($locData[1], $locData[2], 1)) {
-                       // $locData[1] -check means that a record is checked only if the locationData has a value for a record else than the page.
-                       if (!empty($this->sys_page->getPage($locData[0]))) {
-                               return 1;
-                       } else {
-                               $GLOBALS['TT']->setTSlogMessage('LocationData Error: The page pointed to by location data (' . $locationData . ') was not accessible.', 2);
-                       }
-               } else {
-                       $GLOBALS['TT']->setTSlogMessage('LocationData Error: Location data (' . $locationData . ') record pointed to was not accessible.', 2);
-               }
-       }
-
-       /**
-        * Sets the jumpurl for page type "External URL"
-        *
-        * @return void
-        */
-       public function setExternalJumpUrl() {
-               if ((bool)$this->config['config']['disablePageExternalUrl'] === FALSE && $extUrl = $this->sys_page->getExtURL($this->page)) {
-                       $this->jumpurl = $extUrl;
-                       GeneralUtility::_GETset(GeneralUtility::hmac($this->jumpurl, 'jumpurl'), 'juHash');
-               }
-       }
-
-       /**
-        * Sends a header "Location" to jumpUrl, if jumpurl is set.
-        * Will exit if a location header is sent (for instance if jumpUrl was triggered)
-        *
-        * "jumpUrl" is a concept where external links are redirected from the index_ts.php script, which first logs the URL.
-        *
-        * @throws \Exception
-        * @return void
-        */
-       public function jumpUrl() {
-               if ($this->jumpurl) {
-                       if (GeneralUtility::_GP('juSecure')) {
-                               $locationData = (string)GeneralUtility::_GP('locationData');
-                               // Need a type cast here because mimeType is optional!
-                               $mimeType = (string)GeneralUtility::_GP('mimeType');
-                               $hArr = array(
-                                       $this->jumpurl,
-                                       $locationData,
-                                       $mimeType
-                               );
-                               $calcJuHash = GeneralUtility::hmac(serialize($hArr));
-                               $juHash = (string)GeneralUtility::_GP('juHash');
-                               if ($juHash === $calcJuHash) {
-                                       if ($this->locDataCheck($locationData)) {
-                                               // 211002 - goes with cObj->filelink() rawurlencode() of filenames so spaces can be allowed.
-                                               $this->jumpurl = rawurldecode($this->jumpurl);
-                                               // Deny access to files that match TYPO3_CONF_VARS[SYS][fileDenyPattern] and whose parent directory is typo3conf/ (there could be a backup file in typo3conf/ which does not match against the fileDenyPattern)
-                                               $absoluteFileName = GeneralUtility::getFileAbsFileName(GeneralUtility::resolveBackPath($this->jumpurl), FALSE);
-                                               if (GeneralUtility::isAllowedAbsPath($absoluteFileName) && GeneralUtility::verifyFilenameAgainstDenyPattern($absoluteFileName) && !GeneralUtility::isFirstPartOfStr($absoluteFileName, (PATH_site . 'typo3conf'))) {
-                                                       if (@is_file($absoluteFileName)) {
-                                                               $mimeType = $mimeType ?: 'application/octet-stream';
-                                                               header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
-                                                               header('Content-Type: ' . $mimeType);
-                                                               header('Content-Disposition: attachment; filename="' . basename($absoluteFileName) . '"');
-                                                               header('Content-Length: ' . filesize($absoluteFileName));
-                                                               GeneralUtility::flushOutputBuffers();
-                                                               readfile($absoluteFileName);
-                                                               die;
-                                                       } else {
-                                                               throw new \Exception('jumpurl Secure: "' . $this->jumpurl . '" was not a valid file!', 1294585193);
-                                                       }
-                                               } else {
-                                                       throw new \Exception('jumpurl Secure: The requested file was not allowed to be accessed through jumpUrl (path or file not allowed)!', 1294585194);
-                                               }
-                                       } else {
-                                               throw new \Exception('jumpurl Secure: locationData, ' . $locationData . ', was not accessible.', 1294585195);
-                                       }
-                               } else {
-                                       throw new \Exception('jumpurl Secure: Calculated juHash did not match the submitted juHash.', 1294585196);
-                               }
-                       } else {
-                               $allowRedirect = FALSE;
-                               if (GeneralUtility::hmac($this->jumpurl, 'jumpurl') === (string)GeneralUtility::_GP('juHash')) {
-                                       $allowRedirect = TRUE;
-                               } elseif (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['jumpurlRedirectHandler'])) {
-                                       foreach ($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['jumpurlRedirectHandler'] as $classReference) {
-                                               $hookObject = GeneralUtility::getUserObj($classReference);
-                                               $allowRedirectFromHook = FALSE;
-                                               if (method_exists($hookObject, 'jumpurlRedirectHandler')) {
-                                                       $allowRedirectFromHook = $hookObject->jumpurlRedirectHandler($this->jumpurl, $this);
-                                               }
-                                               if ($allowRedirectFromHook === TRUE) {
-                                                       $allowRedirect = TRUE;
-                                                       break;
-                                               }
-                                       }
-                               }
-                               if ($allowRedirect) {
-                                       $TSConf = $this->getPagesTSconfig();
-                                       if ($TSConf['TSFE.']['jumpUrl_transferSession']) {
-                                               $uParts = parse_url($this->jumpurl);
-                                               $params = '&FE_SESSION_KEY=' . rawurlencode(($this->fe_user->id . '-' . md5(($this->fe_user->id . '/' . $this->TYPO3_CONF_VARS['SYS']['encryptionKey']))));
-                                               // Add the session parameter ...
-                                               $this->jumpurl .= ($uParts['query'] ? '' : '?') . $params;
-                                       }
-                                       $statusCode = HttpUtility::HTTP_STATUS_303;
-                                       if ($TSConf['TSFE.']['jumpURL_HTTPStatusCode']) {
-                                               switch ((int)$TSConf['TSFE.']['jumpURL_HTTPStatusCode']) {
-                                                       case 301:
-                                                               $statusCode = HttpUtility::HTTP_STATUS_301;
-                                                               break;
-                                                       case 302:
-                                                               $statusCode = HttpUtility::HTTP_STATUS_302;
-                                                               break;
-                                                       case 307:
-                                                               $statusCode = HttpUtility::HTTP_STATUS_307;
-                                                               break;
-                                               }
-                                       }
-                                       HttpUtility::redirect($this->jumpurl, $statusCode);
-                               } else {
-                                       throw new \Exception('jumpurl: Calculated juHash did not match the submitted juHash.', 1359987599);
-                               }
-                       }
-               }
-       }
-
-       /**
-        * Sets the URL_ID_TOKEN in the internal var, $this->getMethodUrlIdToken
-        * This feature allows sessions to use a GET-parameter instead of a cookie.
-        *
-        * @return void
-        * @access private
-        */
-       public function setUrlIdToken() {
-               if ($this->config['config']['ftu']) {
-                       $this->getMethodUrlIdToken = $this->TYPO3_CONF_VARS['FE']['get_url_id_token'];
-               } else {
-                       $this->getMethodUrlIdToken = '';
-               }
-       }
-
-       /**
-        * Calculates and sets the internal linkVars based upon the current
-        * $_GET parameters and the setting "config.linkVars".
-        *
-        * @return void
-        */
-       public function calculateLinkVars() {
-               $this->linkVars = '';
-               $linkVars = GeneralUtility::trimExplode(',', (string)$this->config['config']['linkVars']);
-               if (empty($linkVars)) {
-                       return;
-               }
-               $getData = GeneralUtility::_GET();
-               foreach ($linkVars as $linkVar) {
-                       $test = ($value = '');
-                       if (preg_match('/^(.*)\\((.+)\\)$/', $linkVar, $match)) {
-                               $linkVar = trim($match[1]);
-                               $test = trim($match[2]);
-                       }
-                       if ($linkVar === '' || !isset($getData[$linkVar])) {
-                               continue;
-                       }
-                       if (!is_array($getData[$linkVar])) {
-                               $temp = rawurlencode($getData[$linkVar]);
-                               if ($test !== '' && !PageGenerator::isAllowedLinkVarValue($temp, $test)) {
-                                       // Error: This value was not allowed for this key
-                                       continue;
-                               }
-                               $value = '&' . $linkVar . '=' . $temp;
-                       } else {
-                               if ($test !== '' && $test !== 'array') {
-                                       // Error: This key must not be an array!
-                                       continue;
-                               }
-                               $value = GeneralUtility::implodeArrayForUrl($linkVar, $getData[$linkVar]);
-                       }
-                       $this->linkVars .= $value;
-               }
-       }
-
-       /**
-        * Redirect to target page if the current page is an overlaid mountpoint.
-        *
-        * If the current page is of type mountpoint and should be overlaid with the contents of the mountpoint page
-        * and is accessed directly, the user will be redirected to the mountpoint context.
-        *
-        * @return void
-        */
-       public function checkPageForMountpointRedirect() {
-               if (!empty($this->originalMountPointPage) && $this->originalMountPointPage['doktype'] == PageRepository::DOKTYPE_MOUNTPOINT) {
-                       $this->redirectToCurrentPage();
-               }
-       }
-
-       /**
-        * Redirect to target page, if the current page is a Shortcut.
-        *
-        * If the current page is of type shortcut and accessed directly via its URL, this function redirects to the
-        * Shortcut target using a Location header.
-        *
-        * @return void If page is not a Shortcut, redirects and exits otherwise
-        */
-       public function checkPageForShortcutRedirect() {
-               if (!empty($this->originalShortcutPage) && $this->originalShortcutPage['doktype'] == PageRepository::DOKTYPE_SHORTCUT) {
-                       $this->redirectToCurrentPage();
-               }
-       }
-
-       /**
-        * Builds a typolink to the current page, appends the type paremeter if required
-        * and redirects the user to the generated URL using a Location header.
-        *
-        * @return void
-        */
-       protected function redirectToCurrentPage() {
-               $this->calculateLinkVars();
-               // Instantiate \TYPO3\CMS\Frontend\ContentObject to generate the correct target URL
-               /** @var $cObj ContentObjectRenderer */
-               $cObj = GeneralUtility::makeInstance(ContentObjectRenderer::class);
-               $parameter = $this->page['uid'];
-               $type = GeneralUtility::_GET('type');
-               if ($type && MathUtility::canBeInterpretedAsInteger($type)) {
-                       $parameter .= ',' . $type;
-               }
-               $redirectUrl = $cObj->typoLink_URL(array('parameter' => $parameter));
-
-               // Prevent redirection loop
-               if (!empty($redirectUrl)) {
-                       // redirect and exit
-                       HttpUtility::redirect($redirectUrl, HttpUtility::HTTP_STATUS_307);
-               }
-       }
-
-       /********************************************
-        *
-        * Page generation; cache handling
-        *
-        *******************************************/
-       /**
-        * Returns TRUE if the page should be generated
-        * That is if jumpurl is not set and the cacheContentFlag is not set.
-        *
-        * @return bool
-        */
-       public function isGeneratePage() {
-               return !$this->cacheContentFlag && !$this->jumpurl;
-       }
-
-       /**
-        * Temp cache content
-        * The temporary cache will expire after a few seconds (typ. 30) or will be cleared by the rendered page, which will also clear and rewrite the cache.
-        *
-        * @return void
-        */
-       public function tempPageCacheContent() {
-               $this->tempContent = FALSE;
-               if (!$this->no_cache) {
-                       $seconds = 30;
-                       $title = htmlspecialchars($this->tmpl->printTitle($this->page['title']));
-                       $request_uri = htmlspecialchars(GeneralUtility::getIndpEnv('REQUEST_URI'));
-                       $stdMsg = '
+class TypoScriptFrontendController implements LoggerAwareInterface
+{
+    use LoggerAwareTrait;
+
+    /**
+     * The page id (int)
+     * @var string
+     */
+    public $id = '';
+
+    /**
+     * The type (read-only)
+     * @var int
+     */
+    public $type = '';
+
+    /**
+     * The submitted cHash
+     * @var string
+     */
+    public $cHash = '';
+
+    /**
+     * Page will not be cached. Write only TRUE. Never clear value (some other
+     * code might have reasons to set it TRUE).
+     * @var bool
+     */
+    public $no_cache = false;
+
+    /**
+     * The rootLine (all the way to tree root, not only the current site!)
+     * @var array
+     */
+    public $rootLine = '';
+
+    /**
+     * The pagerecord
+     * @var array
+     */
+    public $page = '';
+
+    /**
+     * This will normally point to the same value as id, but can be changed to
+     * point to another page from which content will then be displayed instead.
+     * @var int
+     */
+    public $contentPid = 0;
+
+    /**
+     * Gets set when we are processing a page of type mounpoint with enabled overlay in getPageAndRootline()
+     * Used later in checkPageForMountpointRedirect() to determine the final target URL where the user
+     * should be redirected to.
+     *
+     * @var array|NULL
+     */
+    protected $originalMountPointPage = null;
+
+    /**
+     * Gets set when we are processing a page of type shortcut in the early stages
+     * of the request when we do not know about languages yet, used later in the request
+     * to determine the correct shortcut in case a translation changes the shortcut
+     * target
+     * @var array|NULL
+     * @see checkTranslatedShortcut()
+     */
+    protected $originalShortcutPage = null;
+
+    /**
+     * sys_page-object, pagefunctions
+     *
+     * @var PageRepository
+     */
+    public $sys_page = '';
+
+    /**
+     * Contains all URL handler instances that are active for the current request.
+     *
+     * The methods isGeneratePage(), isOutputting() and isINTincScript() depend on this property.
+     *
+     * @var \TYPO3\CMS\Frontend\Http\UrlHandlerInterface[]
+     * @see initializeRedirectUrlHandlers()
+     */
+    protected $activeUrlHandlers = [];
+
+    /**
+     * Is set to 1 if a pageNotFound handler could have been called.
+     * @var int
+     */
+    public $pageNotFound = 0;
+
+    /**
+     * Domain start page
+     * @var int
+     */
+    public $domainStartPage = 0;
+
+    /**
+     * Array containing a history of why a requested page was not accessible.
+     * @var array
+     */
+    public $pageAccessFailureHistory = [];
+
+    /**
+     * @var string
+     */
+    public $MP = '';
+
+    /**
+     * This can be set from applications as a way to tag cached versions of a page
+     * and later perform some external cache management, like clearing only a part
+     * of the cache of a page...
+     * @var int
+     */
+    public $page_cache_reg1 = 0;
+
+    /**
+     * Contains the value of the current script path that activated the frontend.
+     * Typically "index.php" but by rewrite rules it could be something else! Used
+     * for Speaking Urls / Simulate Static Documents.
+     * @var string
+     */
+    public $siteScript = '';
+
+    /**
+     * The frontend user
+     *
+     * @var FrontendUserAuthentication
+     */
+    public $fe_user = '';
+
+    /**
+     * Global flag indicating that a frontend user is logged in. This is set only if
+     * a user really IS logged in. The group-list may show other groups (like added
+     * by IP filter or so) even though there is no user.
+     * @var bool
+     */
+    public $loginUser = false;
+
+    /**
+     * (RO=readonly) The group list, sorted numerically. Group '0,-1' is the default
+     * group, but other groups may be added by other means than a user being logged
+     * in though...
+     * @var string
+     */
+    public $gr_list = '';
+
+    /**
+     * Flag that indicates if a backend user is logged in!
+     * @var bool
+     */
+    public $beUserLogin = false;
+
+    /**
+     * Integer, that indicates which workspace is being previewed.
+     * @var int
+     */
+    public $workspacePreview = 0;
+
+    /**
+     * Shows whether logins are allowed in branch
+     * @var bool
+     */
+    public $loginAllowedInBranch = true;
+
+    /**
+     * Shows specific mode (all or groups)
+     * @var string
+     */
+    public $loginAllowedInBranch_mode = '';
+
+    /**
+     * Set to backend user ID to initialize when keyword-based preview is used
+     * @var int
+     */
+    public $ADMCMD_preview_BEUSER_uid = 0;
+
+    /**
+     * Flag indication that preview is active. This is based on the login of a
+     * backend user and whether the backend user has read access to the current
+     * page. A value of 1 means ordinary preview, 2 means preview of a non-live
+     * workspace
+     * @var int
+     */
+    public $fePreview = 0;
+
+    /**
+     * Flag indicating that hidden pages should be shown, selected and so on. This
+     * goes for almost all selection of pages!
+     * @var bool
+     */
+    public $showHiddenPage = false;
+
+    /**
+     * Flag indicating that hidden records should be shown. This includes
+     * sys_template, pages_language_overlay and even fe_groups in addition to all
+     * other regular content. So in effect, this includes everything except pages.
+     * @var bool
+     */
+    public $showHiddenRecords = false;
+
+    /**
+     * Value that contains the simulated usergroup if any
+     * @var int
+     */
+    public $simUserGroup = 0;
+
+    /**
+     * "CONFIG" object from TypoScript. Array generated based on the TypoScript
+     * configuration of the current page. Saved with the cached pages.
+     * @var array
+     */
+    public $config = [];
+
+    /**
+     * The TypoScript template object. Used to parse the TypoScript template
+     *
+     * @var TemplateService
+     */
+    public $tmpl = null;
+
+    /**
+     * Is set to the time-to-live time of cached pages. If FALSE, default is
+     * 60*60*24, which is 24 hours.
+     * @var bool|int
+     */
+    public $cacheTimeOutDefault = false;
+
+    /**
+     * Set internally if cached content is fetched from the database
+     * @var bool
+     * @internal
+     */
+    public $cacheContentFlag = false;
+
+    /**
+     * Set to the expire time of cached content
+     * @var int
+     */
+    public $cacheExpires = 0;
+
+    /**
+     * Set if cache headers allowing caching are sent.
+     * @var bool
+     */
+    public $isClientCachable = false;
+
+    /**
+     * Used by template fetching system. This array is an identification of
+     * the template. If $this->all is empty it's because the template-data is not
+     * cached, which it must be.
+     * @var array
+     */
+    public $all = [];
+
+    /**
+     * Toplevel - objArrayName, eg 'page'
+     * @var string
+     */
+    public $sPre = '';
+
+    /**
+     * TypoScript configuration of the page-object pointed to by sPre.
+     * $this->tmpl->setup[$this->sPre.'.']
+     * @var array
+     */
+    public $pSetup = '';
+
+    /**
+     * This hash is unique to the template, the $this->id and $this->type vars and
+     * the gr_list (list of groups). Used to get and later store the cached data
+     * @var string
+     */
+    public $newHash = '';
+
+    /**
+     * If config.ftu (Frontend Track User) is set in TypoScript for the current
+     * page, the string value of this var is substituted in the rendered source-code
+     * with the string, '&ftu=[token...]' which enables GET-method usertracking as
+     * opposed to cookie based
+     * @var string
+     */
+    public $getMethodUrlIdToken = '';
+
+    /**
+     * This flag is set before inclusion of pagegen.php IF no_cache is set. If this
+     * flag is set after the inclusion of pagegen.php, no_cache is forced to be set.
+     * This is done in order to make sure that php-code from pagegen does not falsely
+     * clear the no_cache flag.
+     * @var bool
+     */
+    public $no_cacheBeforePageGen = false;
+
+    /**
+     * This flag indicates if temporary content went into the cache during
+     * page-generation.
+     * @var mixed
+     */
+    public $tempContent = false;
+
+    /**
+     * Passed to TypoScript template class and tells it to force template rendering
+     * @var bool
+     */
+    public $forceTemplateParsing = false;
+
+    /**
+     * The array which cHash_calc is based on, see ->makeCacheHash().
+     * @var array
+     */
+    public $cHash_array = [];
+
+    /**
+     * May be set to the pagesTSconfig
+     * @var array
+     */
+    public $pagesTSconfig = '';
+
+    /**
+     * Eg. insert JS-functions in this array ($additionalHeaderData) to include them
+     * once. Use associative keys.
+     *
+     * Keys in use:
+     *
+     * used to accumulate additional HTML-code for the header-section,
+     * <head>...</head>. Insert either associative keys (like
+     * additionalHeaderData['myStyleSheet'], see reserved keys above) or num-keys
+     * (like additionalHeaderData[] = '...')
+     *
+     * @var array
+     */
+    public $additionalHeaderData = [];
+
+    /**
+     * Used to accumulate additional HTML-code for the footer-section of the template
+     * @var array
+     */
+    public $additionalFooterData = [];
+
+    /**
+     * Used to accumulate additional JavaScript-code. Works like
+     * additionalHeaderData. Reserved keys at 'openPic' and 'mouseOver'
+     *
+     * @var array
+     */
+    public $additionalJavaScript = [];
+
+    /**
+     * Used to accumulate additional Style code. Works like additionalHeaderData.
+     *
+     * @var array
+     */
+    public $additionalCSS = [];
+
+    /**
+     * @var  string
+     */
+    public $JSCode;
+
+    /**
+     * @var string
+     */
+    public $inlineJS;
+
+    /**
+     * Used to accumulate DHTML-layers.
+     * @var string
+     */
+    public $divSection = '';
+
+    /**
+     * Debug flag. If TRUE special debug-output maybe be shown (which includes html-formatting).
+     * @var bool
+     */
+    public $debug = false;
+
+    /**
+     * Default internal target
+     * @var string
+     */
+    public $intTarget = '';
+
+    /**
+     * Default external target
+     * @var string
+     */
+    public $extTarget = '';
+
+    /**
+     * Default file link target
+     * @var string
+     */
+    public $fileTarget = '';
+
+    /**
+     * Keys are page ids and values are default &MP (mount point) values to set
+     * when using the linking features...)
+     * @var array
+     */
+    public $MP_defaults = [];
+
+    /**
+     * If set, typolink() function encrypts email addresses. Is set in pagegen-class.
+     * @var string|int
+     */
+    public $spamProtectEmailAddresses = 0;
+
+    /**
+     * Absolute Reference prefix
+     * @var string
+     */
+    public $absRefPrefix = '';
+
+    /**
+     * Lock file path
+     * @var string
+     */
+    public $lockFilePath = '';
+
+    /**
+     * <A>-tag parameters
+     * @var string
+     */
+    public $ATagParams = '';
+
+    /**
+     * Search word regex, calculated if there has been search-words send. This is
+     * used to mark up the found search words on a page when jumped to from a link
+     * in a search-result.
+     * @var string
+     */
+    public $sWordRegEx = '';
+
+    /**
+     * Is set to the incoming array sword_list in case of a page-view jumped to from
+     * a search-result.
+     * @var string
+     */
+    public $sWordList = '';
+
+    /**
+     * A string prepared for insertion in all links on the page as url-parameters.
+     * Based on configuration in TypoScript where you defined which GET_VARS you
+     * would like to pass on.
+     * @var string
+     */
+    public $linkVars = '';
+
+    /**
+     * If set, edit icons are rendered aside content records. Must be set only if
+     * the ->beUserLogin flag is set and set_no_cache() must be called as well.
+     * @var string
+     */
+    public $displayEditIcons = '';
+
+    /**
+     * If set, edit icons are rendered aside individual fields of content. Must be
+     * set only if the ->beUserLogin flag is set and set_no_cache() must be called as
+     * well.
+     * @var string
+     */
+    public $displayFieldEditIcons = '';
+
+    /**
+     * Site language, 0 (zero) is default, int+ is uid pointing to a sys_language
+     * record. Should reflect which language menus, templates etc is displayed in
+     * (master language) - but not necessarily the content which could be falling
+     * back to default (see sys_language_content)
+     * @var int
+     */
+    public $sys_language_uid = 0;
+
+    /**
+     * Site language mode for content fall back.
+     * @var string
+     */
+    public $sys_language_mode = '';
+
+    /**
+     * Site content selection uid (can be different from sys_language_uid if content
+     * is to be selected from a fall-back language. Depends on sys_language_mode)
+     * @var int
+     */
+    public $sys_language_content = 0;
+
+    /**
+     * Site content overlay flag; If set - and sys_language_content is > 0 - ,
+     * records selected will try to look for a translation pointing to their uid. (If
+     * configured in [ctrl][languageField] / [ctrl][transOrigP...]
+     * Possible values: [0,1,hideNonTranslated]
+     * This flag is set based on TypoScript config.sys_language_overlay setting
+     *
+     * @var int|string
+     */
+    public $sys_language_contentOL = 0;
+
+    /**
+     * Is set to the iso code of the sys_language_content if that is properly defined
+     * by the sys_language record representing the sys_language_uid.
+     * @var string
+     */
+    public $sys_language_isocode = '';
+
+    /**
+     * 'Global' Storage for various applications. Keys should be 'tx_'.extKey for
+     * extensions.
+     * @var array
+     */
+    public $applicationData = [];
+
+    /**
+     * @var array
+     */
+    public $register = [];
+
+    /**
+     * Stack used for storing array and retrieving register arrays (see
+     * LOAD_REGISTER and RESTORE_REGISTER)
+     * @var array
+     */
+    public $registerStack = [];
+
+    /**
+     * Checking that the function is not called eternally. This is done by
+     * interrupting at a depth of 50
+     * @var int
+     */
+    public $cObjectDepthCounter = 50;
+
+    /**
+     * Used by RecordContentObject and ContentContentObject to ensure the a records is NOT
+     * rendered twice through it!
+     * @var array
+     */
+    public $recordRegister = [];
+
+    /**
+     * This is set to the [table]:[uid] of the latest record rendered. Note that
+     * class ContentObjectRenderer has an equal value, but that is pointing to the
+     * record delivered in the $data-array of the ContentObjectRenderer instance, if
+     * the cObjects CONTENT or RECORD created that instance
+     * @var string
+     */
+    public $currentRecord = '';
+
+    /**
+     * Used by class \TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuContentObject
+     * to keep track of access-keys.
+     * @var array
+     */
+    public $accessKey = [];
+
+    /**
+     * Numerical array where image filenames are added if they are referenced in the
+     * rendered document. This includes only TYPO3 generated/inserted images.
+     * @var array
+     */
+    public $imagesOnPage = [];
+
+    /**
+     * Is set in ContentObjectRenderer->cImage() function to the info-array of the
+     * most recent rendered image. The information is used in ImageTextContentObject
+     * @var array
+     */
+    public $lastImageInfo = [];
+
+    /**
+     * Used to generate page-unique keys. Point is that uniqid() functions is very
+     * slow, so a unikey key is made based on this, see function uniqueHash()
+     * @var int
+     */
+    public $uniqueCounter = 0;
+
+    /**
+     * @var string
+     */
+    public $uniqueString = '';
+
+    /**
+     * This value will be used as the title for the page in the indexer (if
+     * indexing happens)
+     * @var string
+     */
+    public $indexedDocTitle = '';
+
+    /**
+     * Alternative page title (normally the title of the page record). Can be set
+     * from applications you make.
+     * @var string
+     */
+    public $altPageTitle = '';
+
+    /**
+     * The base URL set for the page header.
+     * @var string
+     */
+    public $baseUrl = '';
+
+    /**
+     * IDs we already rendered for this page (to make sure they are unique)
+     * @var array
+     */
+    private $usedUniqueIds = [];
+
+    /**
+     * Page content render object
+     *
+     * @var ContentObjectRenderer
+     */
+    public $cObj = '';
+
+    /**
+     * All page content is accumulated in this variable. See pagegen.php
+     * @var string
+     */
+    public $content = '';
+
+    /**
+     * Output charset of the websites content. This is the charset found in the
+     * header, meta tag etc. If different than utf-8 a conversion
+     * happens before output to browser. Defaults to utf-8.
+     * @var string
+     */
+    public $metaCharset = 'utf-8';
+
+    /**
+     * Set to the system language key (used on the site)
+     * @var string
+     */
+    public $lang = '';
+
+    /**
+     * Internal calculations for labels
+     *
+     * @var LanguageService
+     */
+    protected $languageService;
+
+    /**
+     * @var LockingStrategyInterface[][]
+     */
+    protected $locks = [];
+
+    /**
+     * @var PageRenderer
+     */
+    protected $pageRenderer = null;
+
+    /**
+     * The page cache object, use this to save pages to the cache and to
+     * retrieve them again
+     *
+     * @var \TYPO3\CMS\Core\Cache\Backend\AbstractBackend
+     */
+    protected $pageCache;
+
+    /**
+     * @var array
+     */
+    protected $pageCacheTags = [];
+
+    /**
+     * The cHash Service class used for cHash related functionality
+     *
+     * @var CacheHashCalculator
+     */
+    protected $cacheHash;
+
+    /**
+     * Runtime cache of domains per processed page ids.
+     *
+     * @var array
+     */
+    protected $domainDataCache = [];
+
+    /**
+     * Content type HTTP header being sent in the request.
+     * @todo Ticket: #63642 Should be refactored to a request/response model later
+     * @internal Should only be used by TYPO3 core for now
+     *
+     * @var string
+     */
+    protected $contentType = 'text/html';
+
+    /**
+     * Doctype to use
+     *
+     * @var string
+     */
+    public $xhtmlDoctype = '';
+
+    /**
+     * @var int
+     */
+    public $xhtmlVersion;
+
+    /**
+     * Originally requested id from the initial $_GET variable
+     *
+     * @var int
+     */
+    protected $requestedId;
+
+    /**
+     * Class constructor
+     * Takes a number of GET/POST input variable as arguments and stores them internally.
+     * The processing of these variables goes on later in this class.
+     * Also sets a unique string (->uniqueString) for this script instance; A md5 hash of the microtime()
+     *
+     * @param array $_ unused, previously defined to set TYPO3_CONF_VARS
+     * @param mixed $id The value of GeneralUtility::_GP('id')
+     * @param int $type The value of GeneralUtility::_GP('type')
+     * @param bool|string $no_cache The value of GeneralUtility::_GP('no_cache'), evaluated to 1/0
+     * @param string $cHash The value of GeneralUtility::_GP('cHash')
+     * @param string $_2 previously was used to define the jumpURL
+     * @param string $MP The value of GeneralUtility::_GP('MP')
+     * @see \TYPO3\CMS\Frontend\Http\RequestHandler
+     */
+    public function __construct($_ = null, $id, $type, $no_cache = '', $cHash = '', $_2 = null, $MP = '')
+    {
+        // Setting some variables:
+        $this->id = $id;
+        $this->type = $type;
+        if ($no_cache) {
+            if ($GLOBALS['TYPO3_CONF_VARS']['FE']['disableNoCacheParameter']) {
+                $warning = '&no_cache=1 has been ignored because $TYPO3_CONF_VARS[\'FE\'][\'disableNoCacheParameter\'] is set!';
+                $this->getTimeTracker()->setTSlogMessage($warning, 2);
+            } else {
+                $warning = '&no_cache=1 has been supplied, so caching is disabled! URL: "' . GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL') . '"';
+                $this->disableCache();
+            }
+            // note: we need to instantiate the logger manually here since the injection happens after the constructor
+            GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__)->warning($warning);
+        }
+        $this->cHash = $cHash;
+        $this->MP = $GLOBALS['TYPO3_CONF_VARS']['FE']['enable_mount_pids'] ? (string)$MP : '';
+        $this->uniqueString = md5(microtime());
+        $this->initPageRenderer();
+        // Call post processing function for constructor:
+        if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['tslib_fe-PostProc'])) {
+            $_params = ['pObj' => &$this];
+            foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['tslib_fe-PostProc'] as $_funcRef) {
+                GeneralUtility::callUserFunction($_funcRef, $_params, $this);
+            }
+        }
+        $this->cacheHash = GeneralUtility::makeInstance(CacheHashCalculator::class);
+        $this->initCaches();
+    }
+
+    /**
+     * Initializes the page renderer object
+     */
+    protected function initPageRenderer()
+    {
+        if ($this->pageRenderer !== null) {
+            return;
+        }
+        $this->pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
+        $this->pageRenderer->setTemplateFile('EXT:frontend/Resources/Private/Templates/MainPage.html');
+    }
+
+    /**
+     * @param string $contentType
+     * @internal Should only be used by TYPO3 core for now
+     */
+    public function setContentType($contentType)
+    {
+        $this->contentType = $contentType;
+    }
+
+    /**
+     * Connect to SQL database. May exit after outputting an error message
+     * or some JavaScript redirecting to the install tool.
+     *
+     * @throws \RuntimeException
+     * @throws ServiceUnavailableException
+     */
+    public function connectToDB()
+    {
+        $connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('pages');
+        try {
+            $connection->connect();
+        } catch (ConnectionException $exception) {
+            // Cannot connect to current database
+            $message = 'Cannot connect to the configured database "' . $connection->getDatabase() . '"';
+            if ($this->checkPageUnavailableHandler()) {
+                $this->pageUnavailableAndExit($message);
+            } else {
+                $this->logger->emergency($message, ['exception' => $exception]);
+                throw new ServiceUnavailableException($message, 1301648782);
+            }
+        }
+        // Call post processing function for DB connection:
+        if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['connectToDB'])) {
+            $_params = ['pObj' => &$this];
+            foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['connectToDB'] as $_funcRef) {
+                GeneralUtility::callUserFunction($_funcRef, $_params, $this);
+            }
+        }
+    }
+
+    /********************************************
+     *
+     * Initializing, resolving page id
+     *
+     ********************************************/
+    /**
+     * Initializes the caching system.
+     */
+    protected function initCaches()
+    {
+        $this->pageCache = GeneralUtility::makeInstance(CacheManager::class)->getCache('cache_pages');
+    }
+
+    /**
+     * Initializes the front-end login user.
+     */
+    public function initFEuser()
+    {
+        $this->fe_user = GeneralUtility::makeInstance(FrontendUserAuthentication::class);
+        // List of pid's acceptable
+        $pid = GeneralUtility::_GP('pid');
+        $this->fe_user->checkPid_value = $pid ? implode(',', GeneralUtility::intExplode(',', $pid)) : 0;
+        // Check if a session is transferred:
+        if (GeneralUtility::_GP('FE_SESSION_KEY')) {
+            $fe_sParts = explode('-', GeneralUtility::_GP('FE_SESSION_KEY'));
+            // If the session key hash check is OK:
+            if (md5(($fe_sParts[0] . '/' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'])) === (string)$fe_sParts[1]) {
+                $cookieName = FrontendUserAuthentication::getCookieName();
+                $_COOKIE[$cookieName] = $fe_sParts[0];
+                if (isset($_SERVER['HTTP_COOKIE'])) {
+                    // See http://forge.typo3.org/issues/27740
+                    $_SERVER['HTTP_COOKIE'] .= ';' . $cookieName . '=' . $fe_sParts[0];
+                }
+                $this->fe_user->forceSetCookie = 1;
+                $this->fe_user->dontSetCookie = false;
+                unset($cookieName);
+            }
+        }
+        $this->fe_user->start();
+        $this->fe_user->unpack_uc();
+
+        // Call hook for possible manipulation of frontend user object
+        if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['initFEuser'])) {
+            $_params = ['pObj' => &$this];
+            foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['initFEuser'] as $_funcRef) {
+                GeneralUtility::callUserFunction($_funcRef, $_params, $this);
+            }
+        }
+        // For every 60 seconds the is_online timestamp is updated.
+        if (is_array($this->fe_user->user) && $this->fe_user->user['uid'] && $this->fe_user->user['is_online'] < $GLOBALS['EXEC_TIME'] - 60) {
+            $dbConnection = GeneralUtility::makeInstance(ConnectionPool::class)
+                ->getConnectionForTable('fe_users');
+            $dbConnection->update(
+                'fe_users',
+                [
+                    'is_online' => $GLOBALS['EXEC_TIME']
+                ],
+                [
+                    'uid' => (int)$this->fe_user->user['uid']
+                ]
+            );
+        }
+    }
+
+    /**
+     * Initializes the front-end user groups.
+     * Sets ->loginUser and ->gr_list based on front-end user status.
+     */
+    public function initUserGroups()
+    {
+        // This affects the hidden-flag selecting the fe_groups for the user!
+        $this->fe_user->showHiddenRecords = $this->showHiddenRecords;
+        // no matter if we have an active user we try to fetch matching groups which can be set without an user (simulation for instance!)
+        $this->fe_user->fetchGroupData();
+        if (is_array($this->fe_user->user) && !empty($this->fe_user->groupData['uid'])) {
+            // global flag!
+            $this->loginUser = true;
+            // group -2 is not an existing group, but denotes a 'default' group when a user IS logged in. This is used to let elements be shown for all logged in users!
+            $this->gr_list = '0,-2';
+            $gr_array = $this->fe_user->groupData['uid'];
+        } else {
+            $this->loginUser = false;
+            // group -1 is not an existing group, but denotes a 'default' group when not logged in. This is used to let elements be hidden, when a user is logged in!
+            $this->gr_list = '0,-1';
+            if ($this->loginAllowedInBranch) {
+                // For cases where logins are not banned from a branch usergroups can be set based on IP masks so we should add the usergroups uids.
+                $gr_array = $this->fe_user->groupData['uid'];
+            } else {
+                // Set to blank since we will NOT risk any groups being set when no logins are allowed!
+                $gr_array = [];
+            }
+        }
+        // Clean up.
+        // Make unique...
+        $gr_array = array_unique($gr_array);
+        // sort
+        sort($gr_array);
+        if (!empty($gr_array) && !$this->loginAllowedInBranch_mode) {
+            $this->gr_list .= ',' . implode(',', $gr_array);
+        }
+        $this->logger->debug('Valid usergroups for TSFE: ' . $this->gr_list);
+    }
+
+    /**
+     * Checking if a user is logged in or a group constellation different from "0,-1"
+     *
+     * @return bool TRUE if either a login user is found (array fe_user->user) OR if the gr_list is set to something else than '0,-1' (could be done even without a user being logged in!)
+     */
+    public function isUserOrGroupSet()
+    {
+        return is_array($this->fe_user->user) || $this->gr_list !== '0,-1';
+    }
+
+    /**
+     * Provides ways to bypass the '?id=[xxx]&type=[xx]' format, using either PATH_INFO or virtual HTML-documents (using Apache mod_rewrite)
+     *
+     * Two options:
+     * 1) Use PATH_INFO (also Apache) to extract id and type from that var. Does not require any special modules compiled with apache. (less typical)
+     * 2) Using hook which enables features like those provided from "realurl" extension (AKA "Speaking URLs")
+     */
+    public function checkAlternativeIdMethods()
+    {
+        $this->siteScript = GeneralUtility::getIndpEnv('TYPO3_SITE_SCRIPT');
+        // Call post processing function for custom URL methods.
+        if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['checkAlternativeIdMethods-PostProc'])) {
+            $_params = ['pObj' => &$this];
+            foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['checkAlternativeIdMethods-PostProc'] as $_funcRef) {
+                GeneralUtility::callUserFunction($_funcRef, $_params, $this);
+            }
+        }
+    }
+
+    /**
+     * Clears the preview-flags, sets sim_exec_time to current time.
+     * Hidden pages must be hidden as default, $GLOBALS['SIM_EXEC_TIME'] is set to $GLOBALS['EXEC_TIME']
+     * in bootstrap initializeGlobalTimeVariables(). Alter it by adding or subtracting seconds.
+     */
+    public function clear_preview()
+    {
+        $this->showHiddenPage = false;
+        $this->showHiddenRecords = false;
+        $GLOBALS['SIM_EXEC_TIME'] = $GLOBALS['EXEC_TIME'];
+        $GLOBALS['SIM_ACCESS_TIME'] = $GLOBALS['ACCESS_TIME'];
+        $this->fePreview = 0;
+    }
+
+    /**
+     * Checks if a backend user is logged in
+     *
+     * @return bool whether a backend user is logged in
+     */
+    public function isBackendUserLoggedIn()
+    {
+        return (bool)$this->beUserLogin;
+    }
+
+    /**
+     * Creates the backend user object and returns it.
+     *
+     * @return FrontendBackendUserAuthentication the backend user object
+     */
+    public function initializeBackendUser()
+    {
+        // PRE BE_USER HOOK
+        if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/index_ts.php']['preBeUser'])) {
+            foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/index_ts.php']['preBeUser'] as $_funcRef) {
+                $_params = [];
+                GeneralUtility::callUserFunction($_funcRef, $_params, $this);
+            }
+        }
+        $backendUserObject = null;
+        // If the backend cookie is set,
+        // we proceed and check if a backend user is logged in.
+        if ($_COOKIE[BackendUserAuthentication::getCookieName()]) {
+            $GLOBALS['TYPO3_MISC']['microtime_BE_USER_start'] = microtime(true);
+            $this->getTimeTracker()->push('Back End user initialized', '');
+            $this->beUserLogin = false;
+            // New backend user object
+            $backendUserObject = GeneralUtility::makeInstance(FrontendBackendUserAuthentication::class);
+            $backendUserObject->start();
+            $backendUserObject->unpack_uc();
+            if (!empty($backendUserObject->user['uid'])) {
+                $backendUserObject->fetchGroupData();
+            }
+            // Unset the user initialization if any setting / restriction applies
+            if (!$backendUserObject->checkBackendAccessSettingsFromInitPhp()) {
+                $backendUserObject = null;
+            } elseif (!empty($backendUserObject->user['uid'])) {
+                // If the user is active now, let the controller know
+                $this->beUserLogin = true;
+            } else {
+                $backendUserObject = null;
+            }
+            $this->getTimeTracker()->pull();
+            $GLOBALS['TYPO3_MISC']['microtime_BE_USER_end'] = microtime(true);
+        }
+        // POST BE_USER HOOK
+        if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/index_ts.php']['postBeUser'])) {
+            $_params = [
+                'BE_USER' => &$backendUserObject
+            ];
+            foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/index_ts.php']['postBeUser'] as $_funcRef) {
+                GeneralUtility::callUserFunction($_funcRef, $_params, $this);
+            }
+        }
+        return $backendUserObject;
+    }
+
+    /**
+     * Determines the id and evaluates any preview settings
+     * Basically this function is about determining whether a backend user is logged in,
+     * if he has read access to the page and if he's previewing the page.
+     * That all determines which id to show and how to initialize the id.
+     */
+    public function determineId()
+    {
+        // Call pre processing function for id determination
+        if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['determineId-PreProcessing'])) {
+            foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['determineId-PreProcessing'] as $functionReference) {
+                $parameters = ['parentObject' => $this];
+                GeneralUtility::callUserFunction($functionReference, $parameters, $this);
+            }
+        }
+        // If there is a Backend login we are going to check for any preview settings:
+        $this->getTimeTracker()->push('beUserLogin', '');
+        $originalFrontendUser = null;
+        $backendUser = $this->getBackendUser();
+        if ($this->beUserLogin || $this->doWorkspacePreview()) {
+            // Backend user preview features:
+            if ($this->beUserLogin && $backendUser->adminPanel instanceof AdminPanelView) {
+                $this->fePreview = (int)$backendUser->adminPanel->extGetFeAdminValue('preview');
+                // If admin panel preview is enabled...
+                if ($this->fePreview) {
+                    if ($this->fe_user->user) {
+                        $originalFrontendUser = $this->fe_user->user;
+                    }
+                    $this->showHiddenPage = (bool)$backendUser->adminPanel->extGetFeAdminValue('preview', 'showHiddenPages');
+                    $this->showHiddenRecords = (bool)$backendUser->adminPanel->extGetFeAdminValue('preview', 'showHiddenRecords');
+                    // Simulate date
+                    $simTime = $backendUser->adminPanel->extGetFeAdminValue('preview', 'simulateDate');
+                    if ($simTime) {
+                        $GLOBALS['SIM_EXEC_TIME'] = $simTime;
+                        $GLOBALS['SIM_ACCESS_TIME'] = $simTime - $simTime % 60;
+                    }
+                    // simulate user
+                    $simUserGroup = $backendUser->adminPanel->extGetFeAdminValue('preview', 'simulateUserGroup');
+                    $this->simUserGroup = $simUserGroup;
+                    if ($simUserGroup) {
+                        if ($this->fe_user->user) {
+                            $this->fe_user->user[$this->fe_user->usergroup_column] = $simUserGroup;
+                        } else {
+                            $this->fe_user->user = [
+                                $this->fe_user->usergroup_column => $simUserGroup
+                            ];
+                        }
+                    }
+                    if (!$simUserGroup && !$simTime && !$this->showHiddenPage && !$this->showHiddenRecords) {
+                        $this->fePreview = 0;
+                    }
+                }
+            }
+            if ($this->id && $this->determineIdIsHiddenPage()) {
+                // The preview flag is set only if the current page turns out to actually be hidden!
+                $this->fePreview = 1;
+                $this->showHiddenPage = true;
+            }
+            // The preview flag will be set if a backend user is in an offline workspace
+            if (
+                    (
+                        $backendUser->user['workspace_preview']
+                        || GeneralUtility::_GP('ADMCMD_view')
+                        || $this->doWorkspacePreview()
+                    )
+                    && (
+                        $this->whichWorkspace() === -1
+                        || $this->whichWorkspace() > 0
+                    )
+                    && !GeneralUtility::_GP('ADMCMD_noBeUser')
+            ) {
+                // Will show special preview message.
+                $this->fePreview = 2;
+            }
+            // If the front-end is showing a preview, caching MUST be disabled.
+            if ($this->fePreview) {
+                $this->disableCache();
+            }
+        }
+        $this->getTimeTracker()->pull();
+        // Now, get the id, validate access etc:
+        $this->fetch_the_id();
+        // Check if backend user has read access to this page. If not, recalculate the id.
+        if ($this->beUserLogin && $this->fePreview) {
+            if (!$backendUser->doesUserHaveAccess($this->page, 1)) {
+                // Resetting
+                $this->clear_preview();
+                $this->fe_user->user = $originalFrontendUser;
+                // Fetching the id again, now with the preview settings reset.
+                $this->fetch_the_id();
+            }
+        }
+        // Checks if user logins are blocked for a certain branch and if so, will unset user login and re-fetch ID.
+        $this->loginAllowedInBranch = $this->checkIfLoginAllowedInBranch();
+        // Logins are not allowed:
+        if (!$this->loginAllowedInBranch) {
+            // Only if there is a login will we run this...
+            if ($this->isUserOrGroupSet()) {
+                if ($this->loginAllowedInBranch_mode === 'all') {
+                    // Clear out user and group:
+                    $this->fe_user->hideActiveLogin();
+                    $this->gr_list = '0,-1';
+                } else {
+                    $this->gr_list = '0,-2';
+                }
+                // Fetching the id again, now with the preview settings reset.
+                $this->fetch_the_id();
+            }
+        }
+        // Final cleaning.
+        // Make sure it's an integer
+        $this->id = ($this->contentPid = (int)$this->id);
+        // Make sure it's an integer
+        $this->type = (int)$this->type;
+        // Call post processing function for id determination:
+        if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['determineId-PostProc'])) {
+            $_params = ['pObj' => &$this];
+            foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['determineId-PostProc'] as $_funcRef) {
+                GeneralUtility::callUserFunction($_funcRef, $_params, $this);
+            }
+        }
+    }
+
+    /**
+     * Checks if the page is hidden in the active workspace.
+     * If it is hidden, preview flags will be set.
+     *
+     * @return bool
+     */
+    protected function determineIdIsHiddenPage()
+    {
+        $field = MathUtility::canBeInterpretedAsInteger($this->id) ? 'uid' : 'alias';
+
+        $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
+            ->getQueryBuilderForTable('pages');
+        $queryBuilder
+            ->getRestrictions()
+            ->removeAll()
+            ->add(GeneralUtility::makeInstance(DeletedRestriction::class));
+
+        $page = $queryBuilder
+            ->select('uid', 'hidden', 'starttime', 'endtime')
+            ->from('pages')
+            ->where(
+                $queryBuilder->expr()->eq($field, $queryBuilder->createNamedParameter($this->id)),
+                $queryBuilder->expr()->gte('pid', $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT))
+            )
+            ->setMaxResults(1)
+            ->execute()
+            ->fetch();
+
+        $workspace = $this->whichWorkspace();
+        if ($workspace !== 0 && $workspace !== false) {
+            // Fetch overlay of page if in workspace and check if it is hidden
+            $pageSelectObject = GeneralUtility::makeInstance(PageRepository::class);
+            $pageSelectObject->versioningPreview = true;
+            $pageSelectObject->init(false);
+            $targetPage = $pageSelectObject->getWorkspaceVersionOfRecord($this->whichWorkspace(), 'pages', $page['uid']);
+            $result = $targetPage === -1 || $targetPage === -2;
+        } else {
+            $result = is_array($page) && ($page['hidden'] || $page['starttime'] > $GLOBALS['SIM_EXEC_TIME'] || $page['endtime'] != 0 && $page['endtime'] <= $GLOBALS['SIM_EXEC_TIME']);
+        }
+        return $result;
+    }
+
+    /**
+     * Resolves the page id and sets up several related properties.
+     *
+     * If $this->id is not set at all or is not a plain integer, the method
+     * does it's best to set the value to an integer. Resolving is based on
+     * this options:
+     *
+     * - Splitting $this->id if it contains an additional type parameter.
+     * - Getting the id for an alias in $this->id
+     * - Finding the domain record start page
+     * - First visible page
+     * - Relocating the id below the domain record if outside
+     *
+     * The following properties may be set up or updated:
+     *
+     * - id
+     * - requestedId
+     * - type
+     * - domainStartPage
+     * - sys_page
+     * - sys_page->where_groupAccess
+     * - sys_page->where_hid_del
+     * - loginUser
+     * - gr_list
+     * - no_cache
+     * - register['SYS_LASTCHANGED']
+     * - pageNotFound
+     *
+     * Via getPageAndRootlineWithDomain()
+     *
+     * - rootLine
+     * - page
+     * - MP
+     * - originalShortcutPage
+     * - originalMountPointPage
+     * - pageAccessFailureHistory['direct_access']
+     * - pageNotFound
+     *
+     * @todo:
+     *
+     * On the first impression the method does to much. This is increased by
+     * the fact, that is is called repeated times by the method determineId.
+     * The reasons are manifold.
+     *
+     * 1.) The first part, the creation of sys_page, the type and alias
+     * resolution don't need to be repeated. They could be separated to be
+     * called only once.
+     *
+     * 2.) The user group setup could be done once on a higher level.
+     *
+     * 3.) The workflow of the resolution could be elaborated to be less
+     * tangled. Maybe the check of the page id to be below the domain via the
+     * root line doesn't need to be done each time, but for the final result
+     * only.
+     *
+     * 4.) The root line does not need to be directly addressed by this class.
+     * A root line is always related to one page. The rootline could be handled
+     * indirectly by page objects. Page objects still don't exist.
+     *
+     * @throws ServiceUnavailableException
+     * @access private
+     */
+    public function fetch_the_id()
+    {
+        $timeTracker = $this->getTimeTracker();
+        $timeTracker->push('fetch_the_id initialize/', '');
+        // Initialize the page-select functions.
+        $this->sys_page = GeneralUtility::makeInstance(PageRepository::class);
+        $this->sys_page->versioningPreview = $this->fePreview === 2 || (int)$this->workspacePreview || (bool)GeneralUtility::_GP('ADMCMD_view');
+        $this->sys_page->versioningWorkspaceId = $this->whichWorkspace();
+        $this->sys_page->init($this->showHiddenPage);
+        // Set the valid usergroups for FE
+        $this->initUserGroups();
+        // Sets sys_page where-clause
+        $this->setSysPageWhereClause();
+        // Splitting $this->id by a period (.).
+        // First part is 'id' and second part (if exists) will overrule the &type param
+        $idParts = explode('.', $this->id, 2);
+        $this->id = $idParts[0];
+        if (isset($idParts[1])) {
+            $this->type = $idParts[1];
+        }
+
+        // If $this->id is a string, it's an alias
+        $this->checkAndSetAlias();
+        // The id and type is set to the integer-value - just to be sure...
+        $this->id = (int)$this->id;
+        $this->type = (int)$this->type;
+        $timeTracker->pull();
+        // We find the first page belonging to the current domain
+        $timeTracker->push('fetch_the_id domain/', '');
+        // The page_id of the current domain
+        $this->domainStartPage = $this->findDomainRecord($GLOBALS['TYPO3_CONF_VARS']['SYS']['recursiveDomainSearch']);
+        if (!$this->id) {
+            if ($this->domainStartPage) {
+                // If the id was not previously set, set it to the id of the domain.
+                $this->id = $this->domainStartPage;
+            } else {
+                // Find the first 'visible' page in that domain
+                $theFirstPage = $this->sys_page->getFirstWebPage($this->id);
+                if ($theFirstPage) {
+                    $this->id = $theFirstPage['uid'];
+                } else {
+                    $message = 'No pages are found on the rootlevel!';
+                    if ($this->checkPageUnavailableHandler()) {
+                        $this->pageUnavailableAndExit($message);
+                    } else {
+                        $this->logger->alert($message);
+                        throw new ServiceUnavailableException($message, 1301648975);
+                    }
+                }
+            }
+        }
+        $timeTracker->pull();
+        $timeTracker->push('fetch_the_id rootLine/', '');
+        // We store the originally requested id
+        $this->requestedId = $this->id;
+        $this->getPageAndRootlineWithDomain($this->domainStartPage);
+        $timeTracker->pull();
+        if ($this->pageNotFound && $GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling']) {
+            $pNotFoundMsg = [
+                1 => 'ID was not an accessible page',
+                2 => 'Subsection was found and not accessible',
+                3 => 'ID was outside the domain',
+                4 => 'The requested page alias does not exist'
+            ];
+            $this->pageNotFoundAndExit($pNotFoundMsg[$this->pageNotFound]);
+        }
+        // Set no_cache if set
+        if ($this->page['no_cache']) {
+            $this->set_no_cache('no_cache is set in page properties');
+        }
+        // Init SYS_LASTCHANGED
+        $this->register['SYS_LASTCHANGED'] = (int)$this->page['tstamp'];
+        if ($this->register['SYS_LASTCHANGED'] < (int)$this->page['SYS_LASTCHANGED']) {
+            $this->register['SYS_LASTCHANGED'] = (int)$this->page['SYS_LASTCHANGED'];
+        }
+        if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['fetchPageId-PostProcessing'])) {
+            foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['fetchPageId-PostProcessing'] as $functionReference) {
+                $parameters = ['parentObject' => $this];
+                GeneralUtility::callUserFunction($functionReference, $parameters, $this);
+            }
+        }
+    }
+
+    /**
+     * Loads the page and root line records based on $this->id
+     *
+     * A final page and the matching root line are determined and loaded by
+     * the algorithm defined by this method.
+     *
+     * First it loads the initial page from the page repository for $this->id.
+     * If that can't be loaded directly, it gets the root line for $this->id.
+     * It walks up the root line towards the root page until the page
+     * repository can deliver a page record. (The loading restrictions of
+     * the root line records are more liberal than that of the page record.)
+     *
+     * Now the page type is evaluated and handled if necessary. If the page is
+     * a short cut, it is replaced by the target page. If the page is a mount
+     * point in overlay mode, the page is replaced by the mounted page.
+     *
+     * After this potential replacements are done, the root line is loaded
+     * (again) for this page record. It walks up the root line up to
+     * the first viewable record.
+     *
+     * (While upon the first accessibility check of the root line it was done
+     * by loading page by page from the page repository, this time the method
+     * checkRootlineForIncludeSection() is used to find the most distant
+     * accessible page within the root line.)
+     *
+     * Having found the final page id, the page record and the root line are
+     * loaded for last time by this method.
+     *
+     * Exceptions may be thrown for DOKTYPE_SPACER and not loadable page records
+     * or root lines.
+     *
+     * If $GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'] is set,
+     * instead of throwing an exception it's handled by a page unavailable
+     * handler.
+     *
+     * May set or update this properties:
+     *
+     * @see TypoScriptFrontendController::$id
+     * @see TypoScriptFrontendController::$MP
+     * @see TypoScriptFrontendController::$page
+     * @see TypoScriptFrontendController::$pageNotFound
+     * @see TypoScriptFrontendController::$pageAccessFailureHistory
+     * @see TypoScriptFrontendController::$originalMountPointPage
+     * @see TypoScriptFrontendController::$originalShortcutPage
+     *
+     * @throws ServiceUnavailableException
+     * @throws PageNotFoundException
+     * @access private
+     */
+    public function getPageAndRootline()
+    {
+        $this->page = $this->sys_page->getPage($this->id);
+        if (empty($this->page)) {
+            // If no page, we try to find the page before in the rootLine.
+            // Page is 'not found' in case the id itself was not an accessible page. code 1
+            $this->pageNotFound = 1;
+            $this->rootLine = $this->sys_page->getRootLine($this->id, $this->MP);
+            if (!empty($this->rootLine)) {
+                $c = count($this->rootLine) - 1;
+                while ($c > 0) {
+                    // Add to page access failure history:
+                    $this->pageAccessFailureHistory['direct_access'][] = $this->rootLine[$c];
+                    // Decrease to next page in rootline and check the access to that, if OK, set as page record and ID value.
+                    $c--;
+                    $this->id = $this->rootLine[$c]['uid'];
+                    $this->page = $this->sys_page->getPage($this->id);
+                    if (!empty($this->page)) {
+                        break;
+                    }
+                }
+            }
+            // If still no page...
+            if (empty($this->page)) {
+                $message = 'The requested page does not exist!';
+                if ($GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling']) {
+                    $this->pageNotFoundAndExit($message);
+                } else {
+                    $this->logger->error($message);
+                    throw new PageNotFoundException($message, 1301648780);
+                }
+            }
+        }
+        // Spacer is not accessible in frontend
+        if ($this->page['doktype'] == PageRepository::DOKTYPE_SPACER) {
+            $message = 'The requested page does not exist!';
+            if ($GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling']) {
+                $this->pageNotFoundAndExit($message);
+            } else {
+                $this->logger->error($message);
+                throw new PageNotFoundException($message, 1301648781);
+            }
+        }
+        // Is the ID a link to another page??
+        if ($this->page['doktype'] == PageRepository::DOKTYPE_SHORTCUT) {
+            // We need to clear MP if the page is a shortcut. Reason is if the short cut goes to another page, then we LEAVE the rootline which the MP expects.
+            $this->MP = '';
+            // saving the page so that we can check later - when we know
+            // about languages - whether we took the correct shortcut or
+            // whether a translation of the page overwrites the shortcut
+            // target and we need to follow the new target
+            $this->originalShortcutPage = $this->page;
+            $this->page = $this->getPageShortcut($this->page['shortcut'], $this->page['shortcut_mode'], $this->page['uid']);
+            $this->id = $this->page['uid'];
+        }
+        // If the page is a mountpoint which should be overlaid with the contents of the mounted page,
+        // it must never be accessible directly, but only in the mountpoint context. Therefore we change
+        // the current ID and the user is redirected by checkPageForMountpointRedirect().
+        if ($this->page['doktype'] == PageRepository::DOKTYPE_MOUNTPOINT && $this->page['mount_pid_ol']) {
+            $this->originalMountPointPage = $this->page;
+            $this->page = $this->sys_page->getPage($this->page['mount_pid']);
+            if (empty($this->page)) {
+                $message = 'This page (ID ' . $this->originalMountPointPage['uid'] . ') is of type "Mount point" and '
+                    . 'mounts a page which is not accessible (ID ' . $this->originalMountPointPage['mount_pid'] . ').';
+                throw new PageNotFoundException($message, 1402043263);
+            }
+            $this->MP = $this->page['uid'] . '-' . $this->originalMountPointPage['uid'];
+            $this->id = $this->page['uid'];
+        }
+        // Gets the rootLine
+        $this->rootLine = $this->sys_page->getRootLine($this->id, $this->MP);
+        // If not rootline we're off...
+        if (empty($this->rootLine)) {
+            $message = 'The requested page didn\'t have a proper connection to the tree-root!';
+            if ($this->checkPageUnavailableHandler()) {
+                $this->pageUnavailableAndExit($message);
+            } else {
+                $this->logger->error($message);
+                throw new ServiceUnavailableException($message, 1301648167);
+            }
+        }
+        // Checking for include section regarding the hidden/starttime/endtime/fe_user (that is access control of a whole subbranch!)
+        if ($this->checkRootlineForIncludeSection()) {
+            if (empty($this->rootLine)) {
+                $message = 'The requested page was not accessible!';
+                if ($this->checkPageUnavailableHandler()) {
+                    $this->pageUnavailableAndExit($message);
+                } else {
+                    $this->logger->warning($message);
+                    throw new ServiceUnavailableException($message, 1301648234);
+                }
+            } else {
+                $el = reset($this->rootLine);
+                $this->id = $el['uid'];
+                $this->page = $this->sys_page->getPage($this->id);
+                $this->rootLine = $this->sys_page->getRootLine($this->id, $this->MP);
+            }
+        }
+    }
+
+    /**
+     * Get page shortcut; Finds the records pointed to by input value $SC (the shortcut value)
+     *
+     * @param int $SC The value of the "shortcut" field from the pages record
+     * @param int $mode The shortcut mode: 1 will select first subpage, 2 a random subpage, 3 the parent page; default is the page pointed to by $SC
+     * @param int $thisUid The current page UID of the page which is a shortcut
+     * @param int $itera Safety feature which makes sure that the function is calling itself recursively max 20 times (since this function can find shortcuts to other shortcuts to other shortcuts...)
+     * @param array $pageLog An array filled with previous page uids tested by the function - new page uids are evaluated against this to avoid going in circles.
+     * @param bool $disableGroupCheck If true, the group check is disabled when fetching the target page (needed e.g. for menu generation)
+     * @throws \RuntimeException
+     * @throws PageNotFoundException
+     * @return mixed Returns the page record of the page that the shortcut pointed to.
+     * @access private
+     * @see getPageAndRootline()
+     */
+    public function getPageShortcut($SC, $mode, $thisUid, $itera = 20, $pageLog = [], $disableGroupCheck = false)
+    {
+        $idArray = GeneralUtility::intExplode(',', $SC);
+        // Find $page record depending on shortcut mode:
+        switch ($mode) {
+            case PageRepository::SHORTCUT_MODE_FIRST_SUBPAGE:
+
+            case PageRepository::SHORTCUT_MODE_RANDOM_SUBPAGE:
+                $pageArray = $this->sys_page->getMenu($idArray[0] ? $idArray[0] : $thisUid, '*', 'sorting', 'AND pages.doktype<199 AND pages.doktype!=' . PageRepository::DOKTYPE_BE_USER_SECTION);
+                $pO = 0;
+                if ($mode == PageRepository::SHORTCUT_MODE_RANDOM_SUBPAGE && !empty($pageArray)) {
+                    $randval = (int)rand(0, count($pageArray) - 1);
+                    $pO = $randval;
+                }
+                $c = 0;
+                $page = [];
+                foreach ($pageArray as $pV) {
+                    if ($c === $pO) {
+                        $page = $pV;
+                        break;
+                    }
+                    $c++;
+                }
+                if (empty($page)) {
+                    $message = 'This page (ID ' . $thisUid . ') is of type "Shortcut" and configured to redirect to a subpage. ' . 'However, this page has no accessible subpages.';
+                    throw new PageNotFoundException($message, 1301648328);
+                }
+                break;
+            case PageRepository::SHORTCUT_MODE_PARENT_PAGE:
+                $parent = $this->sys_page->getPage($idArray[0] ? $idArray[0] : $thisUid, $disableGroupCheck);
+                $page = $this->sys_page->getPage($parent['pid'], $disableGroupCheck);
+                if (empty($page)) {
+                    $message = 'This page (ID ' . $thisUid . ') is of type "Shortcut" and configured to redirect to its parent page. ' . 'However, the parent page is not accessible.';
+                    throw new PageNotFoundException($message, 1301648358);
+                }
+                break;
+            default:
+                $page = $this->sys_page->getPage($idArray[0], $disableGroupCheck);
+                if (empty($page)) {
+                    $message = 'This page (ID ' . $thisUid . ') is of type "Shortcut" and configured to redirect to a page, which is not accessible (ID ' . $idArray[0] . ').';
+                    throw new PageNotFoundException($message, 1301648404);
+                }
+        }
+        // Check if short cut page was a shortcut itself, if so look up recursively:
+        if ($page['doktype'] == PageRepository::DOKTYPE_SHORTCUT) {
+            if (!in_array($page['uid'], $pageLog) && $itera > 0) {
+                $pageLog[] = $page['uid'];
+                $page = $this->getPageShortcut($page['shortcut'], $page['shortcut_mode'], $page['uid'], $itera - 1, $pageLog, $disableGroupCheck);
+            } else {
+                $pageLog[] = $page['uid'];
+                $message = 'Page shortcuts were looping in uids ' . implode(',', $pageLog) . '...!';
+                $this->logger->error($message);
+                throw new \RuntimeException($message, 1294587212);
+            }
+        }
+        // Return resulting page:
+        return $page;
+    }
+
+    /**
+     * Checks the current rootline for defined sections.
+     *
+     * @return bool
+     * @access private
+     */
+    public function checkRootlineForIncludeSection()
+    {
+        $c = count($this->rootLine);
+        $removeTheRestFlag = 0;
+        for ($a = 0; $a < $c; $a++) {
+            if (!$this->checkPagerecordForIncludeSection($this->rootLine[$a])) {
+                // Add to page access failure history:
+                $this->pageAccessFailureHistory['sub_section'][] = $this->rootLine[$a];
+                $removeTheRestFlag = 1;
+            }
+
+            if ($this->rootLine[$a]['doktype'] == PageRepository::DOKTYPE_BE_USER_SECTION) {
+                // If there is a backend user logged in, check if he has read access to the page:
+                if ($this->beUserLogin) {
+                    $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
+                        ->getQueryBuilderForTable('pages');
+
+                    $queryBuilder
+                        ->getRestrictions()
+                        ->removeAll();
+
+                    $row = $queryBuilder
+                        ->select('uid')
+                        ->from('pages')
+                        ->where(
+                            $queryBuilder->expr()->eq(
+                                'uid',
+                                $queryBuilder->createNamedParameter($this->id, \PDO::PARAM_INT)
+                            ),
+                            $this->getBackendUser()->getPagePermsClause(1)
+                        )
+                        ->execute()
+                        ->fetch();
+
+                    // versionOL()?
+                    if (!$row) {
+                        // If there was no page selected, the user apparently did not have read access to the current PAGE (not position in rootline) and we set the remove-flag...
+                        $removeTheRestFlag = 1;
+                    }
+                } else {
+                    // Don't go here, if there is no backend user logged in.
+                    $removeTheRestFlag = 1;
+                }
+            }
+            if ($removeTheRestFlag) {
+                // Page is 'not found' in case a subsection was found and not accessible, code 2
+                $this->pageNotFound = 2;
+                unset($this->rootLine[$a]);
+            }
+        }
+        return $removeTheRestFlag;
+    }
+
+    /**
+     * Checks page record for enableFields
+     * Returns TRUE if enableFields does not disable the page record.
+     * Takes notice of the ->showHiddenPage flag and uses SIM_ACCESS_TIME for start/endtime evaluation
+     *
+     * @param array $row The page record to evaluate (needs fields: hidden, starttime, endtime, fe_group)
+     * @param bool $bypassGroupCheck Bypass group-check
+     * @return bool TRUE, if record is viewable.
+     * @see \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::getTreeList(), checkPagerecordForIncludeSection()
+     */
+    public function checkEnableFields($row, $bypassGroupCheck = false)
+    {
+        if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['hook_checkEnableFields']) && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['hook_checkEnableFields'])) {
+            $_params = ['pObj' => $this, 'row' => &$row, 'bypassGroupCheck' => &$bypassGroupCheck];
+            foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['hook_checkEnableFields'] as $_funcRef) {
+                // Call hooks: If one returns FALSE, method execution is aborted with result "This record is not available"
+                $return = GeneralUtility::callUserFunction($_funcRef, $_params, $this);
+                if ($return === false) {
+                    return false;
+                }
+            }
+        }
+        if ((!$row['hidden'] || $this->showHiddenPage) && $row['starttime'] <= $GLOBALS['SIM_ACCESS_TIME'] && ($row['endtime'] == 0 || $row['endtime'] > $GLOBALS['SIM_ACCESS_TIME']) && ($bypassGroupCheck || $this->checkPageGroupAccess($row))) {
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * Check group access against a page record
+     *
+     * @param array $row The page record to evaluate (needs field: fe_group)
+     * @param mixed $groupList List of group id's (comma list or array). Default is $this->gr_list
+     * @return bool TRUE, if group access is granted.
+     * @access private
+     */
+    public function checkPageGroupAccess($row, $groupList = null)
+    {
+        if (is_null($groupList)) {
+            $groupList = $this->gr_list;
+        }
+        if (!is_array($groupList)) {
+            $groupList = explode(',', $groupList);
+        }
+        $pageGroupList = explode(',', $row['fe_group'] ?: 0);
+        return count(array_intersect($groupList, $pageGroupList)) > 0;
+    }
+
+    /**
+     * Checks page record for include section
+     *
+     * @param array $row The page record to evaluate (needs fields: extendToSubpages + hidden, starttime, endtime, fe_group)
+     * @return bool Returns TRUE if either extendToSubpages is not checked or if the enableFields does not disable the page record.
+     * @access private
+     * @see checkEnableFields(), \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::getTreeList(), checkRootlineForIncludeSection()
+     */
+    public function checkPagerecordForIncludeSection($row)
+    {
+        return !$row['extendToSubpages'] || $this->checkEnableFields($row) ? 1 : 0;
+    }
+
+    /**
+     * Checks if logins are allowed in the current branch of the page tree. Traverses the full root line and returns TRUE if logins are OK, otherwise FALSE (and then the login user must be unset!)
+     *
+     * @return bool returns TRUE if logins are OK, otherwise FALSE (and then the login user must be unset!)
+     */
+    public function checkIfLoginAllowedInBranch()
+    {
+        // Initialize:
+        $c = count($this->rootLine);
+        $loginAllowed = true;
+        // Traverse root line from root and outwards:
+        for ($a = 0; $a < $c; $a++) {
+            // If a value is set for login state:
+            if ($this->rootLine[$a]['fe_login_mode'] > 0) {
+                // Determine state from value:
+                if ((int)$this->rootLine[$a]['fe_login_mode'] === 1) {
+                    $loginAllowed = false;
+                    $this->loginAllowedInBranch_mode = 'all';
+                } elseif ((int)$this->rootLine[$a]['fe_login_mode'] === 3) {
+                    $loginAllowed = false;
+                    $this->loginAllowedInBranch_mode = 'groups';
+                } else {
+                    $loginAllowed = true;
+                }
+            }
+        }
+        return $loginAllowed;
+    }
+
+    /**
+     * Analysing $this->pageAccessFailureHistory into a summary array telling which features disabled display and on which pages and conditions. That data can be used inside a page-not-found handler
+     *
+     * @return array Summary of why page access was not allowed.
+     */
+    public function getPageAccessFailureReasons()
+    {
+        $output = [];
+        $combinedRecords = array_merge(is_array($this->pageAccessFailureHistory['direct_access']) ? $this->pageAccessFailureHistory['direct_access'] : [['fe_group' => 0]], is_array($this->pageAccessFailureHistory['sub_section']) ? $this->pageAccessFailureHistory['sub_section'] : []);
+        if (!empty($combinedRecords)) {
+            foreach ($combinedRecords as $k => $pagerec) {
+                // If $k=0 then it is the very first page the original ID was pointing at and that will get a full check of course
+                // If $k>0 it is parent pages being tested. They are only significant for the access to the first page IF they had the extendToSubpages flag set, hence checked only then!
+                if (!$k || $pagerec['extendToSubpages']) {
+                    if ($pagerec['hidden']) {
+                        $output['hidden'][$pagerec['uid']] = true;
+                    }
+                    if ($pagerec['starttime'] > $GLOBALS['SIM_ACCESS_TIME']) {
+                        $output['starttime'][$pagerec['uid']] = $pagerec['starttime'];
+                    }
+                    if ($pagerec['endtime'] != 0 && $pagerec['endtime'] <= $GLOBALS['SIM_ACCESS_TIME']) {
+                        $output['endtime'][$pagerec['uid']] = $pagerec['endtime'];
+                    }
+                    if (!$this->checkPageGroupAccess($pagerec)) {
+                        $output['fe_group'][$pagerec['uid']] = $pagerec['fe_group'];
+                    }
+                }
+            }
+        }
+        return $output;
+    }
+
+    /**
+     * Gets ->page and ->rootline information based on ->id. ->id may change during this operation.
+     * If not inside domain, then default to first page in domain.
+     *
+     * @param int $domainStartPage Page uid of the page where the found domain record is (pid of the domain record)
+     * @access private
+     */
+    public function getPageAndRootlineWithDomain($domainStartPage)
+    {
+        $this->getPageAndRootline();
+        // Checks if the $domain-startpage is in the rootLine. This is necessary so that references to page-id's from other domains are not possible.
+        if ($domainStartPage && is_array($this->rootLine)) {
+            $idFound = 0;
+            foreach ($this->rootLine as $key => $val) {
+                if ($val['uid'] == $domainStartPage) {
+                    $idFound = 1;
+                    break;
+                }
+            }
+            if (!$idFound) {
+                // Page is 'not found' in case the id was outside the domain, code 3
+                $this->pageNotFound = 3;
+                $this->id = $domainStartPage;
+                // re-get the page and rootline if the id was not found.
+                $this->getPageAndRootline();
+            }
+        }
+    }
+
+    /**
+     * Sets sys_page where-clause
+     *
+     * @access private
+     */
+    public function setSysPageWhereClause()
+    {
+        $expressionBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
+            ->getConnectionForTable('pages')
+            ->getExpressionBuilder();
+        $this->sys_page->where_hid_del = ' AND ' . (string)$expressionBuilder->andX(
+            QueryHelper::stripLogicalOperatorPrefix($this->sys_page->where_hid_del),
+            $expressionBuilder->lt('pages.doktype', 200)
+        );
+        $this->sys_page->where_groupAccess = $this->sys_page->getMultipleGroupsWhereClause('pages.fe_group', 'pages');
+    }
+
+    /**
+     * Looking up a domain record based on HTTP_HOST
+     *
+     * @param bool $recursive If set, it looks "recursively" meaning that a domain like "123.456.typo3.com" would find a domain record like "typo3.com" if "123.456.typo3.com" or "456.typo3.com" did not exist.
+     * @return int Returns the page id of the page where the domain record was found.
+     * @access private
+     */
+    public function findDomainRecord($recursive = false)
+    {
+        if ($recursive) {
+            $pageUid = 0;
+            $host = explode('.', GeneralUtility::getIndpEnv('HTTP_HOST'));
+            while (count($host)) {
+                $pageUid = $this->sys_page->getDomainStartPage(implode('.', $host), GeneralUtility::getIndpEnv('SCRIPT_NAME'), GeneralUtility::getIndpEnv('REQUEST_URI'));
+                if ($pageUid) {
+                    return $pageUid;
+                }
+                array_shift($host);
+            }
+            return $pageUid;
+        }
+        return $this->sys_page->getDomainStartPage(GeneralUtility::getIndpEnv('HTTP_HOST'), GeneralUtility::getIndpEnv('SCRIPT_NAME'), GeneralUtility::getIndpEnv('REQUEST_URI'));
+    }
+
+    /**
+     * Page unavailable handler for use in frontend plugins from extensions.
+     *
+     * @param string $reason Reason text
+     * @param string $header HTTP header to send
+     */
+    public function pageUnavailableAndExit($reason = '', $header = '')
+    {
+        $header = $header ?: $GLOBALS['TYPO3_CONF_VARS']['FE']['pageUnavailable_handling_statheader'];
+        $this->pageUnavailableHandler($GLOBALS['TYPO3_CONF_VARS']['FE']['pageUnavailable_handling'], $header, $reason);
+        die;
+    }
+
+    /**
+     * Page-not-found handler for use in frontend plugins from extensions.
+     *
+     * @param string $reason Reason text
+     * @param string $header HTTP header to send
+     */
+    public function pageNotFoundAndExit($reason = '', $header = '')
+    {
+        $header = $header ?: $GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling_statheader'];
+        $this->pageNotFoundHandler($GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'], $header, $reason);
+        die;
+    }
+
+    /**
+     * Checks whether the pageUnavailableHandler should be used. To be used, pageUnavailable_handling must be set
+     * and devIPMask must not match the current visitor's IP address.
+     *
+     * @return bool TRUE/FALSE whether the pageUnavailable_handler should be used.
+     */
+    public function checkPageUnavailableHandler()
+    {
+        if (
+            $GLOBALS['TYPO3_CONF_VARS']['FE']['pageUnavailable_handling']
+            && !GeneralUtility::cmpIP(
+                GeneralUtility::getIndpEnv('REMOTE_ADDR'),
+                $GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask']
+            )
+        ) {
+            $checkPageUnavailableHandler = true;
+        } else {
+            $checkPageUnavailableHandler = false;
+        }
+        return $checkPageUnavailableHandler;
+    }
+
+    /**
+     * Page unavailable handler. Acts a wrapper for the pageErrorHandler method.
+     *
+     * @param mixed $code Which type of handling; If a true PHP-boolean or TRUE then a \TYPO3\CMS\Core\Messaging\ErrorpageMessage is outputted. If integer an error message with that number is shown. Otherwise the $code value is expected to be a "Location:" header value.
+     * @param string $header If set, this is passed directly to the PHP function, header()
+     * @param string $reason If set, error messages will also mention this as the reason for the page-not-found.
+     */
+    public function pageUnavailableHandler($code, $header, $reason)
+    {
+        $this->pageErrorHandler($code, $header, $reason);
+    }
+
+    /**
+     * Page not found handler. Acts a wrapper for the pageErrorHandler method.
+     *
+     * @param mixed $code Which type of handling; If a true PHP-boolean or TRUE then a \TYPO3\CMS\Core\Messaging\ErrorpageMessage is outputted. If integer an error message with that number is shown. Otherwise the $code value is expected to be a "Location:" header value.
+     * @param string $header If set, this is passed directly to the PHP function, header()
+     * @param string $reason If set, error messages will also mention this as the reason for the page-not-found.
+     */
+    public function pageNotFoundHandler($code, $header = '', $reason = '')
+    {
+        $this->pageErrorHandler($code, $header, $reason);
+    }
+
+    /**
+     * Generic error page handler.
+     * Exits.
+     *
+     * @param mixed $code Which type of handling; If a true PHP-boolean or TRUE then a \TYPO3\CMS\Core\Messaging\ErrorpageMessage is outputted. If integer an error message with that number is shown. Otherwise the $code value is expected to be a "Location:" header value.
+     * @param string $header If set, this is passed directly to the PHP function, header()
+     * @param string $reason If set, error messages will also mention this as the reason for the page-not-found.
+     * @throws \RuntimeException
+     */
+    public function pageErrorHandler($code, $header = '', $reason = '')
+    {
+        // Issue header in any case:
+        if ($header) {
+            $headerArr = preg_split('/\\r|\\n/', $header, -1, PREG_SPLIT_NO_EMPTY);
+            foreach ($headerArr as $header) {
+                header($header);
+            }
+        }
+        // Create response:
+        // Simply boolean; Just shows TYPO3 error page with reason:
+        if (strtolower($code) === 'true' || (string)$code === '1' || gettype($code) === 'boolean') {
+            echo GeneralUtility::makeInstance(ErrorPageController::class)->errorAction(
+                'Page Not Found',
+                'The page did not exist or was inaccessible.' . ($reason ? ' Reason: ' . $reason : '')
+            );
+        } elseif (GeneralUtility::isFirstPartOfStr($code, 'USER_FUNCTION:')) {
+            $funcRef = trim(substr($code, 14));
+            $params = [
+                'currentUrl' => GeneralUtility::getIndpEnv('REQUEST_URI'),
+                'reasonText' => $reason,
+                'pageAccessFailureReasons' => $this->getPageAccessFailureReasons()
+            ];
+            echo GeneralUtility::callUserFunction($funcRef, $params, $this);
+        } elseif (GeneralUtility::isFirstPartOfStr($code, 'READFILE:')) {
+            $readFile = GeneralUtility::getFileAbsFileName(trim(substr($code, 9)));
+            if (@is_file($readFile)) {
+                echo str_replace(
+                    [
+                        '###CURRENT_URL###',
+                        '###REASON###'
+                    ],
+                    [
+                        GeneralUtility::getIndpEnv('REQUEST_URI'),
+                        htmlspecialchars($reason)
+                    ],
+                    file_get_contents($readFile)
+                );
+            } else {
+                throw new \RuntimeException('Configuration Error: 404 page "' . $readFile . '" could not be found.', 1294587214);
+            }
+        } elseif (GeneralUtility::isFirstPartOfStr($code, 'REDIRECT:')) {
+            HttpUtility::redirect(substr($code, 9));
+        } elseif ($code !== '') {
+            // Check if URL is relative
+            $url_parts = parse_url($code);
+            // parse_url could return an array without the key "host", the empty check works better than strict check
+            if (empty($url_parts['host'])) {
+                $url_parts['host'] = GeneralUtility::getIndpEnv('HTTP_HOST');
+                if ($code[0] === '/') {
+                    $code = GeneralUtility::getIndpEnv('TYPO3_REQUEST_HOST') . $code;
+                } else {
+                    $code = GeneralUtility::getIndpEnv('TYPO3_REQUEST_DIR') . $code;
+                }
+                $checkBaseTag = false;
+            } else {
+                $checkBaseTag = true;
+            }
+            // Check recursion
+            if ($code == GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL')) {
+                if ($reason == '') {
+                    $reason = 'Page cannot be found.';
+                }
+                $reason .= LF . LF . 'Additionally, ' . $code . ' was not found while trying to retrieve the error document.';
+                throw new \RuntimeException(nl2br(htmlspecialchars($reason)), 1294587215);
+            }
+            // Prepare headers
+            $headerArr = [
+                'User-agent: ' . GeneralUtility::getIndpEnv('HTTP_USER_AGENT'),
+                'Referer: ' . GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL')
+            ];
+            $res = GeneralUtility::getUrl($code, 1, $headerArr);
+            // Header and content are separated by an empty line
+            list($header, $content) = explode(CRLF . CRLF, $res, 2);
+            $content .= CRLF;
+            if (false === $res) {
+                // Last chance -- redirect
+                HttpUtility::redirect($code);
+            } else {
+                // Forward these response headers to the client
+                $forwardHeaders = [
+                    'Content-Type:'
+                ];
+                $headerArr = preg_split('/\\r|\\n/', $header, -1, PREG_SPLIT_NO_EMPTY);
+                foreach ($headerArr as $header) {
+                    foreach ($forwardHeaders as $h) {
+                        if (preg_match('/^' . $h . '/', $header)) {
+                            header($header);
+                        }
+                    }
+                }
+                // Put <base> if necessary
+                if ($checkBaseTag) {
+                    // If content already has <base> tag, we do not need to do anything
+                    if (false === stristr($content, '<base ')) {
+                        // Generate href for base tag
+                        $base = $url_parts['scheme'] . '://';
+                        if ($url_parts['user'] != '') {
+                            $base .= $url_parts['user'];
+                            if ($url_parts['pass'] != '') {
+                                $base .= ':' . $url_parts['pass'];
+                            }
+                            $base .= '@';
+                        }
+                        $base .= $url_parts['host'];
+                        // Add path portion skipping possible file name
+                        $base .= preg_replace('/(.*\\/)[^\\/]*/', '${1}', $url_parts['path']);
+                        // Put it into content (generate also <head> if necessary)
+                        $replacement = LF . '<base href="' . htmlentities($base) . '" />' . LF;
+                        if (stristr($content, '<head>')) {
+                            $content = preg_replace('/(<head>)/i', '\\1' . $replacement, $content);
+                        } else {
+                            $content = preg_replace('/(<html[^>]*>)/i', '\\1<head>' . $replacement . '</head>', $content);
+                        }
+                    }
+                }
+                // Output the content
+                echo $content;
+            }
+        } else {
+            echo GeneralUtility::makeInstance(ErrorPageController::class)->errorAction(
+                'Page Not Found',
+                $reason ? 'Reason: ' . $reason : 'Page cannot be found.'
+            );
+        }
+        die;
+    }
+
+    /**
+     * Fetches the integer page id for a page alias.
+     * Looks if ->id is not an integer and if so it will search for a page alias and if found the page uid of that page is stored in $this->id
+     *
+     * @access private
+     */
+    public function checkAndSetAlias()
+    {
+        if ($this->id && !MathUtility::canBeInterpretedAsInteger($this->id)) {
+            $aid = $this->sys_page->getPageIdFromAlias($this->id);
+            if ($aid) {
+                $this->id = $aid;
+            } else {
+                $this->pageNotFound = 4;
+            }
+        }
+    }
+
+    /**
+     * Merging values into the global $_GET
+     *
+     * @param array $GET_VARS Array of key/value pairs that will be merged into the current GET-vars. (Non-escaped values)
+     */
+    public function mergingWithGetVars($GET_VARS)
+    {
+        if (is_array($GET_VARS)) {
+            // Getting $_GET var, unescaped.
+            $realGet = GeneralUtility::_GET();
+            if (!is_array($realGet)) {
+                $realGet = [];
+            }
+            // Merge new values on top:
+            ArrayUtility::mergeRecursiveWithOverrule($realGet, $GET_VARS);
+            // Write values back to $_GET:
+            GeneralUtility::_GETset($realGet);
+            // Setting these specifically (like in the init-function):
+            if (isset($GET_VARS['type'])) {
+                $this->type = (int)$GET_VARS['type'];
+            }
+            if (isset($GET_VARS['cHash'])) {
+                $this->cHash = $GET_VARS['cHash'];
+            }
+            if (isset($GET_VARS['MP'])) {
+                $this->MP = $GLOBALS['TYPO3_CONF_VARS']['FE']['enable_mount_pids'] ? $GET_VARS['MP'] : '';
+            }
+            if (isset($GET_VARS['no_cache']) && $GET_VARS['no_cache']) {
+                $this->set_no_cache('no_cache is requested via GET parameter');
+            }
+        }
+    }
+
+    /********************************************
+     *
+     * Template and caching related functions.
+     *
+     *******************************************/
+    /**
+     * Calculates a hash string based on additional parameters in the url.
+     *
+     * Calculated hash is stored in $this->cHash_array.
+     * This is used to cache pages with more parameters than just id and type.
+     *
+     * @see reqCHash()
+     */
+    public function makeCacheHash()
+    {
+        // No need to test anything if caching was already disabled.
+        if ($this->no_cache && !$GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFoundOnCHashError']) {
+            return;
+        }
+        $GET = GeneralUtility::_GET();
+        if ($this->cHash && is_array($GET)) {
+            // Make sure we use the page uid and not the page alias
+            $GET['id'] = $this->id;
+            $this->cHash_array = $this->cacheHash->getRelevantParameters(GeneralUtility::implodeArrayForUrl('', $GET));
+            $cHash_calc = $this->cacheHash->calculateCacheHash($this->cHash_array);
+            if ($cHash_calc != $this->cHash) {
+                if ($GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFoundOnCHashError']) {
+                    $this->pageNotFoundAndExit('Request parameters could not be validated (&cHash comparison failed)');
+                } else {
+                    $this->disableCache();
+                    $this->getTimeTracker()->setTSlogMessage('The incoming cHash "' . $this->cHash . '" and calculated cHash "' . $cHash_calc . '" did not match, so caching was disabled. The fieldlist used was "' . implode(',', array_keys($this->cHash_array)) . '"', 2);
+                }
+            }
+        } elseif (is_array($GET)) {
+            // No cHash is set, check if that is correct
+            if ($this->cacheHash->doParametersRequireCacheHash(GeneralUtility::implodeArrayForUrl('', $GET))) {
+                $this->reqCHash();
+            }
+        }
+    }
+
+    /**
+     * Will disable caching if the cHash value was not set.
+     * This function should be called to check the _existence_ of "&cHash" whenever a plugin generating cacheable output is using extra GET variables. If there _is_ a cHash value the validation of it automatically takes place in makeCacheHash() (see above)
+     *
+     * @see makeCacheHash(), \TYPO3\CMS\Frontend\Plugin\AbstractPlugin::pi_cHashCheck()
+     */
+    public function reqCHash()
+    {
+        if (!$this->cHash) {
+            if ($GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFoundOnCHashError']) {
+                if ($this->tempContent) {
+                    $this->clearPageCacheContent();
+                }
+                $this->pageNotFoundAndExit('Request parameters could not be validated (&cHash empty)');
+            } else {
+                $this->disableCache();
+                $this->getTimeTracker()->setTSlogMessage('TSFE->reqCHash(): No &cHash parameter was sent for GET vars though required so caching is disabled', 2);
+            }
+        }
+    }
+
+    /**
+     * Initialize the TypoScript template parser
+     */
+    public function initTemplate()
+    {
+        $this->tmpl = GeneralUtility::makeInstance(TemplateService::class);
+        $this->tmpl->setVerbose((bool)$this->beUserLogin);
+        $this->tmpl->init();
+        $this->tmpl->tt_track = (bool)$this->beUserLogin;
+    }
+
+    /**
+     * See if page is in cache and get it if so
+     * Stores the page content in $this->content if something is found.
+     *
+     * @throws \InvalidArgumentException
+     * @throws \RuntimeException
+     */
+    public function getFromCache()
+    {
+        // clearing the content-variable, which will hold the pagecontent
+        $this->content = '';
+        // Unsetting the lowlevel config
+        $this->config = [];
+        $this->cacheContentFlag = false;
+
+        if ($this->no_cache) {
+            return;
+        }
+
+        $pageSectionCacheContent = $this->tmpl->getCurrentPageData();
+        if (!is_array($pageSectionCacheContent)) {
+            // Nothing in the cache, we acquire an "exclusive lock" for the key now.
+            // We use the Registry to store this lock centrally,
+            // but we protect the access again with a global exclusive lock to avoid race conditions
+
+            $this->acquireLock('pagesection', $this->id . '::' . $this->MP);
+            //
+            // from this point on we're the only one working on that page ($key)
+            //
+
+            // query the cache again to see if the page data are there meanwhile
+            $pageSectionCacheContent = $this->tmpl->getCurrentPageData();
+            if (is_array($pageSectionCacheContent)) {
+                // we have the content, nice that some other process did the work for us already
+                $this->releaseLock('pagesection');
+            }
+            // We keep the lock set, because we are the ones generating the page now
+                // and filling the cache.
+                // This indicates that we have to release the lock in the Registry later in releaseLocks()
+        }
+
+        if (is_array($pageSectionCacheContent)) {
+            // BE CAREFUL to change the content of the cc-array. This array is serialized and an md5-hash based on this is used for caching the page.
+            // If this hash is not the same in here in this section and after page-generation, then the page will not be properly cached!
+            // This array is an identification of the template. If $this->all is empty it's because the template-data is not cached, which it must be.
+            $pageSectionCacheContent = $this->tmpl->matching($pageSectionCacheContent);
+            ksort($pageSectionCacheContent);
+            $this->all = $pageSectionCacheContent;
+        }
+        unset($pageSectionCacheContent);
+
+        // Look for page in cache only if a shift-reload is not sent to the server.
+        $lockHash = $this->getLockHash();
+        if (!$this->headerNoCache()) {
+            if ($this->all) {
+                // we got page section information
+                $this->newHash = $this->getHash();
+                $this->getTimeTracker()->push('Cache Row', '');
+                $row = $this->getFromCache_queryRow();
+                if (!is_array($row)) {
+                    // nothing in the cache, we acquire an exclusive lock now
+
+                    $this->acquireLock('pages', $lockHash);
+                    //
+                    // from this point on we're the only one working on that page ($lockHash)
+                    //
+
+                    // query the cache again to see if the data are there meanwhile
+                    $row = $this->getFromCache_queryRow();
+                    if (is_array($row)) {
+                        // we have the content, nice that some other process did the work for us
+                        $this->releaseLock('pages');
+                    }
+                    // We keep the lock set, because we are the ones generating the page now
+                        // and filling the cache.
+                        // This indicates that we have to release the lock in the Registry later in releaseLocks()
+                }
+                if (is_array($row)) {
+                    // we have data from cache
+
+                    // Call hook when a page is retrieved from cache:
+                    if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['pageLoadedFromCache'])) {
+                        $_params = ['pObj' => &$this, 'cache_pages_row' => &$row];
+                        foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['pageLoadedFromCache'] as $_funcRef) {
+                            GeneralUtility::callUserFunction($_funcRef, $_params, $this);
+                        }
+                    }
+                    // Fetches the lowlevel config stored with the cached data
+                    $this->config = $row['cache_data'];
+                    // Getting the content
+                    $this->content = $row['content'];
+                    // Flag for temp content
+                    $this->tempContent = $row['temp_content'];
+                    // Setting flag, so we know, that some cached content has been loaded
+                    $this->cacheContentFlag = true;
+                    $this->cacheExpires = $row['expires'];
+
+                    // Restore page title information, this is needed to generate the page title for
+                    // partially cached pages.
+                    $this->page['title'] = $row['pageTitleInfo']['title'];
+                    $this->altPageTitle = $row['pageTitleInfo']['altPageTitle'];
+                    $this->indexedDocTitle = $row['pageTitleInfo']['indexedDocTitle'];
+
+                    if (isset($this->config['config']['debug'])) {
+                        $debugCacheTime = (bool)$this->config['config']['debug'];
+                    } else {
+                        $debugCacheTime = !empty($GLOBALS['TYPO3_CONF_VARS']['FE']['debug']);
+                    }
+                    if ($debugCacheTime) {
+                        $dateFormat = $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'];
+                        $timeFormat = $GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'];
+                        $this->content .= LF . '<!-- Cached page generated ' . date(($dateFormat . ' ' . $timeFormat), $row['tstamp']) . '. Expires ' . date(($dateFormat . ' ' . $timeFormat), $row['expires']) . ' -->';
+                    }
+                }
+                $this->getTimeTracker()->pull();
+
+                return;
+            }
+        }
+        // the user forced rebuilding the page cache or there was no pagesection information
+        // get a lock for the page content so other processes will not interrupt the regeneration
+        $this->acquireLock('pages', $lockHash);
+    }
+
+    /**
+     * Returning the cached version of page with hash = newHash
+     *
+     * @return array Cached row, if any. Otherwise void.
+     */
+    public function getFromCache_queryRow()
+    {
+        $this->getTimeTracker()->push('Cache Query', '');
+        $row = $this->pageCache->get($this->newHash);
+        $this->getTimeTracker()->pull();
+        return $row;
+    }
+
+    /**
+     * Detecting if shift-reload has been clicked
+     * Will not be called if re-generation of page happens by other reasons (for instance that the page is not in cache yet!)
+     * Also, a backend user MUST be logged in for the shift-reload to be detected due to DoS-attack-security reasons.
+     *
+     * @return bool If shift-reload in client browser has been clicked, disable getting cached page (and regenerate it).
+     */
+    public function headerNoCache()
+    {
+        $disableAcquireCacheData = false;
+        if ($this->beUserLogin) {
+            if (strtolower($_SERVER['HTTP_CACHE_CONTROL']) === 'no-cache' || strtolower($_SERVER['HTTP_PRAGMA']) === 'no-cache') {
+                $disableAcquireCacheData = true;
+            }
+        }
+        // Call hook for possible by-pass of requiring of page cache (for recaching purpose)
+        if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['headerNoCache'])) {
+            $_params = ['pObj' => &$this, 'disableAcquireCacheData' => &$disableAcquireCacheData];
+            foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['headerNoCache'] as $_funcRef) {
+                GeneralUtility::callUserFunction($_funcRef, $_params, $this);
+            }
+        }
+        return $disableAcquireCacheData;
+    }
+
+    /**
+     * Calculates the cache-hash
+     * This hash is unique to the template, the variables ->id, ->type, ->gr_list (list of groups), ->MP (Mount Points) and cHash array
+     * Used to get and later store the cached data.
+     *
+     * @return string MD5 hash of serialized hash base from createHashBase()
+     * @access private
+     * @see getFromCache(), getLockHash()
+     */
+    public function getHash()
+    {
+        return md5($this->createHashBase(false));
+    }
+
+    /**
+     * Calculates the lock-hash
+     * This hash is unique to the above hash, except that it doesn't contain the template information in $this->all.
+     *
+     * @return string MD5 hash
+     * @access private
+     * @see getFromCache(), getHash()
+     */
+    public function getLockHash()
+    {
+        $lockHash = $this->createHashBase(true);
+        return md5($lockHash);
+    }
+
+    /**
+     * Calculates the cache-hash (or the lock-hash)
+     * This hash is unique to the template,
+     * the variables ->id, ->type, ->gr_list (list of groups),
+     * ->MP (Mount Points) and cHash array
+     * Used to get and later store the cached data.
+     *
+     * @param bool $createLockHashBase Whether to create the lock hash, which doesn't contain the "this->all" (the template information)
+     * @return string the serialized hash base
+     */
+    protected function createHashBase($createLockHashBase = false)
+    {
+        $hashParameters = [
+            'id' => (int)$this->id,
+            'type' => (int)$this->type,
+            'gr_list' => (string)$this->gr_list,
+            'MP' => (string)$this->MP,
+            'cHash' => $this->cHash_array,
+            'domainStartPage' => $this->domainStartPage
+        ];
+        // Include the template information if we shouldn't create a lock hash
+        if (!$createLockHashBase) {
+            $hashParameters['all'] = $this->all;
+        }
+        // Call hook to influence the hash calculation
+        if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['createHashBase'])) {
+            $_params = [
+                'hashParameters' => &$hashParameters,
+                'createLockHashBase' => $createLockHashBase
+            ];
+            foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['createHashBase'] as $_funcRef) {
+                GeneralUtility::callUserFunction($_funcRef, $_params, $this);
+            }
+        }
+        return serialize($hashParameters);
+    }
+
+    /**
+     * Checks if config-array exists already but if not, gets it
+     *
+     * @throws ServiceUnavailableException
+     */
+    public function getConfigArray()
+    {
+        // If config is not set by the cache (which would be a major mistake somewhere) OR if INTincScripts-include-scripts have been registered, then we must parse the template in order to get it
+        if (empty($this->config) || is_array($this->config['INTincScript']) || $this->forceTemplateParsing) {
+            $timeTracker = $this->getTimeTracker();
+            $timeTracker->push('Parse template', '');
+            // Force parsing, if set?:
+            $this->tmpl->forceTemplateParsing = $this->forceTemplateParsing;
+            // Start parsing the TS template. Might return cached version.
+            $this->tmpl->start($this->rootLine);
+            $timeTracker->pull();
+            if ($this->tmpl->loaded) {
+                $timeTracker->push('Setting the config-array', '');
+                // toplevel - objArrayName
+                $this->sPre = $this->tmpl->setup['types.'][$this->type];
+                $this->pSetup = $this->tmpl->setup[$this->sPre . '.'];
+                if (!is_array($this->pSetup)) {
+                    $message = 'The page is not configured! [type=' . $this->type . '][' . $this->sPre . '].';
+                    if ($this->checkPageUnavailableHandler()) {
+                        $this->pageUnavailableAndExit($message);
+                    } else {
+                        $explanation = 'This means that there is no TypoScript object of type PAGE with typeNum=' . $this->type . ' configured.';
+                        $this->logger->alert($message);
+                        throw new ServiceUnavailableException($message . ' ' . $explanation, 1294587217);
+                    }
+                } else {
+                    if (!isset($this->config['config'])) {
+                        $this->config['config'] = [];
+                    }
+                    // Filling the config-array, first with the main "config." part
+                    if (is_array($this->tmpl->setup['config.'])) {
+                        ArrayUtility::mergeRecursiveWithOverrule($this->tmpl->setup['config.'], $this->config['config']);
+                        $this->config['config'] = $this->tmpl->setup['config.'];
+                    }
+                    // override it with the page/type-specific "config."
+                    if (is_array($this->pSetup['config.'])) {
+                        ArrayUtility::mergeRecursiveWithOverrule($this->config['config'], $this->pSetup['config.']);
+                    }
+                    if ($this->config['config']['typolinkEnableLinksAcrossDomains']) {
+                        $this->config['config']['typolinkCheckRootline'] = true;
+                    }
+                    // Set default values for removeDefaultJS and inlineStyle2TempFile so CSS and JS are externalized if compatversion is higher than 4.0
+                    if (!isset($this->config['config']['removeDefaultJS'])) {
+                        $this->config['config']['removeDefaultJS'] = 'external';
+                    }
+                    if (!isset($this->config['config']['inlineStyle2TempFile'])) {
+                        $this->config['config']['inlineStyle2TempFile'] = 1;
+                    }
+
+                    if (!isset($this->config['config']['compressJs'])) {
+                        $this->config['config']['compressJs'] = 0;
+                    }
+                    // Processing for the config_array:
+                    $this->config['rootLine'] = $this->tmpl->rootLine;
+                    // Class for render Header and Footer parts
+                    if ($this->pSetup['pageHeaderFooterTemplateFile']) {
+                        $file = $this->tmpl->getFileName($this->pSetup['pageHeaderFooterTemplateFile']);
+                        if ($file) {
+                            $this->pageRenderer->setTemplateFile($file);
+                        }
+                    }
+                }
+                $timeTracker->pull();
+            } else {
+                if ($this->checkPageUnavailableHandler()) {
+                    $this->pageUnavailableAndExit('No TypoScript template found!');
+                } else {
+                    $message = 'No TypoScript template found!';
+                    $this->logger->alert($message);
+                    throw new ServiceUnavailableException($message, 1294587218);
+                }
+            }
+        }
+
+        // No cache
+        // Set $this->no_cache TRUE if the config.no_cache value is set!
+        if ($this->config['config']['no_cache']) {
+            $this->set_no_cache('config.no_cache is set');
+        }
+        // Merge GET with defaultGetVars
+        if (!empty($this->config['config']['defaultGetVars.'])) {
+            $modifiedGetVars = GeneralUtility::removeDotsFromTS($this->config['config']['defaultGetVars.']);
+            ArrayUtility::mergeRecursiveWithOverrule($modifiedGetVars, GeneralUtility::_GET());
+            GeneralUtility::_GETset($modifiedGetVars);
+        }
+        // Hook for postProcessing the configuration array
+        if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['configArrayPostProc'])) {
+            $params = ['config' => &$this->config['config']];
+            foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['configArrayPostProc'] as $funcRef) {
+                GeneralUtility::callUserFunction($funcRef, $params, $this);
+            }
+        }
+    }
+
+    /********************************************
+     *
+     * Further initialization and data processing
+     *
+     *******************************************/
+
+    /**
+     * Setting the language key that will be used by the current page.
+     * In this function it should be checked, 1) that this language exists, 2) that a page_overlay_record exists, .. and if not the default language, 0 (zero), should be set.
+     *
+     * @access private
+     */
+    public function settingLanguage()
+    {
+        if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['settingLanguage_preProcess'])) {
+            $_params = [];
+            foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['settingLanguage_preProcess'] as $_funcRef) {
+                GeneralUtility::callUserFunction($_funcRef, $_params, $this);
+            }
+        }
+
+        // Initialize charset settings etc.
+        $languageKey = $this->config['config']['language'] ?? 'default';
+        $this->lang = $languageKey;
+        $this->setOutputLanguage($languageKey);
+
+        // Rendering charset of HTML page.
+        if (isset($this->config['config']['metaCharset']) && $this->config['config']['metaCharset'] !== 'utf-8') {
+            $this->metaCharset = $this->config['config']['metaCharset'];
+        }
+
+        // Get values from TypoScript:
+        $this->sys_language_uid = ($this->sys_language_content = (int)$this->config['config']['sys_language_uid']);
+        list($this->sys_language_mode, $sys_language_content) = GeneralUtility::trimExplode(';', $this->config['config']['sys_language_mode']);
+        $this->sys_language_contentOL = $this->config['config']['sys_language_overlay'];
+        // If sys_language_uid is set to another language than default:
+        if ($this->sys_language_uid > 0) {
+            // check whether a shortcut is overwritten by a translated page
+            // we can only do this now, as this is the place where we get
+            // to know about translations
+            $this->checkTranslatedShortcut();
+            // Request the overlay record for the sys_language_uid:
+            $olRec = $this->sys_page->getPageOverlay($this->id, $this->sys_language_uid);
+            if (empty($olRec)) {
+                // If no OL record exists and a foreign language is asked for...
+                if ($this->sys_language_uid) {
+                    // If requested translation is not available:
+                    if (GeneralUtility::hideIfNotTranslated($this->page['l18n_cfg'])) {
+                        $this->pageNotFoundAndExit('Page is not available in the requested language.');
+                    } else {
+                        switch ((string)$this->sys_language_mode) {
+                            case 'strict':
+                                $this->pageNotFoundAndExit('Page is not available in the requested language (strict).');
+                                break;
+                            case 'content_fallback':
+                                // Setting content uid (but leaving the sys_language_uid) when a content_fallback
+                                // value was found.
+                                $fallBackOrder = GeneralUtility::trimExplode(',', $sys_language_content);
+                                foreach ($fallBackOrder as $orderValue) {
+                                    if ($orderValue === '0' || $orderValue === '') {
+                                        $this->sys_language_content = 0;
+                                        break;
+                                    }
+                                    if (MathUtility::canBeInterpretedAsInteger($orderValue) && !empty($this->sys_page->getPageOverlay($this->id, (int)$orderValue))) {
+                                        $this->sys_language_content = (int)$orderValue;
+                                        break;
+                                    }
+                                    if ($orderValue === 'pageNotFound') {
+                                        // The existing fallbacks have not been found, but instead of continuing
+                                        // page rendering with default language, a "page not found" message should be shown
+                                        // instead.
+                                        $this->pageNotFoundAndExit('Page is not available in the requested language (fallbacks did not apply).');
+                                    }
+                                }
+                                break;
+                            case 'ignore':
+                                $this->sys_language_content = $this->sys_language_uid;
+                                break;
+                            default:
+                                // Default is that everything defaults to the default language...
+                                $this->sys_language_uid = ($this->sys_language_content = 0);
+                        }
+                    }
+                }
+            } else {
+                // Setting sys_language if an overlay record was found (which it is only if a language is used)
+                $this->page = $this->sys_page->getPageOverlay($this->page, $this->sys_language_uid);
+            }
+        }
+        // Setting sys_language_uid inside sys-page:
+        $this->sys_page->sys_language_uid = $this->sys_language_uid;
+        // If default translation is not available:
+        if ((!$this->sys_language_uid || !$this->sys_language_content) && GeneralUtility::hideIfDefaultLanguage($this->page['l18n_cfg'])) {
+            $message = 'Page is not available in default language.';
+            $this->logger->error($message);
+            $this->pageNotFoundAndExit($message);
+        }
+        $this->updateRootLinesWithTranslations();
+
+        // Finding the ISO code for the currently selected language
+        // fetched by the sys_language record when not fetching content from the default language
+        if ($this->sys_language_content > 0) {
+            // using sys_language_content because the ISO code only (currently) affect content selection from FlexForms - which should follow "sys_language_content"
+            // Set the fourth parameter to TRUE in the next two getRawRecord() calls to
+            // avoid versioning overlay to be applied as it generates an SQL error
+            $sys_language_row = $this->sys_page->getRawRecord('sys_language', $this->sys_language_content, 'language_isocode,static_lang_isocode');
+            if (is_array($sys_language_row) && !empty($sys_language_row['language_isocode'])) {
+                $this->sys_language_isocode = $sys_language_row['language_isocode'];
+            }
+            // the DB value is overridden by TypoScript
+            if (!empty($this->config['config']['sys_language_isocode'])) {
+                $this->sys_language_isocode = $this->config['config']['sys_language_isocode'];
+            }
+        } else {
+            // fallback to the TypoScript option when rendering with sys_language_uid=0
+            // also: use "en" by default
+            if (!empty($this->config['config']['sys_language_isocode_default'])) {
+                $this->sys_language_isocode = $this->config['config']['sys_language_isocode_default'];
+            } else {
+                $this->sys_language_isocode = $languageKey !== 'default' ? $languageKey : 'en';
+            }
+        }
+
+        if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['settingLanguage_postProcess'])) {
+            $_params = [];
+            foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['settingLanguage_postProcess'] as $_funcRef) {
+                GeneralUtility::callUserFunction($_funcRef, $_params, $this);
+            }
+        }
+    }
+
+    /**
+     * Updating content of the two rootLines IF the language key is set!
+     */
+    protected function updateRootLinesWithTranslations()
+    {
+        if ($this->sys_language_uid) {
+            $this->rootLine = $this->sys_page->getRootLine($this->id, $this->MP);
+            $this->tmpl->updateRootlineData($this->rootLine);
+        }
+    }
+
+    /**
+     * Setting locale for frontend rendering
+     */
+    public function settingLocale()
+    {
+        // Setting locale
+        if ($this->config['config']['locale_all']) {
+            $availableLocales = GeneralUtility::trimExplode(',', $this->config['config']['locale_all'], true);
+            // If LC_NUMERIC is set e.g. to 'de_DE' PHP parses float values locale-aware resulting in strings with comma
+            // as decimal point which causes problems with value conversions - so we set all locale types except LC_NUMERIC
+            // @see https://bugs.php.net/bug.php?id=53711
+            $locale = setlocale(LC_COLLATE, ...$availableLocales);
+            if ($locale) {
+                // As str_* methods are locale aware and turkish has no upper case I
+                // Class autoloading and other checks depending on case changing break with turkish locale LC_CTYPE
+                // @see http://bugs.php.net/bug.php?id=35050
+                if (substr($this->config['config']['locale_all'], 0, 2) !== 'tr') {
+                    setlocale(LC_CTYPE, ...$availableLocales);
+                }
+                setlocale(LC_MONETARY, ...$availableLocales);
+                setlocale(LC_TIME, ...$availableLocales);
+            } else {
+                $this->getTimeTracker()->setTSlogMessage('Locale "' . htmlspecialchars($this->config['config']['locale_all']) . '" not found.', 3);
+            }
+        }
+    }
+
+    /**
+     * Checks whether a translated shortcut page has a different shortcut
+     * target than the original language page.
+     * If that is the case, things get corrected to follow that alternative
+     * shortcut
+     */
+    protected function checkTranslatedShortcut()
+    {
+        if (!is_null($this->originalShortcutPage)) {
+            $originalShortcutPageOverlay = $this->sys_page->getPageOverlay($this->originalShortcutPage['uid'], $this->sys_language_uid);
+            if (!empty($originalShortcutPageOverlay['shortcut']) && $originalShortcutPageOverlay['shortcut'] != $this->id) {
+                // the translation of the original shortcut page has a different shortcut target!
+                // set the correct page and id
+                $shortcut = $this->getPageShortcut($originalShortcutPageOverlay['shortcut'], $originalShortcutPageOverlay['shortcut_mode'], $originalShortcutPageOverlay['uid']);
+                $this->id = ($this->contentPid = $shortcut['uid']);
+                $this->page = $this->sys_page->getPage($this->id);
+                // Fix various effects on things like menus f.e.
+                $this->fetch_the_id();
+                $this->tmpl->rootLine = array_reverse($this->rootLine);
+            }
+        }
+    }
+
+    /**
+     * Handle data submission
+     * This is done at this point, because we need the config values
+     */
+    public function handleDataSubmission()
+    {
+        // Hook for processing data submission to extensions
+        if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['checkDataSubmission'])) {
+            foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['checkDataSubmission'] as $className) {
+                $_procObj = GeneralUtility::makeInstance($className);
+                $_procObj->checkDataSubmission($this);
+            }
+        }
+    }
+
+    /**
+     * Loops over all configured URL handlers and registers all active handlers in the redirect URL handler array.
+     *
+     * @see $activeRedirectUrlHandlers
+     */
+    public function initializeRedirectUrlHandlers()
+    {
+        if (
+            empty($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['urlProcessing']['urlHandlers'])
+            || !is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['urlProcessing']['urlHandlers'])
+        ) {
+            return;
+        }
+
+        $urlHandlers = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['urlProcessing']['urlHandlers'];
+        foreach ($urlHandlers as $identifier => $configuration) {
+            if (empty($configuration) || !is_array($configuration)) {
+                throw new \RuntimeException('Missing configuration for URL handler "' . $identifier . '".', 1442052263);
+            }
+            if (!is_string($configuration['handler']) || empty($configuration['handler']) || !class_exists($configuration['handler']) || !is_subclass_of($configuration['handler'], UrlHandlerInterface::class)) {
+                throw new \RuntimeException('The URL handler "' . $identifier . '" defines an invalid provider. Ensure the class exists and implements the "' . UrlHandlerInterface::class . '".', 1442052249);
+            }
+        }
+
+        $orderedHandlers = GeneralUtility::makeInstance(DependencyOrderingService::class)->orderByDependencies($urlHandlers);
+
+        foreach ($orderedHandlers as $configuration) {
+            /** @var UrlHandlerInterface $urlHandler */
+            $urlHandler = GeneralUtility::makeInstance($configuration['handler']);
+            if ($urlHandler->canHandleCurrentUrl()) {
+                $this->activeUrlHandlers[] = $urlHandler;
+            }
+        }
+    }
+
+    /**
+     * Loops over all registered URL handlers and lets them process the current URL.
+     *
+     * If no handler has stopped the current process (e.g. by redirecting) and a
+     * the redirectUrl propert is not empty, the user will be redirected to this URL.
+     *
+     * @internal Should be called by the FrontendRequestHandler only.
+     */
+    public function redirectToExternalUrl()
+    {
+        foreach ($this->activeUrlHandlers as $redirectHandler) {
+            $redirectHandler->handle();
+        }
+
+        if (!empty($this->activeUrlHandlers)) {
+            throw new \RuntimeException('A URL handler is active but did not process the URL.', 1442305505);
+        }
+    }
+
+    /**
+     * Sets the URL_ID_TOKEN in the internal var, $this->getMethodUrlIdToken
+     * This feature allows sessions to use a GET-parameter instead of a cookie.
+     *
+     * @access private
+     */
+    public function setUrlIdToken()
+    {
+        if ($this->config['config']['ftu']) {
+            $this->getMethodUrlIdToken = $GLOBALS['TYPO3_CONF_VARS']['FE']['get_url_id_token'];
+        } else {
+            $this->getMethodUrlIdToken = '';
+        }
+    }
+
+    /**
+     * Calculates and sets the internal linkVars based upon the current
+     * $_GET parameters and the setting "config.linkVars".
+     */
+    public function calculateLinkVars()
+    {
+        $this->linkVars = '';
+        if (empty($this->config['config']['linkVars'])) {
+            return;
+        }
+
+        $linkVars = $this->splitLinkVarsString((string)$this->config['config']['linkVars']);
+
+        if (empty($linkVars)) {
+            return;
+        }
+        $getData = GeneralUtility::_GET();
+        foreach ($linkVars as $linkVar) {
+            $test = ($value = '');
+            if (preg_match('/^(.*)\\((.+)\\)$/', $linkVar, $match)) {
+                $linkVar = trim($match[1]);
+                $test = trim($match[2]);
+            }
+            if ($linkVar === '' || !isset($getData[$linkVar])) {
+                continue;
+            }
+            if (!is_array($getData[$linkVar])) {
+                $temp = rawurlencode($getData[$linkVar]);
+                if ($test !== '' && !PageGenerator::isAllowedLinkVarValue($temp, $test)) {
+                    // Error: This value was not allowed for this key
+                    continue;
+                }
+                $value = '&' . $linkVar . '=' . $temp;
+            } else {
+                if ($test !== '' && $test !== 'array') {
+                    // Error: This key must not be an array!
+                    continue;
+                }
+                $value = GeneralUtility::implodeArrayForUrl($linkVar, $getData[$linkVar]);
+            }
+            $this->linkVars .= $value;
+        }
+    }
+
+    /**
+     * Split the link vars string by "," but not if the "," is inside of braces
+     *
+     * @param $string
+     *
+     * @return array
+     */
+    protected function splitLinkVarsString(string $string): array
+    {
+        $tempCommaReplacementString = '###KASPER###';
+
+        // replace every "," wrapped in "()" by a "unique" string
+        $string = preg_replace_callback('/\((?>[^()]|(?R))*\)/', function ($result) use ($tempCommaReplacementString) {
+            return str_replace(',', $tempCommaReplacementString, $result[0]);
+        }, $string);
+
+        $string = GeneralUtility::trimExplode(',', $string);
+
+        // replace all "unique" strings back to ","
+        return str_replace($tempCommaReplacementString, ',', $string);
+    }
+
+    /**
+     * Redirect to target page if the current page is an overlaid mountpoint.
+     *
+     * If the current page is of type mountpoint and should be overlaid with the contents of the mountpoint page
+     * and is accessed directly, the user will be redirected to the mountpoint context.
+     */
+    public function checkPageForMountpointRedirect()
+    {
+        if (!empty($this->originalMountPointPage) && $this->originalMountPointPage['doktype'] == PageRepository::DOKTYPE_MOUNTPOINT) {
+            $this->redirectToCurrentPage();
+        }
+    }
+
+    /**
+     * Redirect to target page, if the current page is a Shortcut.
+     *
+     * If the current page is of type shortcut and accessed directly via its URL, this function redirects to the
+     * Shortcut target using a Location header.
+     */
+    public function checkPageForShortcutRedirect()
+    {
+        if (!empty($this->originalShortcutPage) && $this->originalShortcutPage['doktype'] == PageRepository::DOKTYPE_SHORTCUT) {
+            $this->redirectToCurrentPage();
+        }
+    }
+
+    /**
+     * Builds a typolink to the current page, appends the type paremeter if required
+     * and redirects the user to the generated URL using a Location header.
+     */
+    protected function redirectToCurrentPage()
+    {
+        $this->calculateLinkVars();
+        // Instantiate \TYPO3\CMS\Frontend\ContentObject to generate the correct target URL
+        /** @var $cObj ContentObjectRenderer */
+        $cObj = GeneralUtility::makeInstance(ContentObjectRenderer::class);
+        $parameter = $this->page['uid'];
+        $type = GeneralUtility::_GET('type');
+        if ($type && MathUtility::canBeInterpretedAsInteger($type)) {
+            $parameter .= ',' . $type;
+        }
+        $redirectUrl = $cObj->typoLink_URL(['parameter' => $parameter, 'addQueryString' => true,
+            'addQueryString.' => ['exclude' => 'id']]);
+
+        // Prevent redirection loop
+        if (!empty($redirectUrl)) {
+            // redirect and exit
+            HttpUtility::redirect($redirectUrl, HttpUtility::HTTP_STATUS_307);
+        }
+    }
+
+    /********************************************
+     *
+     * Page generation; cache handling
+     *
+     *******************************************/
+    /**
+     * Returns TRUE if the page should be generated.
+     * That is if no URL handler is active and the cacheContentFlag is not set.
+     *
+     * @return bool
+     */
+    public function isGeneratePage()
+    {
+        return !$this->cacheContentFlag && empty($this->activeUrlHandlers);
+    }
+
+    /**
+     * Temp cache content
+     * The temporary cache will expire after a few seconds (typ. 30) or will be cleared by the rendered page, which will also clear and rewrite the cache.
+     */
+    public function tempPageCacheContent()
+    {
+        $this->tempContent = false;
+        if (!$this->no_cache) {
+            $seconds = 30;
+            $title = htmlspecialchars($this->tmpl->printTitle($this->page['title']));
+            $request_uri = htmlspecialchars(GeneralUtility::getIndpEnv('REQUEST_URI'));
+            $stdMsg = '
                <strong>Page is being generated.</strong><br />
                If this message does not disappear within ' . $seconds . ' seconds, please reload.';
-                       $message = $this->config['config']['message_page_is_being_generated'];
-                       if ((string)$message !== '') {
-                               // This page is always encoded as UTF-8
-                               $message = $this->csConvObj->utf8_encode($message, $this->renderCharset);
-                               $message = str_replace('###TITLE###', $title, $message);
-                               $message = str_replace('###REQUEST_URI###', $request_uri, $message);
-                       } else {
-                               $message = $stdMsg;
-                       }
-                       $temp_content = '<?xml version="1.0" encoding="UTF-8"?>
+            $message = $this->config['config']['message_page_is_being_generated'];
+            if ((string)$message !== '') {
+                $message = str_replace('###TITLE###', $title, $message);
+                $message = str_replace('###REQUEST_URI###', $request_uri, $message);
+            } else {
+                $message = $stdMsg;
+            }
+            $temp_content = '<?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
@@ -3068,459 +2960,493 @@ class TypoScriptFrontendController {
        <body style="background-color:white; font-family:Verdana,Arial,Helvetica,sans-serif; color:#cccccc; text-align:center;">' . $message . '
        </body>
 </html>';
-                       // Fix 'nice errors' feature in modern browsers
-                       $padSuffix = '<!--pad-->';
-                       // prevent any trims
-                       $padSize = 768 - strlen($padSuffix) - strlen($temp_content);
-                       if ($padSize > 0) {
-                               $temp_content = str_pad($temp_content, $padSize, LF) . $padSuffix;
-                       }
-                       if (!$this->headerNoCache() && ($cachedRow = $this->getFromCache_queryRow())) {
-                               // We are here because between checking for cached content earlier and now some other HTTP-process managed to store something in cache AND it was not due to a shift-reload by-pass.
-                               // This is either the "Page is being generated" screen or it can be the final result.
-                               // In any case we should not begin another rendering process also, so we silently disable caching and render the page ourselves and that's it.
-                               // Actually $cachedRow contains content that we could show instead of rendering. Maybe we should do that to gain more performance but then we should set all the stuff done in $this->getFromCache()... For now we stick to this...
-                               $this->set_no_cache('Another process wrote into the cache since the beginning of the render process', TRUE);
-
-                               // Since the new Locking API this should never be the case
-                       } else {
-                               $this->tempContent = TRUE;
-                               // This flag shows that temporary content is put in the cache
-                               $this->setPageCacheContent($temp_content, $this->config, $GLOBALS['EXEC_TIME'] + $seconds);
-                       }
-               }
-       }
-
-       /**
-        * Set cache content to $this->content
-        *
-        * @return void
-        */
-       public function realPageCacheContent() {
-               // seconds until a cached page is too old
-               $cacheTimeout = $this->get_cache_timeout();
-               $timeOutTime = $GLOBALS['EXEC_TIME'] + $cacheTimeout;
-               $this->tempContent = FALSE;
-               $usePageCache = TRUE;
-               // Hook for deciding whether page cache should be written to the cache backend or not
-               // NOTE: as hooks are called in a loop, the last hook will have the final word (however each
-               // hook receives the current status of the $usePageCache flag)
-               if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['usePageCache'])) {
-                       foreach ($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['usePageCache'] as $_classRef) {
-                               $_procObj = GeneralUtility::getUserObj($_classRef);
-                               $usePageCache = $_procObj->usePageCache($this, $usePageCache);
-                       }
-               }
-               // Write the page to cache, if necessary
-               if ($usePageCache) {
-                       $this->setPageCacheContent($this->content, $this->config, $timeOutTime);
-               }
-               // Hook for cache post processing (eg. writing static files!)
-               if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['insertPageIncache'])) {
-                       foreach ($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['insertPageIncache'] as $_classRef) {
-                               $_procObj = GeneralUtility::getUserObj($_classRef);
-                               $_procObj->insertPageIncache($this, $timeOutTime);
-                       }
-               }
-       }
-
-       /**
-        * Sets cache content; Inserts the content string into the cache_pages cache.
-        *
-        * @param string $content The content to store in the HTML field of the cache table
-        * @param mixed $data The additional cache_data array, fx. $this->config
-        * @param int $expirationTstamp Expiration timestamp
-        * @return void
-        * @see realPageCacheContent(), tempPageCacheContent()
-        */
-       public function setPageCacheContent($content, $data, $expirationTstamp) {
-               $cacheData = array(
-                       'identifier' => $this->newHash,
-                       'page_id' => $this->id,
-                       'content' => $content,
-                       'temp_content' => $this->tempContent,
-                       'cache_data' => $data,
-                       'expires' => $expirationTstamp,
-                       'tstamp' => $GLOBALS['EXEC_TIME'],
-                       'pageTitleInfo' => array(
-                               'title' => $this->page['title'],
-                               'altPageTitle' => $this->altPageTitle,
-                               'indexedDocTitle' => $this->indexedDocTitle
-                       )
-               );
-               $this->cacheExpires = $expirationTstamp;
-               $this->pageCacheTags[] = 'pageId_' . $cacheData['page_id'];
-               if ($this->page_cache_reg1) {
-                       $reg1 = (int)$this->page_cache_reg1;
-                       $cacheData['reg1'] = $reg1;
-                       $this->pageCacheTags[] = 'reg1_' . $reg1;
-               }
-               if (!empty($this->page['cache_tags'])) {
-                       $tags = GeneralUtility::trimExplode(',', $this->page['cache_tags'], TRUE);
-                       $this->pageCacheTags = array_merge($this->pageCacheTags, $tags);
-               }
-               $this->pageCache->set($this->newHash, $cacheData, $this->pageCacheTags, $expirationTstamp - $GLOBALS['EXEC_TIME']);
-       }
-
-       /**
-        * Clears cache content (for $this->newHash)
-        *
-        * @return void
-        */
-       public function clearPageCacheContent() {
-               $this->pageCache->remove($this->newHash);
-       }
-
-       /**
-        * Clears cache content for a list of page ids
-        *
-        * @param string $pidList A list of INTEGER numbers which points to page uids for which to clear entries in the cache_pages cache (page content cache)
-        * @return void
-        */
-       public function clearPageCacheContent_pidList($pidList) {
-               $pageIds = GeneralUtility::trimExplode(',', $pidList);
-               foreach ($pageIds as $pageId) {
-                       $this->pageCache->flushByTag('pageId_' . (int)$pageId);
-               }
-       }
-
-       /**
-        * Sets sys last changed
-        * Setting the SYS_LASTCHANGED value in the pagerecord: This value will thus be set to the highest tstamp of records rendered on the page. This includes all records with no regard to hidden records, userprotection and so on.
-        *
-        * @return void
-        * @see ContentObjectRenderer::lastChanged()
-        */
-       public function setSysLastChanged() {
-               // Draft workspaces are always uid 1 or more. We do not update SYS_LASTCHANGED if we are browsing page from one of theses workspaces
-               if ((int)$this->whichWorkspace() < 1 && $this->page['SYS_LASTCHANGED'] < (int)$this->register['SYS_LASTCHANGED']) {
-                       $GLOBALS['TYPO3_DB']->exec_UPDATEquery('pages', 'uid=' . (int)$this->id, array('SYS_LASTCHANGED' => (int)$this->register['SYS_LASTCHANGED']));
-               }
-       }
-
-       /**
-        * Lock the page generation process
-        * The lock is used to queue page requests until this page is successfully stored in the cache.
-        *
-        * @param Locker $lockObj Reference to a locking object
-        * @param string $key String to identify the lock in the system
-        * @return bool Returns TRUE if the lock could be obtained, FALSE otherwise (= process had to wait for existing lock to be released)
-        * @see releasePageGenerationLock()
-        * @deprecated since TYPO3 CMS 7, will be removed with TYPO3 CMS 8
-        */
-       public function acquirePageGenerationLock(&$lockObj, $key) {
-               GeneralUtility::logDeprecatedFunction();
-               if ($this->no_cache || $this->headerNoCache()) {
-                       GeneralUtility::sysLog('Locking: Page is not cached, no locking required', 'cms', GeneralUtility::SYSLOG_SEVERITY_INFO);
-                       // No locking is needed if caching is disabled
-                       return TRUE;
-               }
-               try {
-                       if (!is_object($lockObj)) {
-                               $lockObj = GeneralUtility::makeInstance(Locker::class, $key, $this->TYPO3_CONF_VARS['SYS']['lockingMode']);
-                       }
-                       $success = FALSE;
-                       if ($key !== '') {
-                               // TRUE = Page could get locked without blocking
-                               // FALSE = Page could get locked but process was blocked before
-                               $success = $lockObj->acquire();
-                               if ($lockObj->getLockStatus()) {
-                                       $lockObj->sysLog('Acquired lock');
-                               }
-                       }
-               } catch (\Exception $e) {
-                       GeneralUtility::sysLog('Locking: Failed to acquire lock: ' . $e->getMessage(), 'cms', GeneralUtility::SYSLOG_SEVERITY_ERROR);
-                       // If locking fails, return with FALSE and continue without locking
-                       $success = FALSE;
-               }
-               return $success;
-       }
-
-       /**
-        * Release the page generation lock
-        *
-        * @param Locker $lockObj Reference to a locking object
-        * @return bool Returns TRUE on success, FALSE otherwise
-        * @see acquirePageGenerationLock()
-        * @deprecated since TYPO3 CMS 7, will be removed with TYPO3 CMS 8
-        */
-       public function releasePageGenerationLock(&$lockObj) {
-               GeneralUtility::logDeprecatedFunction();
-               $success = FALSE;
-               // If lock object is set and was acquired (may also happen if no_cache was enabled during runtime), release it:
-               if (is_object($lockObj) && $lockObj instanceof Locker && $lockObj->getLockStatus()) {
-                       $success = $lockObj->release();
-                       $lockObj->sysLog('Released lock');
-                       $lockObj = NULL;
-               } elseif ($this->no_cache || $this->headerNoCache()) {
-                       $success = TRUE;
-               }
-               return $success;
-       }
-
-       /**
-        * Release pending locks
-        *
-        * @internal
-        * @return void
-        */
-       public function releaseLocks() {
-               $this->releaseLock('pagesection');
-               $this->releaseLock('pages');
-       }
-
-       /**
-        * Adds tags to this page's cache entry, you can then f.e. remove cache
-        * entries by tag
-        *
-        * @param array $tags An array of tag
-        * @return void
-        */
-       public function addCacheTags(array $tags) {
-               $this->pageCacheTags = array_merge($this->pageCacheTags, $tags);
-       }
-
-       /********************************************
-        *
-        * Page generation; rendering and inclusion
-        *
-        *******************************************/
-       /**
-        * Does some processing BEFORE the pagegen script is included.
-        *
-        * @return void
-        */
-       public function generatePage_preProcessing() {
-               // Same codeline as in getFromCache(). But $this->all has been changed by
-               // \TYPO3\CMS\Core\TypoScript\TemplateService::start() in the meantime, so this must be called again!
-               $this->newHash = $this->getHash();
-
-               // If the pages_lock is set, we are in charge of generating the page.
-               if (is_object($this->locks['pages']['accessLock'])) {
-                       // Here we put some temporary stuff in the cache in order to let the first hit generate the page.
-                       // The temporary cache will expire after a few seconds (typ. 30) or will be cleared by the rendered page,
-                       // which will also clear and rewrite the cache.
-                       $this->tempPageCacheContent();
-               }
-               // At this point we have a valid pagesection_cache and also some temporary page_cache content,
-               // so let all other processes proceed now. (They are blocked at the pagessection_lock in getFromCache())
-               $this->releaseLock('pagesection');
-
-               // Setting cache_timeout_default. May be overridden by PHP include scripts.
-               $this->cacheTimeOutDefault = (int)$this->config['config']['cache_period'];
-               // Page is generated
-               $this->no_cacheBeforePageGen = $this->no_cache;
-       }
-
-       /**
-        * Determines to include custom or pagegen.php script
-        * returns script-filename if a TypoScript (config) script is defined and should be included instead of pagegen.php
-        *
-        * @return string The relative filepath of "config.pageGenScript" if found and allowed
-        */
-       public function generatePage_whichScript() {
-               if (!$this->TYPO3_CONF_VARS['FE']['noPHPscriptInclude'] && $this->config['config']['pageGenScript']) {
-                       return $this->tmpl->getFileName($this->config['config']['pageGenScript']);
-               }
-       }
-
-       /**
-        * Does some processing AFTER the pagegen script is included.
-        * This includes calling XHTML cleaning (if configured), caching the page, indexing the page (if configured) and setting sysLastChanged
-        *
-        * @return void
-        */
-       public function generatePage_postProcessing() {
-               // This is to ensure, that the page is NOT cached if the no_cache parameter was set before the page was generated. This is a safety precaution, as it could have been unset by some script.
-               if ($this->no_cacheBeforePageGen) {
-                       $this->set_no_cache('no_cache has been set before the page was generated - safety check', TRUE);
-               }
-               // Hook for post-processing of page content cached/non-cached:
-               if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-all'])) {
-                       $_params = array('pObj' => &$this);
-                       foreach ($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-all'] as $_funcRef) {
-                               GeneralUtility::callUserFunction($_funcRef, $_params, $this);
-                       }
-               }
-               // Processing if caching is enabled:
-               if (!$this->no_cache) {
-                       // Hook for post-processing of page content before being cached:
-                       if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-cached'])) {
-                               $_params = array('pObj' => &$this);
-                               foreach ($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-cached'] as $_funcRef) {
-                                       GeneralUtility::callUserFunction($_funcRef, $_params, $this);
-                               }
-                       }
-               }
-               // Convert char-set for output: (should be BEFORE indexing of the content (changed 22/4 2005)), because otherwise indexed search might convert from the wrong charset! One thing is that the charset mentioned in the HTML header would be wrong since the output charset (metaCharset) has not been converted to from renderCharset. And indexed search will internally convert from metaCharset to renderCharset so the content MUST be in metaCharset already!
-               $this->content = $this->convOutputCharset($this->content, 'mainpage');
-               // Hook for indexing pages
-               if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['pageIndexing'])) {
-                       foreach ($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['pageIndexing'] as $_classRef) {
-                               $_procObj = GeneralUtility::getUserObj($_classRef);
-                               $_procObj->hook_indexContent($this);
-                       }
-               }
-               // Storing for cache:
-               if (!$this->no_cache) {
-                       $this->realPageCacheContent();
-               } elseif ($this->tempContent) {
-                       // If there happens to be temporary content in the cache and the cache was not cleared due to new content, put it in... ($this->no_cache=0)
-                       $this->clearPageCacheContent();
-                       $this->tempContent = FALSE;
-               }
-               // Sets sys-last-change:
-               $this->setSysLastChanged();
-       }
-
-       /**
-        * Generate the page title again as TSFE->altPageTitle might have been modified by an inc script
-        *
-        * @return void
-        */
-       protected function regeneratePageTitle() {
-               PageGenerator::generatePageTitle();
-       }
-
-       /**
-        * Processes the INTinclude-scripts
-        *
-        * @return void
-        */
-       public function INTincScript() {
-               // Deprecated stuff:
-               // @deprecated: annotation added TYPO3 4.6
-               $this->additionalHeaderData = is_array($this->config['INTincScript_ext']['additionalHeaderData']) ? $this->config['INTincScript_ext']['additionalHeaderData'] : array();
-               $this->additionalFooterData = is_array($this->config['INTincScript_ext']['additionalFooterData']) ? $this->config['INTincScript_ext']['additionalFooterData'] : array();
-               $this->additionalJavaScript = $this->config['INTincScript_ext']['additionalJavaScript'];
-               $this->additionalCSS = $this->config['INTincScript_ext']['additionalCSS'];
-               $this->divSection = '';
-               if (empty($this->config['INTincScript_ext']['pageRenderer'])) {
-                       $this->initPageRenderer();
-               } else {
-                       /** @var PageRenderer $pageRenderer */
-                       $pageRenderer = unserialize($this->config['INTincScript_ext']['pageRenderer']);
-                       $this->pageRenderer = $pageRenderer;
-                       GeneralUtility::setSingletonInstance(PageRenderer::class, $pageRenderer);
-               }
-
-               $this->recursivelyReplaceIntPlaceholdersInContent();
-               $GLOBALS['TT']->push('Substitute header section');
-               $this->INTincScript_loadJSCode();
-               $this->regeneratePageTitle();
-
-               $this->content = str_replace(
-                       array(
-                               '<!--HD_' . $this->config['INTincScript_ext']['divKey'] . '-->',
-                               '<!--FD_' . $this->config['INTincScript_ext']['divKey'] . '-->',
-                               '<!--TDS_' . $this->config['INTincScript_ext']['divKey'] . '-->'
-                       ),
-                       array(
-                               $this->convOutputCharset(implode(LF, $this->additionalHeaderData), 'HD'),
-                               $this->convOutputCharset(implode(LF, $this->additionalFooterData), 'FD'),
-                               $this->convOutputCharset($this->divSection, 'TDS'),
-                       ),
-                       $this->pageRenderer->renderJavaScriptAndCssForProcessingOfUncachedContentObjects($this->content, $this->config['INTincScript_ext']['divKey'])
-               );
-               // Replace again, because header and footer data and page renderer replacements may introduce additional placeholders (see #44825)
-               $this->recursivelyReplaceIntPlaceholdersInContent();
-               $this->setAbsRefPrefix();
-               $GLOBALS['TT']->pull();
-       }
-
-       /**
-        * Replaces INT placeholders (COA_INT and USER_INT) in $this->content
-        * In case the replacement adds additional placeholders, it loops
-        * until no new placeholders are found any more.
-        */
-       protected function recursivelyReplaceIntPlaceholdersInContent() {
-               do {
-                       $INTiS_config = $this->config['INTincScript'];
-                       $this->INTincScript_includeLibs($INTiS_config);
-                       $this->INTincScript_process($INTiS_config);
-                       // Check if there were new items added to INTincScript during the previous execution:
-                       $INTiS_config = array_diff_assoc($this->config['INTincScript'], $INTiS_config);
-                       $reprocess = count($INTiS_config) > 0;
-               } while ($reprocess);
-       }
-
-       /**
-        * Include libraries for uncached objects.
-        *
-        * @param array $INTiS_config $GLOBALS['TSFE']->config['INTincScript'] or part of it
-        * @return void
-        * @see INTincScript()
-        */
-       protected function INTincScript_includeLibs($INTiS_config) {
-               foreach ($INTiS_config as $INTiS_cPart) {
-                       if (isset($INTiS_cPart['conf']['includeLibs']) && $INTiS_cPart['conf']['includeLibs']) {
-                               $INTiS_resourceList = GeneralUtility::trimExplode(',', $INTiS_cPart['conf']['includeLibs'], TRUE);
-                               $this->includeLibraries($INTiS_resourceList);
-                       }
-               }
-       }
-
-       /**
-        * Processes the INTinclude-scripts and substitue in content.
-        *
-        * @param array $INTiS_config $GLOBALS['TSFE']->config['INTincScript'] or part of it
-        * @return void
-        * @see INTincScript()
-        */
-       protected function INTincScript_process($INTiS_config) {
-               $GLOBALS['TT']->push('Split content');
-               // Splits content with the key.
-               $INTiS_splitC = explode('<!--INT_SCRIPT.', $this->content);
-               $this->content = '';
-               $GLOBALS['TT']->setTSlogMessage('Parts: ' . count($INTiS_splitC));
-               $GLOBALS['TT']->pull();
-               foreach ($INTiS_splitC as $INTiS_c => $INTiS_cPart) {
-                       // If the split had a comment-end after 32 characters it's probably a split-string
-                       if (substr($INTiS_cPart, 32, 3) === '-->') {
-                               $INTiS_key = 'INT_SCRIPT.' . substr($INTiS_cPart, 0, 32);
-                               if (is_array($INTiS_config[$INTiS_key])) {
-                                       $GLOBALS['TT']->push('Include ' . $INTiS_config[$INTiS_key]['file'], '');
-                                       $incContent = '';
-                                       $INTiS_cObj = unserialize($INTiS_config[$INTiS_key]['cObj']);
-                                       /* @var $INTiS_cObj ContentObjectRenderer */
-                                       $INTiS_cObj->INT_include = 1;
-                                       switch ($INTiS_config[$INTiS_key]['type']) {
-                                               case 'COA':
-                                                       $incContent = $INTiS_cObj->cObjGetSingle('COA', $INTiS_config[$INTiS_key]['conf']);
-                                                       break;
-                                               case 'FUNC':
-                                                       $incContent = $INTiS_cObj->cObjGetSingle('USER', $INTiS_config[$INTiS_key]['conf']);
-                                                       break;
-                                               case 'POSTUSERFUNC':
-                                                       $incContent = $INTiS_cObj->callUserFunction($INTiS_config[$INTiS_key]['postUserFunc'], $INTiS_config[$INTiS_key]['conf'], $INTiS_config[$INTiS_key]['content']);
-                                                       break;
-                                       }
-                                       $this->content .= $this->convOutputCharset($incContent, 'INC-' . $INTiS_c);
-                                       $this->content .= substr($INTiS_cPart, 35);
-                                       $GLOBALS['TT']->pull($incContent);
-                               } else {
-                                       $this->content .= substr($INTiS_cPart, 35);
-                               }
-                       } else {
-                               $this->content .= ($INTiS_c ? '<!--INT_SCRIPT.' : '') . $INTiS_cPart;
-                       }
-               }
-       }
-
-       /**
-        * Loads the JavaScript code for INTincScript
-        *
-        * @return void
-        */
-       public function INTincScript_loadJSCode() {
-               // Add javascript
-               $jsCode = trim($this->JSCode);
-               $additionalJavaScript = is_array($this->additionalJavaScript)
-                       ? implode(LF, $this->additionalJavaScript)
-                       : $this->additionalJavaScript;
-               $additionalJavaScript = trim($additionalJavaScript);
-               if ($jsCode !== '' || $additionalJavaScript !== '') {
-                       $this->additionalHeaderData['JSCode'] = '
+            // Fix 'nice errors' feature in modern browsers
+            $padSuffix = '<!--pad-->';
+            // prevent any trims
+            $padSize = 768 - strlen($padSuffix) - strlen($temp_content);
+            if ($padSize > 0) {
+                $temp_content = str_pad($temp_content, $padSize, LF) . $padSuffix;
+            }
+            if (!$this->headerNoCache() && ($cachedRow = $this->getFromCache_queryRow())) {
+                // We are here because between checking for cached content earlier and now some other HTTP-process managed to store something in cache AND it was not due to a shift-reload by-pass.
+                // This is either the "Page is being generated" screen or it can be the final result.
+                // In any case we should not begin another rendering process also, so we silently disable caching and render the page ourselves and that's it.
+                // Actually $cachedRow contains content that we could show instead of rendering. Maybe we should do that to gain more performance but then we should set all the stuff done in $this->getFromCache()... For now we stick to this...
+                $this->set_no_cache('Another process wrote into the cache since the beginning of the render process', true);
+
+                // Since the new Locking API this should never be the case
+            } else {
+                $this->tempContent = true;
+                // This flag shows that temporary content is put in the cache</