[TASK] Move PageRepository to EXT:core 66/61166/7
authorBenni Mack <benni@typo3.org>
Sat, 13 Jul 2019 14:12:47 +0000 (16:12 +0200)
committerBenjamin Franzke <bfr@qbus.de>
Wed, 17 Jul 2019 05:12:52 +0000 (07:12 +0200)
Since Context API was introduced in TYPO3 v9, PageRepository is highly
decoupled from $TSFE->sys_page, and fully works standalone.

It is also used in various places where TSFE is not needed,
or required, but also in places of EXT:core.

Especially parts like RootlineUtility, which depends on PageRepository
very much, cannot live without it.

I propose to move this highly important PHP class into EXT:core,
in order to allow to decouple EXT:frontend even further from
EXT:core.

The FQCN is moved from
- \TYPO3\CMS\Frontend\Page\PageRepository
to
- TYPO3\CMS\Core\Domain\Repository\PageRepository

It can be assumed to use PageRepository for any use-case
and actually reduce usages towards BackendUtility::get...
by using this API more and more.

Further adaptions could be to reduce the logic
within PageRepository and move this into QueryBuilder
and assimilate especially the "versionOL" behavior.

Resolves: #88746
Releases: master
Change-Id: Id8225100ac60bd77fc7e1303efb4c46b741d3415
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/61166
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Benjamin Franzke <bfr@qbus.de>
Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Benjamin Franzke <bfr@qbus.de>
72 files changed:
composer.json
composer.lock
typo3/sysext/backend/Classes/Controller/EditDocumentController.php
typo3/sysext/backend/Classes/Controller/NewRecordController.php
typo3/sysext/backend/Classes/Controller/PageLayoutController.php
typo3/sysext/backend/Classes/Controller/SiteConfigurationController.php
typo3/sysext/backend/Classes/Tree/View/ElementBrowserPageTreeView.php
typo3/sysext/backend/Classes/Utility/BackendUtility.php
typo3/sysext/backend/Classes/View/PageLayoutView.php
typo3/sysext/core/Classes/Domain/Repository/PageRepository.php [new file with mode: 0644]
typo3/sysext/core/Classes/Domain/Repository/PageRepositoryGetPageHookInterface.php [new file with mode: 0644]
typo3/sysext/core/Classes/Domain/Repository/PageRepositoryGetPageOverlayHookInterface.php [new file with mode: 0644]
typo3/sysext/core/Classes/Domain/Repository/PageRepositoryGetRecordOverlayHookInterface.php [new file with mode: 0644]
typo3/sysext/core/Classes/Domain/Repository/PageRepositoryInitHookInterface.php [new file with mode: 0644]
typo3/sysext/core/Classes/Routing/Aspect/PersistedAliasMapper.php
typo3/sysext/core/Classes/Routing/Aspect/PersistedPatternMapper.php
typo3/sysext/core/Classes/Routing/PageRouter.php
typo3/sysext/core/Classes/TypoScript/TemplateService.php
typo3/sysext/core/Classes/Utility/RootlineUtility.php
typo3/sysext/core/Configuration/TCA/pages.php
typo3/sysext/core/Documentation/Changelog/master/Deprecation-88746-PageRepositoryPHPClassMovedFromFrontendToCoreExtension.rst [new file with mode: 0644]
typo3/sysext/core/Migrations/Code/ClassAliasMap.php [new file with mode: 0644]
typo3/sysext/core/Migrations/Code/LegacyClassesForIde.php [new file with mode: 0644]
typo3/sysext/core/Tests/Functional/Domain/Repository/PageRepositoryTest.php [new file with mode: 0644]
typo3/sysext/core/Tests/Functional/Fixtures/pages.xml [new file with mode: 0644]
typo3/sysext/core/Tests/Functional/Tca/PagesVisibleFieldsTest.php
typo3/sysext/core/Tests/Unit/Domain/Repository/PageRepositoryTest.php [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Utility/RootlineUtilityTest.php
typo3/sysext/core/composer.json
typo3/sysext/core/ext_tables.php
typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapper.php
typo3/sysext/extbase/Classes/Persistence/Generic/Storage/Typo3DbBackend.php
typo3/sysext/extbase/Classes/Persistence/Generic/Storage/Typo3DbQueryParser.php
typo3/sysext/extbase/Tests/Functional/Persistence/QueryLocalizedDataTest.php
typo3/sysext/extbase/Tests/Functional/Persistence/TranslationTest.php
typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Storage/Typo3DbBackendTest.php
typo3/sysext/frontend/Classes/Aspect/FileMetadataOverlayAspect.php
typo3/sysext/frontend/Classes/Category/Collection/CategoryCollection.php
typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
typo3/sysext/frontend/Classes/ContentObject/FilesContentObject.php
typo3/sysext/frontend/Classes/ContentObject/Menu/AbstractMenuContentObject.php
typo3/sysext/frontend/Classes/ContentObject/RecordsContentObject.php
typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php
typo3/sysext/frontend/Classes/Middleware/ShortcutAndMountPointRedirect.php
typo3/sysext/frontend/Classes/Page/PageRepository.php [deleted file]
typo3/sysext/frontend/Classes/Page/PageRepositoryGetPageHookInterface.php [deleted file]
typo3/sysext/frontend/Classes/Page/PageRepositoryGetPageOverlayHookInterface.php [deleted file]
typo3/sysext/frontend/Classes/Page/PageRepositoryGetRecordOverlayHookInterface.php [deleted file]
typo3/sysext/frontend/Classes/Page/PageRepositoryInitHookInterface.php [deleted file]
typo3/sysext/frontend/Classes/Typolink/AbstractTypolinkBuilder.php
typo3/sysext/frontend/Classes/Typolink/PageLinkBuilder.php
typo3/sysext/frontend/Configuration/TCA/pages_language_overlay.php
typo3/sysext/frontend/Tests/Functional/Configuration/TypoScript/ConditionMatching/ConditionMatcherTest.php
typo3/sysext/frontend/Tests/Functional/ContentObject/ContentObjectRendererTest.php
typo3/sysext/frontend/Tests/Functional/Controller/TypoScriptFrontendControllerTest.php
typo3/sysext/frontend/Tests/Functional/Fixtures/pages.xml [deleted file]
typo3/sysext/frontend/Tests/Functional/Page/PageRepositoryTest.php [deleted file]
typo3/sysext/frontend/Tests/Functional/Rendering/UriPrefixRenderingTest.php
typo3/sysext/frontend/Tests/Functional/Tca/PagesLanguageOverlayVisibleFieldsTest.php
typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php
typo3/sysext/frontend/Tests/Unit/ContentObject/Menu/AbstractMenuContentObjectTest.php
typo3/sysext/frontend/Tests/Unit/Controller/TypoScriptFrontendControllerTest.php
typo3/sysext/frontend/Tests/Unit/Page/PageRepositoryTest.php [deleted file]
typo3/sysext/frontend/Tests/Unit/Typolink/DatabaseRecordLinkBuilderTest.php
typo3/sysext/indexed_search/Classes/Controller/SearchController.php
typo3/sysext/install/Configuration/ExtensionScanner/Php/ClassNameMatcher.php
typo3/sysext/recordlist/Classes/RecordList/DatabaseRecordList.php
typo3/sysext/seo/Classes/Canonical/CanonicalGenerator.php
typo3/sysext/seo/Classes/XmlSitemap/PagesXmlSitemapDataProvider.php
typo3/sysext/seo/Configuration/TCA/Overrides/pages.php
typo3/sysext/seo/Tests/Functional/Canonical/CanonicalGeneratorTest.php
typo3/sysext/viewpage/Classes/Controller/ViewModuleController.php

index b4d9cfb..32453f1 100644 (file)
@@ -94,6 +94,9 @@
        },
        "extra": {
                "typo3/class-alias-loader": {
+                       "class-alias-maps": [
+                               "typo3/sysext/core/Migrations/Code/ClassAliasMap.php"
+                       ],
                        "always-add-alias-loader": true
                },
                "branch-alias": {
index 1af7549..a8a1f9a 100644 (file)
@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "d1380344a1f0aac44298b30b03cf311e",
+    "content-hash": "6b351613bd61be8bef920113cedfeeda",
     "packages": [
         {
             "name": "cogpowered/finediff",
index fdea3a9..aa991e9 100644 (file)
@@ -34,6 +34,7 @@ use TYPO3\CMS\Core\Database\Query\Restriction\BackendWorkspaceRestriction;
 use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
 use TYPO3\CMS\Core\Database\ReferenceIndex;
 use TYPO3\CMS\Core\DataHandling\DataHandler;
+use TYPO3\CMS\Core\Domain\Repository\PageRepository;
 use TYPO3\CMS\Core\Exception\SiteNotFoundException;
 use TYPO3\CMS\Core\Http\HtmlResponse;
 use TYPO3\CMS\Core\Http\RedirectResponse;
@@ -51,7 +52,6 @@ use TYPO3\CMS\Core\Utility\HttpUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
 use TYPO3\CMS\Core\Utility\PathUtility;
 use TYPO3\CMS\Extbase\SignalSlot\Dispatcher;
-use TYPO3\CMS\Frontend\Page\PageRepository;
 
 /**
  * Main backend controller almost always used if some database record is edited in the backend.
index 691e58c..5c0fedf 100644 (file)
@@ -26,6 +26,7 @@ use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
+use TYPO3\CMS\Core\Domain\Repository\PageRepository;
 use TYPO3\CMS\Core\Http\HtmlResponse;
 use TYPO3\CMS\Core\Http\RedirectResponse;
 use TYPO3\CMS\Core\Imaging\Icon;
@@ -34,7 +35,6 @@ use TYPO3\CMS\Core\Type\Bitmask\Permission;
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\PathUtility;
-use TYPO3\CMS\Frontend\Page\PageRepository;
 
 /**
  * Script class for 'db_new'
index d4aad20..7e11cae 100644 (file)
@@ -29,6 +29,7 @@ use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Database\Query\QueryBuilder;
 use TYPO3\CMS\Core\Database\Query\Restriction\BackendWorkspaceRestriction;
 use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
+use TYPO3\CMS\Core\Domain\Repository\PageRepository;
 use TYPO3\CMS\Core\Http\HtmlResponse;
 use TYPO3\CMS\Core\Imaging\Icon;
 use TYPO3\CMS\Core\Imaging\IconFactory;
@@ -41,7 +42,6 @@ use TYPO3\CMS\Core\Utility\MathUtility;
 use TYPO3\CMS\Core\Versioning\VersionState;
 use TYPO3\CMS\Fluid\View\StandaloneView;
 use TYPO3\CMS\Fluid\ViewHelpers\Be\InfoboxViewHelper;
-use TYPO3\CMS\Frontend\Page\PageRepository;
 
 /**
  * Script Class for Web > Layout module
index aeea35f..c9bee8f 100644 (file)
@@ -33,6 +33,7 @@ use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Database\Query\Restriction\BackendWorkspaceRestriction;
 use TYPO3\CMS\Core\Database\Query\Restriction\HiddenRestriction;
+use TYPO3\CMS\Core\Domain\Repository\PageRepository;
 use TYPO3\CMS\Core\Exception\SiteNotFoundException;
 use TYPO3\CMS\Core\Http\HtmlResponse;
 use TYPO3\CMS\Core\Http\RedirectResponse;
@@ -44,7 +45,6 @@ use TYPO3\CMS\Core\Site\SiteFinder;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
 use TYPO3\CMS\Fluid\View\StandaloneView;
-use TYPO3\CMS\Frontend\Page\PageRepository;
 use TYPO3Fluid\Fluid\View\ViewInterface;
 
 /**
index 986528d..1bd06f6 100644 (file)
@@ -14,10 +14,10 @@ namespace TYPO3\CMS\Backend\Tree\View;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Domain\Repository\PageRepository;
 use TYPO3\CMS\Core\LinkHandling\LinkService;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\HttpUtility;
-use TYPO3\CMS\Frontend\Page\PageRepository;
 use TYPO3\CMS\Recordlist\Tree\View\LinkParameterProviderInterface;
 
 /**
index 0016b75..ca8f0d5 100644 (file)
@@ -29,6 +29,7 @@ use TYPO3\CMS\Core\Database\Query\Restriction\BackendWorkspaceRestriction;
 use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
 use TYPO3\CMS\Core\Database\Query\Restriction\HiddenRestriction;
 use TYPO3\CMS\Core\Database\RelationHandler;
+use TYPO3\CMS\Core\Domain\Repository\PageRepository;
 use TYPO3\CMS\Core\Exception\SiteNotFoundException;
 use TYPO3\CMS\Core\Http\Uri;
 use TYPO3\CMS\Core\Imaging\Icon;
@@ -51,7 +52,6 @@ use TYPO3\CMS\Core\Utility\HttpUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
 use TYPO3\CMS\Core\Utility\PathUtility;
 use TYPO3\CMS\Core\Versioning\VersionState;
-use TYPO3\CMS\Frontend\Page\PageRepository;
 
 /**
  * Standard functions available for the TYPO3 backend.
index 161a702..4f71458 100644 (file)
@@ -1797,7 +1797,7 @@ class PageLayoutView implements LoggerAwareInterface
                     break;
                 case 'shortcut':
                 case 'shortcut_mode':
-                    if ((int)$row['doktype'] === \TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_SHORTCUT) {
+                    if ((int)$row['doktype'] === \TYPO3\CMS\Core\Domain\Repository\PageRepository::DOKTYPE_SHORTCUT) {
                         $theData[$field] = $this->getPagesTableFieldValue($field, $row);
                     }
                     break;
diff --git a/typo3/sysext/core/Classes/Domain/Repository/PageRepository.php b/typo3/sysext/core/Classes/Domain/Repository/PageRepository.php
new file mode 100644 (file)
index 0000000..08567b5
--- /dev/null
@@ -0,0 +1,1740 @@
+<?php
+namespace TYPO3\CMS\Core\Domain\Repository;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+use Psr\Log\LoggerAwareInterface;
+use Psr\Log\LoggerAwareTrait;
+use TYPO3\CMS\Core\Cache\CacheManager;
+use TYPO3\CMS\Core\Cache\Frontend\VariableFrontend;
+use TYPO3\CMS\Core\Context\Context;
+use TYPO3\CMS\Core\Context\Exception\AspectNotFoundException;
+use TYPO3\CMS\Core\Context\LanguageAspect;
+use TYPO3\CMS\Core\Context\UserAspect;
+use TYPO3\CMS\Core\Database\Connection;
+use TYPO3\CMS\Core\Database\ConnectionPool;
+use TYPO3\CMS\Core\Database\Query\QueryHelper;
+use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
+use TYPO3\CMS\Core\Database\Query\Restriction\FrontendRestrictionContainer;
+use TYPO3\CMS\Core\Database\Query\Restriction\FrontendWorkspaceRestriction;
+use TYPO3\CMS\Core\Error\Http\ShortcutTargetPageNotFoundException;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Core\Utility\MathUtility;
+use TYPO3\CMS\Core\Versioning\VersionState;
+
+/**
+ * Page functions, a lot of sql/pages-related functions
+ *
+ * Mainly used in the frontend but also in some cases in the backend. It's
+ * important to set the right $where_hid_del in the object so that the
+ * functions operate properly
+ * @see \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::fetch_the_id()
+ */
+class PageRepository implements LoggerAwareInterface
+{
+    use LoggerAwareTrait;
+
+    /**
+     * This is not the final clauses. There will normally be conditions for the
+     * hidden, starttime and endtime fields as well. You MUST initialize the object
+     * by the init() function
+     *
+     * @var string
+     */
+    public $where_hid_del = ' AND pages.deleted=0';
+
+    /**
+     * Clause for fe_group access
+     *
+     * @var string
+     */
+    public $where_groupAccess = '';
+
+    /**
+     * Can be migrated away later to use context API directly.
+     *
+     * @var int
+     */
+    protected $sys_language_uid = 0;
+
+    /**
+     * Can be migrated away later to use context API directly.
+     * Workspace ID for preview
+     * If > 0, versioning preview of other record versions is allowed. THIS MUST
+     * ONLY BE SET IF the page is not cached and truly previewed by a backend
+     * user!
+     *
+     * @var int
+     */
+    protected $versioningWorkspaceId = 0;
+
+    /**
+     * Computed properties that are added to database rows.
+     *
+     * @var array
+     */
+    protected $computedPropertyNames = [
+        '_LOCALIZED_UID',
+        '_MP_PARAM',
+        '_ORIG_uid',
+        '_ORIG_pid',
+        '_PAGES_OVERLAY',
+        '_PAGES_OVERLAY_UID',
+        '_PAGES_OVERLAY_LANGUAGE',
+        '_PAGES_OVERLAY_REQUESTEDLANGUAGE',
+    ];
+
+    /**
+     * Named constants for "magic numbers" of the field doktype
+     */
+    const DOKTYPE_DEFAULT = 1;
+    const DOKTYPE_LINK = 3;
+    const DOKTYPE_SHORTCUT = 4;
+    const DOKTYPE_BE_USER_SECTION = 6;
+    const DOKTYPE_MOUNTPOINT = 7;
+    const DOKTYPE_SPACER = 199;
+    const DOKTYPE_SYSFOLDER = 254;
+    const DOKTYPE_RECYCLER = 255;
+
+    /**
+     * Named constants for "magic numbers" of the field shortcut_mode
+     */
+    const SHORTCUT_MODE_NONE = 0;
+    const SHORTCUT_MODE_FIRST_SUBPAGE = 1;
+    const SHORTCUT_MODE_RANDOM_SUBPAGE = 2;
+    const SHORTCUT_MODE_PARENT_PAGE = 3;
+
+    /**
+     * @var Context
+     */
+    protected $context;
+
+    /**
+     * PageRepository constructor to set the base context, this will effectively remove the necessity for
+     * setting properties from the outside.
+     *
+     * @param Context $context
+     */
+    public function __construct(Context $context = null)
+    {
+        $this->context = $context ?? GeneralUtility::makeInstance(Context::class);
+        $this->versioningWorkspaceId = $this->context->getPropertyFromAspect('workspace', 'id');
+        // Only set up the where clauses for pages when TCA is set. This usually happens only in tests.
+        // Once all tests are written very well, this can be removed again
+        if (isset($GLOBALS['TCA']['pages'])) {
+            $this->init($this->context->getPropertyFromAspect('visibility', 'includeHiddenPages'));
+            $this->where_groupAccess = $this->getMultipleGroupsWhereClause('pages.fe_group', 'pages');
+            $this->sys_language_uid = (int)$this->context->getPropertyFromAspect('language', 'id', 0);
+        }
+    }
+
+    /**
+     * init() MUST be run directly after creating a new template-object
+     * This sets the internal variable $this->where_hid_del to the correct where
+     * clause for page records taking deleted/hidden/starttime/endtime/t3ver_state
+     * into account
+     *
+     * @param bool $show_hidden If $show_hidden is TRUE, the hidden-field is ignored!! Normally this should be FALSE. Is used for previewing.
+     * @internal
+     */
+    protected function init($show_hidden)
+    {
+        $this->where_groupAccess = '';
+
+        $expressionBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
+            ->getQueryBuilderForTable('pages')
+            ->expr();
+        if ($this->versioningWorkspaceId > 0) {
+            // For version previewing, make sure that enable-fields are not
+            // de-selecting hidden pages - we need versionOL() to unset them only
+            // if the overlay record instructs us to.
+            // Clear where_hid_del and restrict to live and current workspaces
+            $this->where_hid_del = ' AND ' . $expressionBuilder->andX(
+                $expressionBuilder->eq('pages.deleted', 0),
+                $expressionBuilder->orX(
+                    $expressionBuilder->eq('pages.t3ver_wsid', 0),
+                    $expressionBuilder->eq('pages.t3ver_wsid', (int)$this->versioningWorkspaceId)
+                ),
+                $expressionBuilder->lt('pages.doktype', 200)
+            );
+        } else {
+            // add starttime / endtime, and check for hidden/deleted
+            // Filter out new/deleted place-holder pages in case we are NOT in a
+            // versioning preview (that means we are online!)
+            $this->where_hid_del = ' AND ' . (string)$expressionBuilder->andX(
+                QueryHelper::stripLogicalOperatorPrefix(
+                    $this->enableFields('pages', $show_hidden, ['fe_group' => true])
+                ),
+                $expressionBuilder->lt('pages.doktype', 200)
+            );
+        }
+        if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][self::class]['init'] ?? false)) {
+            foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][self::class]['init'] as $classRef) {
+                $hookObject = GeneralUtility::makeInstance($classRef);
+                if (!$hookObject instanceof PageRepositoryInitHookInterface) {
+                    throw new \UnexpectedValueException($classRef . ' must implement interface ' . PageRepositoryInitHookInterface::class, 1379579812);
+                }
+                $hookObject->init_postProcess($this);
+            }
+        }
+    }
+
+    /**************************
+     *
+     * Selecting page records
+     *
+     **************************/
+
+    /**
+     * Loads the full page record for the given page ID.
+     *
+     * The page record is either served from a first-level cache or loaded from the
+     * database. If no page can be found, an empty array is returned.
+     *
+     * Language overlay and versioning overlay are applied. Mount Point
+     * handling is not done, an overlaid Mount Point is not replaced.
+     *
+     * The result is conditioned by the public properties where_groupAccess
+     * and where_hid_del that are preset by the init() method.
+     *
+     * @see PageRepository::where_groupAccess
+     * @see PageRepository::where_hid_del
+     *
+     * By default the usergroup access check is enabled. Use the second method argument
+     * to disable the usergroup access check.
+     *
+     * The given UID can be preprocessed by registering a hook class that is
+     * implementing the PageRepositoryGetPageHookInterface into the configuration array
+     * $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_page.php']['getPage'].
+     *
+     * @param int $uid The page id to look up
+     * @param bool $disableGroupAccessCheck set to true to disable group access check
+     * @return array The resulting page record with overlays or empty array
+     * @throws \UnexpectedValueException
+     * @see PageRepository::getPage_noCheck()
+     */
+    public function getPage($uid, $disableGroupAccessCheck = false)
+    {
+        // Hook to manipulate the page uid for special overlay handling
+        foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_page.php']['getPage'] ?? [] as $className) {
+            $hookObject = GeneralUtility::makeInstance($className);
+            if (!$hookObject instanceof PageRepositoryGetPageHookInterface) {
+                throw new \UnexpectedValueException($className . ' must implement interface ' . PageRepositoryGetPageHookInterface::class, 1251476766);
+            }
+            $hookObject->getPage_preProcess($uid, $disableGroupAccessCheck, $this);
+        }
+        $cacheIdentifier = 'PageRepository_getPage_' . md5(
+            implode(
+                '-',
+                [
+                    $uid,
+                    $disableGroupAccessCheck ? '' : $this->where_groupAccess,
+                    $this->where_hid_del,
+                    $this->sys_language_uid
+                ]
+            )
+        );
+        $cache = $this->getRuntimeCache();
+        $cacheEntry = $cache->get($cacheIdentifier);
+        if (is_array($cacheEntry)) {
+            return $cacheEntry;
+        }
+        $result = [];
+        $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');
+        $queryBuilder->getRestrictions()->removeAll();
+        $queryBuilder->select('*')
+            ->from('pages')
+            ->where(
+                $queryBuilder->expr()->eq('uid', (int)$uid),
+                QueryHelper::stripLogicalOperatorPrefix($this->where_hid_del)
+            );
+
+        if (!$disableGroupAccessCheck) {
+            $queryBuilder->andWhere(QueryHelper::stripLogicalOperatorPrefix($this->where_groupAccess));
+        }
+
+        $row = $queryBuilder->execute()->fetch();
+        if ($row) {
+            $this->versionOL('pages', $row);
+            if (is_array($row)) {
+                $result = $this->getPageOverlay($row);
+            }
+        }
+        $cache->set($cacheIdentifier, $result);
+        return $result;
+    }
+
+    /**
+     * Return the $row for the page with uid = $uid WITHOUT checking for
+     * ->where_hid_del (start- and endtime or hidden). Only "deleted" is checked!
+     *
+     * @param int $uid The page id to look up
+     * @return array The page row with overlaid localized fields. Empty array if no page.
+     * @see getPage()
+     */
+    public function getPage_noCheck($uid)
+    {
+        $cache = $this->getRuntimeCache();
+        $cacheIdentifier = 'PageRepository_getPage_noCheck_' . $uid . '_' . $this->sys_language_uid . '_' . $this->versioningWorkspaceId;
+        $cacheEntry = $cache->get($cacheIdentifier);
+        if ($cacheEntry !== false) {
+            return $cacheEntry;
+        }
+
+        $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');
+        $queryBuilder->getRestrictions()
+            ->removeAll()
+            ->add(GeneralUtility::makeInstance(DeletedRestriction::class));
+        $row = $queryBuilder->select('*')
+            ->from('pages')
+            ->where($queryBuilder->expr()->eq('uid', (int)$uid))
+            ->execute()
+            ->fetch();
+
+        $result = [];
+        if ($row) {
+            $this->versionOL('pages', $row);
+            if (is_array($row)) {
+                $result = $this->getPageOverlay($row);
+            }
+        }
+        $cache->set($cacheIdentifier, $result);
+        return $result;
+    }
+
+    /**
+     * Master helper method to overlay a record to a language.
+     *
+     * Be aware that for pages the languageId is taken, and for all other records the contentId.
+     * This might change through a feature switch in the future.
+     *
+     * @param string $table the name of the table, should be a TCA table with localization enabled
+     * @param array $row the current (full-fletched) record.
+     * @return array|null
+     */
+    public function getLanguageOverlay(string $table, array $row)
+    {
+        // table is not localizable, so return directly
+        if (!isset($GLOBALS['TCA'][$table]['ctrl']['languageField'])) {
+            return $row;
+        }
+        try {
+            /** @var LanguageAspect $languageAspect */
+            $languageAspect = $this->context->getAspect('language');
+            if ($languageAspect->doOverlays()) {
+                if ($table === 'pages') {
+                    return $this->getPageOverlay($row, $languageAspect->getId());
+                }
+                return $this->getRecordOverlay(
+                    $table,
+                    $row,
+                    $languageAspect->getContentId(),
+                    $languageAspect->getOverlayType() === $languageAspect::OVERLAYS_MIXED ? '1' : 'hideNonTranslated'
+                );
+            }
+        } catch (AspectNotFoundException $e) {
+            // no overlays
+        }
+        return $row;
+    }
+
+    /**
+     * Returns the relevant page overlay record fields
+     *
+     * @param mixed $pageInput If $pageInput is an integer, it's the pid of the pageOverlay record and thus the page overlay record is returned. If $pageInput is an array, it's a page-record and based on this page record the language record is found and OVERLAID before the page record is returned.
+     * @param int $languageUid Language UID if you want to set an alternative value to $this->sys_language_uid which is default. Should be >=0
+     * @throws \UnexpectedValueException
+     * @return array Page row which is overlaid with language_overlay record (or the overlay record alone)
+     */
+    public function getPageOverlay($pageInput, $languageUid = null)
+    {
+        $rows = $this->getPagesOverlay([$pageInput], $languageUid);
+        // Always an array in return
+        return $rows[0] ?? [];
+    }
+
+    /**
+     * Returns the relevant page overlay record fields
+     *
+     * @param array $pagesInput Array of integers or array of arrays. If each value is an integer, it's the pids of the pageOverlay records and thus the page overlay records are returned. If each value is an array, it's page-records and based on this page records the language records are found and OVERLAID before the page records are returned.
+     * @param int $languageUid Language UID if you want to set an alternative value to $this->sys_language_uid which is default. Should be >=0
+     * @throws \UnexpectedValueException
+     * @return array Page rows which are overlaid with language_overlay record.
+     *               If the input was an array of integers, missing records are not
+     *               included. If the input were page rows, untranslated pages
+     *               are returned.
+     */
+    public function getPagesOverlay(array $pagesInput, $languageUid = null)
+    {
+        if (empty($pagesInput)) {
+            return [];
+        }
+        if ($languageUid === null) {
+            $languageUid = $this->sys_language_uid;
+        }
+        foreach ($pagesInput as &$origPage) {
+            foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_page.php']['getPageOverlay'] ?? [] as $className) {
+                $hookObject = GeneralUtility::makeInstance($className);
+                if (!$hookObject instanceof PageRepositoryGetPageOverlayHookInterface) {
+                    throw new \UnexpectedValueException($className . ' must implement interface ' . PageRepositoryGetPageOverlayHookInterface::class, 1269878881);
+                }
+                $hookObject->getPageOverlay_preProcess($origPage, $languageUid, $this);
+            }
+        }
+        unset($origPage);
+
+        $overlays = [];
+        // If language UID is different from zero, do overlay:
+        if ($languageUid) {
+            $languageUids = array_merge([$languageUid], $this->getLanguageFallbackChain(null));
+
+            $pageIds = [];
+            foreach ($pagesInput as $origPage) {
+                if (is_array($origPage)) {
+                    // Was the whole record
+                    $pageIds[] = (int)$origPage['uid'];
+                } else {
+                    // Was the id
+                    $pageIds[] = (int)$origPage;
+                }
+            }
+            $overlays = $this->getPageOverlaysForLanguageUids($pageIds, $languageUids);
+        }
+
+        // Create output:
+        $pagesOutput = [];
+        foreach ($pagesInput as $key => $origPage) {
+            if (is_array($origPage)) {
+                $pagesOutput[$key] = $origPage;
+                if (isset($overlays[$origPage['uid']])) {
+                    // Overwrite the original field with the overlay
+                    foreach ($overlays[$origPage['uid']] as $fieldName => $fieldValue) {
+                        if ($fieldName !== 'uid' && $fieldName !== 'pid') {
+                            $pagesOutput[$key][$fieldName] = $fieldValue;
+                        }
+                    }
+                }
+            } else {
+                if (isset($overlays[$origPage])) {
+                    $pagesOutput[$key] = $overlays[$origPage];
+                }
+            }
+        }
+        return $pagesOutput;
+    }
+
+    /**
+     * Checks whether the passed (translated or default language) page is accessible with the given language settings.
+     *
+     * @param array $page the page translation record or the page in the default language
+     * @param LanguageAspect $languageAspect
+     * @return bool true if the given page translation record is suited for the given language ID
+     * @internal only in use for HMENU generation for now
+     */
+    public function isPageSuitableForLanguage(array $page, LanguageAspect $languageAspect): bool
+    {
+        $languageUid = $languageAspect->getId();
+        // Checks if the default language version can be shown
+        // Block page is set, if l18n_cfg allows plus: 1) Either default language or 2) another language but NO overlay record set for page!
+        if (GeneralUtility::hideIfDefaultLanguage($page['l18n_cfg']) && (!$languageUid || $languageUid && !$page['_PAGES_OVERLAY'])) {
+            return false;
+        }
+        if ($languageUid > 0 && GeneralUtility::hideIfNotTranslated($page['l18n_cfg'])) {
+            if (!$page['_PAGES_OVERLAY'] || (int)$page['_PAGES_OVERLAY_LANGUAGE'] !== $languageUid) {
+                return false;
+            }
+        } elseif ($languageUid > 0) {
+            $languageUids = array_merge([$languageUid], $this->getLanguageFallbackChain($languageAspect));
+            return in_array((int)$page['sys_language_uid'], $languageUids, true);
+        }
+        return true;
+    }
+
+    /**
+     * Returns the cleaned fallback chain from the current language aspect, if there is one.
+     *
+     * @param LanguageAspect|null $languageAspect
+     * @return int[]
+     */
+    protected function getLanguageFallbackChain(?LanguageAspect $languageAspect): array
+    {
+        $languageAspect = $languageAspect ?? $this->context->getAspect('language');
+        return array_filter($languageAspect->getFallbackChain(), function ($item) {
+            return MathUtility::canBeInterpretedAsInteger($item);
+        });
+    }
+
+    /**
+     * Returns the first match of overlays for pages in the passed languages.
+     *
+     * NOTE regarding the query restrictions:
+     * Currently the visibility aspect within the FrontendRestrictionContainer will allow
+     * page translation records to be selected as they are child-records of a page.
+     * However you may argue that the visibility flag should determine this.
+     * But that's not how it's done right now.
+     *
+     * @param array $pageUids
+     * @param array $languageUids uid of sys_language, please note that the order is important here.
+     * @return array
+     */
+    protected function getPageOverlaysForLanguageUids(array $pageUids, array $languageUids): array
+    {
+        // Remove default language ("0")
+        $languageUids = array_filter($languageUids);
+        $languageField = $GLOBALS['TCA']['pages']['ctrl']['languageField'];
+        $overlays = [];
+
+        foreach ($pageUids as $pageId) {
+            // Create a map based on the order of values in $languageUids. Those entries reflect the order of the language + fallback chain.
+            // We can't work with database ordering since there is no common SQL clause to order by e.g. [7, 1, 2].
+            $orderedListByLanguages = array_flip($languageUids);
+
+            $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');
+            $queryBuilder->setRestrictions(GeneralUtility::makeInstance(FrontendRestrictionContainer::class));
+            $result = $queryBuilder->select('*')
+                ->from('pages')
+                ->where(
+                    $queryBuilder->expr()->eq(
+                        $GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField'],
+                        $queryBuilder->createNamedParameter($pageId, \PDO::PARAM_INT)
+                    ),
+                    $queryBuilder->expr()->in(
+                        $GLOBALS['TCA']['pages']['ctrl']['languageField'],
+                        $queryBuilder->createNamedParameter($languageUids, Connection::PARAM_INT_ARRAY)
+                    )
+                )
+                ->execute();
+
+            // Create a list of rows ordered by values in $languageUids
+            while ($row = $result->fetch()) {
+                $orderedListByLanguages[$row[$languageField]] = $row;
+            }
+
+            foreach ($orderedListByLanguages as $languageUid => $row) {
+                if (!is_array($row)) {
+                    continue;
+                }
+
+                // Found a result for the current language id
+                $this->versionOL('pages', $row);
+                if (is_array($row)) {
+                    $row['_PAGES_OVERLAY'] = true;
+                    $row['_PAGES_OVERLAY_UID'] = $row['uid'];
+                    $row['_PAGES_OVERLAY_LANGUAGE'] = $languageUid;
+                    $row['_PAGES_OVERLAY_REQUESTEDLANGUAGE'] = $languageUids[0];
+                    // Unset vital fields that are NOT allowed to be overlaid:
+                    unset($row['uid'], $row['pid']);
+                    $overlays[$pageId] = $row;
+
+                    // Language fallback found, stop querying further languages
+                    break;
+                }
+            }
+        }
+
+        return $overlays;
+    }
+
+    /**
+     * Creates language-overlay for records in general (where translation is found
+     * in records from the same table)
+     *
+     * @param string $table Table name
+     * @param array $row Record to overlay. Must contain uid, pid and $table]['ctrl']['languageField']
+     * @param int $sys_language_content Pointer to the sys_language uid for content on the site.
+     * @param string $OLmode Overlay mode. If "hideNonTranslated" then records without translation will not be returned  un-translated but unset (and return value is FALSE)
+     * @throws \UnexpectedValueException
+     * @return mixed Returns the input record, possibly overlaid with a translation.  But if $OLmode is "hideNonTranslated" then it will return FALSE if no translation is found.
+     */
+    public function getRecordOverlay($table, $row, $sys_language_content, $OLmode = '')
+    {
+        foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_page.php']['getRecordOverlay'] ?? [] as $className) {
+            $hookObject = GeneralUtility::makeInstance($className);
+            if (!$hookObject instanceof PageRepositoryGetRecordOverlayHookInterface) {
+                throw new \UnexpectedValueException($className . ' must implement interface ' . PageRepositoryGetRecordOverlayHookInterface::class, 1269881658);
+            }
+            $hookObject->getRecordOverlay_preProcess($table, $row, $sys_language_content, $OLmode, $this);
+        }
+
+        $tableControl = $GLOBALS['TCA'][$table]['ctrl'] ?? [];
+
+        if (!empty($tableControl['languageField'])
+            // Return record for ALL languages untouched
+            // TODO: Fix call stack to prevent this situation in the first place
+            && (int)$row[$tableControl['languageField']] !== -1
+            && !empty($tableControl['transOrigPointerField'])
+            && $row['uid'] > 0
+            && ($row['pid'] > 0 || in_array($tableControl['rootLevel'] ?? false, [true, 1, -1], true))) {
+            // Will try to overlay a record only if the sys_language_content value is larger than zero.
+            if ($sys_language_content > 0) {
+                // Must be default language, otherwise no overlaying
+                if ((int)$row[$tableControl['languageField']] === 0) {
+                    // Select overlay record:
+                    $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
+                        ->getQueryBuilderForTable($table);
+                    $queryBuilder->setRestrictions(
+                        GeneralUtility::makeInstance(FrontendRestrictionContainer::class)
+                    );
+                    $olrow = $queryBuilder->select('*')
+                        ->from($table)
+                        ->where(
+                            $queryBuilder->expr()->eq(
+                                'pid',
+                                $queryBuilder->createNamedParameter($row['pid'], \PDO::PARAM_INT)
+                            ),
+                            $queryBuilder->expr()->eq(
+                                $tableControl['languageField'],
+                                $queryBuilder->createNamedParameter($sys_language_content, \PDO::PARAM_INT)
+                            ),
+                            $queryBuilder->expr()->eq(
+                                $tableControl['transOrigPointerField'],
+                                $queryBuilder->createNamedParameter($row['uid'], \PDO::PARAM_INT)
+                            )
+                        )
+                        ->setMaxResults(1)
+                        ->execute()
+                        ->fetch();
+
+                    $this->versionOL($table, $olrow);
+                    // Merge record content by traversing all fields:
+                    if (is_array($olrow)) {
+                        if (isset($olrow['_ORIG_uid'])) {
+                            $row['_ORIG_uid'] = $olrow['_ORIG_uid'];
+                        }
+                        if (isset($olrow['_ORIG_pid'])) {
+                            $row['_ORIG_pid'] = $olrow['_ORIG_pid'];
+                        }
+                        foreach ($row as $fN => $fV) {
+                            if ($fN !== 'uid' && $fN !== 'pid' && isset($olrow[$fN])) {
+                                $row[$fN] = $olrow[$fN];
+                            } elseif ($fN === 'uid') {
+                                $row['_LOCALIZED_UID'] = $olrow['uid'];
+                            }
+                        }
+                    } elseif ($OLmode === 'hideNonTranslated' && (int)$row[$tableControl['languageField']] === 0) {
+                        // Unset, if non-translated records should be hidden. ONLY done if the source
+                        // record really is default language and not [All] in which case it is allowed.
+                        unset($row);
+                    }
+                } elseif ($sys_language_content != $row[$tableControl['languageField']]) {
+                    unset($row);
+                }
+            } else {
+                // When default language is displayed, we never want to return a record carrying
+                // another language!
+                if ($row[$tableControl['languageField']] > 0) {
+                    unset($row);
+                }
+            }
+        }
+
+        foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_page.php']['getRecordOverlay'] ?? [] as $className) {
+            $hookObject = GeneralUtility::makeInstance($className);
+            if (!$hookObject instanceof PageRepositoryGetRecordOverlayHookInterface) {
+                throw new \UnexpectedValueException($className . ' must implement interface ' . PageRepositoryGetRecordOverlayHookInterface::class, 1269881659);
+            }
+            $hookObject->getRecordOverlay_postProcess($table, $row, $sys_language_content, $OLmode, $this);
+        }
+
+        return $row;
+    }
+
+    /************************************************
+     *
+     * Page related: Menu, Domain record, Root line
+     *
+     ************************************************/
+
+    /**
+     * Returns an array with page rows for subpages of a certain page ID. This is used for menus in the frontend.
+     * If there are mount points in overlay mode the _MP_PARAM field is set to the correct MPvar.
+     *
+     * If the $pageId being input does in itself require MPvars to define a correct
+     * rootline these must be handled externally to this function.
+     *
+     * @param int|int[] $pageId The page id (or array of page ids) for which to fetch subpages (PID)
+     * @param string $fields List of fields to select. Default is "*" = all
+     * @param string $sortField The field to sort by. Default is "sorting
+     * @param string $additionalWhereClause Optional additional where clauses. Like "AND title like '%blabla%'" for instance.
+     * @param bool $checkShortcuts Check if shortcuts exist, checks by default
+     * @return array Array with key/value pairs; keys are page-uid numbers. values are the corresponding page records (with overlaid localized fields, if any)
+     * @see self::getPageShortcut(), \TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuContentObject::makeMenu()
+     */
+    public function getMenu($pageId, $fields = '*', $sortField = 'sorting', $additionalWhereClause = '', $checkShortcuts = true)
+    {
+        return $this->getSubpagesForPages((array)$pageId, $fields, $sortField, $additionalWhereClause, $checkShortcuts);
+    }
+
+    /**
+     * Returns an array with page-rows for pages with uid in $pageIds.
+     *
+     * This is used for menus. If there are mount points in overlay mode
+     * the _MP_PARAM field is set to the correct MPvar.
+     *
+     * @param int[] $pageIds Array of page ids to fetch
+     * @param string $fields List of fields to select. Default is "*" = all
+     * @param string $sortField The field to sort by. Default is "sorting"
+     * @param string $additionalWhereClause Optional additional where clauses. Like "AND title like '%blabla%'" for instance.
+     * @param bool $checkShortcuts Check if shortcuts exist, checks by default
+     * @return array Array with key/value pairs; keys are page-uid numbers. values are the corresponding page records (with overlaid localized fields, if any)
+     */
+    public function getMenuForPages(array $pageIds, $fields = '*', $sortField = 'sorting', $additionalWhereClause = '', $checkShortcuts = true)
+    {
+        return $this->getSubpagesForPages($pageIds, $fields, $sortField, $additionalWhereClause, $checkShortcuts, false);
+    }
+
+    /**
+     * Loads page records either by PIDs or by UIDs.
+     *
+     * By default the subpages of the given page IDs are loaded (as the method name suggests). If $parentPages is set
+     * to FALSE, the page records for the given page IDs are loaded directly.
+     *
+     * Concerning the rationale, please see these two other methods:
+     *
+     * @see PageRepository::getMenu()
+     * @see PageRepository::getMenuForPages()
+     *
+     * Version and language overlay are applied to the loaded records.
+     *
+     * If a record is a mount point in overlay mode, the the overlaying page record is returned in place of the
+     * record. The record is enriched by the field _MP_PARAM containing the mount point mapping for the mount
+     * point.
+     *
+     * The query can be customized by setting fields, sorting and additional WHERE clauses. If additional WHERE
+     * clauses are given, the clause must start with an operator, i.e: "AND title like '%blabla%'".
+     *
+     * The keys of the returned page records are the page UIDs.
+     *
+     * CAUTION: In case of an overlaid mount point, it is the original UID.
+     *
+     * @param int[] $pageIds PIDs or UIDs to load records for
+     * @param string $fields fields to select
+     * @param string $sortField the field to sort by
+     * @param string $additionalWhereClause optional additional WHERE clause
+     * @param bool $checkShortcuts whether to check if shortcuts exist
+     * @param bool $parentPages Switch to load pages (false) or child pages (true).
+     * @return array page records
+     *
+     * @see self::getPageShortcut()
+     * @see \TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuContentObject::makeMenu()
+     */
+    protected function getSubpagesForPages(
+        array $pageIds,
+        string $fields = '*',
+        string $sortField = 'sorting',
+        string $additionalWhereClause = '',
+        bool $checkShortcuts = true,
+        bool $parentPages = true
+    ): array {
+        $relationField = $parentPages ? 'pid' : 'uid';
+        $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');
+        $queryBuilder->getRestrictions()->removeAll();
+
+        $res = $queryBuilder->select(...GeneralUtility::trimExplode(',', $fields, true))
+            ->from('pages')
+            ->where(
+                $queryBuilder->expr()->in(
+                    $relationField,
+                    $queryBuilder->createNamedParameter($pageIds, Connection::PARAM_INT_ARRAY)
+                ),
+                $queryBuilder->expr()->eq(
+                    $GLOBALS['TCA']['pages']['ctrl']['languageField'],
+                    $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)
+                ),
+                QueryHelper::stripLogicalOperatorPrefix($this->where_hid_del),
+                QueryHelper::stripLogicalOperatorPrefix($this->where_groupAccess),
+                QueryHelper::stripLogicalOperatorPrefix($additionalWhereClause)
+            );
+
+        if (!empty($sortField)) {
+            $orderBy = QueryHelper::parseOrderBy($sortField);
+            foreach ($orderBy as $order) {
+                $res->orderBy(...$order);
+            }
+        }
+        $result = $res->execute();
+
+        $pages = [];
+        while ($page = $result->fetch()) {
+            $originalUid = $page['uid'];
+
+            // Versioning Preview Overlay
+            $this->versionOL('pages', $page, true);
+            // Skip if page got disabled due to version overlay
+            // (might be delete or move placeholder)
+            if (empty($page)) {
+                continue;
+            }
+
+            // Add a mount point parameter if needed
+            $page = $this->addMountPointParameterToPage((array)$page);
+
+            // If shortcut, look up if the target exists and is currently visible
+            if ($checkShortcuts) {
+                $page = $this->checkValidShortcutOfPage((array)$page, $additionalWhereClause);
+            }
+
+            // If the page still is there, we add it to the output
+            if (!empty($page)) {
+                $pages[$originalUid] = $page;
+            }
+        }
+
+        // Finally load language overlays
+        return $this->getPagesOverlay($pages);
+    }
+
+    /**
+     * Replaces the given page record with mounted page if required
+     *
+     * If the given page record is a mount point in overlay mode, the page
+     * record is replaced by the record of the overlaying page. The overlay
+     * record is enriched by setting the mount point mapping into the field
+     * _MP_PARAM as string for example '23-14'.
+     *
+     * In all other cases the given page record is returned as is.
+     *
+     * @todo Find a better name. The current doesn't hit the point.
+     *
+     * @param array $page The page record to handle.
+     * @return array The given page record or it's replacement.
+     */
+    protected function addMountPointParameterToPage(array $page): array
+    {
+        if (empty($page)) {
+            return [];
+        }
+
+        // $page MUST have "uid", "pid", "doktype", "mount_pid", "mount_pid_ol" fields in it
+        $mountPointInfo = $this->getMountPointInfo($page['uid'], $page);
+
+        // There is a valid mount point in overlay mode.
+        if (is_array($mountPointInfo) && $mountPointInfo['overlay']) {
+
+            // Using "getPage" is OK since we need the check for enableFields AND for type 2
+            // of mount pids we DO require a doktype < 200!
+            $mountPointPage = $this->getPage($mountPointInfo['mount_pid']);
+
+            if (!empty($mountPointPage)) {
+                $page = $mountPointPage;
+                $page['_MP_PARAM'] = $mountPointInfo['MPvar'];
+            } else {
+                $page = [];
+            }
+        }
+        return $page;
+    }
+
+    /**
+     * If shortcut, look up if the target exists and is currently visible
+     *
+     * @param array $page The page to check
+     * @param string $additionalWhereClause Optional additional where clauses. Like "AND title like '%blabla%'" for instance.
+     * @return array
+     */
+    protected function checkValidShortcutOfPage(array $page, $additionalWhereClause)
+    {
+        if (empty($page)) {
+            return [];
+        }
+
+        $dokType = (int)$page['doktype'];
+        $shortcutMode = (int)$page['shortcut_mode'];
+
+        if ($dokType === self::DOKTYPE_SHORTCUT && ($page['shortcut'] || $shortcutMode)) {
+            if ($shortcutMode === self::SHORTCUT_MODE_NONE) {
+                // No shortcut_mode set, so target is directly set in $page['shortcut']
+                $searchField = 'uid';
+                $searchUid = (int)$page['shortcut'];
+            } elseif ($shortcutMode === self::SHORTCUT_MODE_FIRST_SUBPAGE || $shortcutMode === self::SHORTCUT_MODE_RANDOM_SUBPAGE) {
+                // Check subpages - first subpage or random subpage
+                $searchField = 'pid';
+                // If a shortcut mode is set and no valid page is given to select subpags
+                // from use the actual page.
+                $searchUid = (int)$page['shortcut'] ?: $page['uid'];
+            } elseif ($shortcutMode === self::SHORTCUT_MODE_PARENT_PAGE) {
+                // Shortcut to parent page
+                $searchField = 'uid';
+                $searchUid = $page['pid'];
+            } else {
+                $searchField = '';
+                $searchUid = 0;
+            }
+
+            $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');
+            $queryBuilder->getRestrictions()->removeAll();
+            $count = $queryBuilder->count('uid')
+                ->from('pages')
+                ->where(
+                    $queryBuilder->expr()->eq(
+                        $searchField,
+                        $queryBuilder->createNamedParameter($searchUid, \PDO::PARAM_INT)
+                    ),
+                    QueryHelper::stripLogicalOperatorPrefix($this->where_hid_del),
+                    QueryHelper::stripLogicalOperatorPrefix($this->where_groupAccess),
+                    QueryHelper::stripLogicalOperatorPrefix($additionalWhereClause)
+                )
+                ->execute()
+                ->fetchColumn();
+
+            if (!$count) {
+                $page = [];
+            }
+        } elseif ($dokType === self::DOKTYPE_SHORTCUT) {
+            // Neither shortcut target nor mode is set. Remove the page from the menu.
+            $page = [];
+        }
+        return $page;
+    }
+
+    /**
+     * Get page shortcut; Finds the records pointed to by input value $SC (the shortcut value)
+     *
+     * @param int $shortcutFieldValue The value of the "shortcut" field from the pages record
+     * @param int $shortcutMode 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 $iteration 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 ShortcutTargetPageNotFoundException
+     * @return mixed Returns the page record of the page that the shortcut pointed to.
+     * @internal
+     * @see getPageAndRootline()
+     */
+    public function getPageShortcut($shortcutFieldValue, $shortcutMode, $thisUid, $iteration = 20, $pageLog = [], $disableGroupCheck = false)
+    {
+        $idArray = GeneralUtility::intExplode(',', $shortcutFieldValue);
+        // Find $page record depending on shortcut mode:
+        switch ($shortcutMode) {
+            case self::SHORTCUT_MODE_FIRST_SUBPAGE:
+            case self::SHORTCUT_MODE_RANDOM_SUBPAGE:
+                $pageArray = $this->getMenu($idArray[0] ?: $thisUid, '*', 'sorting', 'AND pages.doktype<199 AND pages.doktype!=' . self::DOKTYPE_BE_USER_SECTION);
+                $pO = 0;
+                if ($shortcutMode == self::SHORTCUT_MODE_RANDOM_SUBPAGE && !empty($pageArray)) {
+                    $pO = (int)rand(0, count($pageArray) - 1);
+                }
+                $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 ShortcutTargetPageNotFoundException($message, 1301648328);
+                }
+                break;
+            case self::SHORTCUT_MODE_PARENT_PAGE:
+                $parent = $this->getPage($idArray[0] ?: $thisUid, $disableGroupCheck);
+                $page = $this->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 ShortcutTargetPageNotFoundException($message, 1301648358);
+                }
+                break;
+            default:
+                $page = $this->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 ShortcutTargetPageNotFoundException($message, 1301648404);
+                }
+        }
+        // Check if short cut page was a shortcut itself, if so look up recursively:
+        if ($page['doktype'] == self::DOKTYPE_SHORTCUT) {
+            if (!in_array($page['uid'], $pageLog) && $iteration > 0) {
+                $pageLog[] = $page['uid'];
+                $page = $this->getPageShortcut($page['shortcut'], $page['shortcut_mode'], $page['uid'], $iteration - 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;
+    }
+
+    /**
+     * Returns the redirect URL for the input page row IF the doktype is set to 3.
+     *
+     * @param array $pagerow The page row to return URL type for
+     * @return string|bool The URL from based on the data from "pages:url". False if not found.
+     */
+    public function getExtURL($pagerow)
+    {
+        if ((int)$pagerow['doktype'] === self::DOKTYPE_LINK) {
+            $redirectTo = $pagerow['url'];
+            $uI = parse_url($redirectTo);
+            // If relative path, prefix Site URL
+            // If it's a valid email without protocol, add "mailto:"
+            if (!($uI['scheme'] ?? false)) {
+                if (GeneralUtility::validEmail($redirectTo)) {
+                    $redirectTo = 'mailto:' . $redirectTo;
+                } elseif ($redirectTo[0] !== '/') {
+                    $redirectTo = GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . $redirectTo;
+                }
+            }
+            return $redirectTo;
+        }
+        return false;
+    }
+
+    /**
+     * Returns a MountPoint array for the specified page
+     *
+     * Does a recursive search if the mounted page should be a mount page
+     * itself.
+     *
+     * Note:
+     *
+     * Recursive mount points are not supported by all parts of the core.
+     * The usage is discouraged. They may be removed from this method.
+     *
+     * @see: https://decisions.typo3.org/t/supporting-or-prohibiting-recursive-mount-points/165/3
+     *
+     * An array will be returned if mount pages are enabled, the correct
+     * doktype (7) is set for page and there IS a mount_pid with a valid
+     * record.
+     *
+     * The optional page record must contain at least uid, pid, doktype,
+     * mount_pid,mount_pid_ol. If it is not supplied it will be looked up by
+     * the system at additional costs for the lookup.
+     *
+     * Returns FALSE if no mount point was found, "-1" if there should have been
+     * one, but no connection to it, otherwise an array with information
+     * about mount pid and modes.
+     *
+     * @param int $pageId Page id to do the lookup for.
+     * @param array|bool $pageRec Optional page record for the given page.
+     * @param array $prevMountPids Internal register to prevent lookup cycles.
+     * @param int $firstPageUid The first page id.
+     * @return mixed Mount point array or failure flags (-1, false).
+     * @see \TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuContentObject
+     */
+    public function getMountPointInfo($pageId, $pageRec = false, $prevMountPids = [], $firstPageUid = 0)
+    {
+        if (!$GLOBALS['TYPO3_CONF_VARS']['FE']['enable_mount_pids']) {
+            return false;
+        }
+        $cacheIdentifier = 'PageRepository_getMountPointInfo_' . $pageId;
+        $cache = $this->getRuntimeCache();
+        if ($cache->has($cacheIdentifier)) {
+            return $cache->get($cacheIdentifier);
+        }
+        $result = false;
+        // Get pageRec if not supplied:
+        if (!is_array($pageRec)) {
+            $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');
+            $queryBuilder->getRestrictions()
+                ->removeAll()
+                ->add(GeneralUtility::makeInstance(DeletedRestriction::class));
+
+            $pageRec = $queryBuilder->select('uid', 'pid', 'doktype', 'mount_pid', 'mount_pid_ol', 't3ver_state')
+                ->from('pages')
+                ->where(
+                    $queryBuilder->expr()->eq(
+                        'uid',
+                        $queryBuilder->createNamedParameter($pageId, \PDO::PARAM_INT)
+                    ),
+                    $queryBuilder->expr()->neq(
+                        'doktype',
+                        $queryBuilder->createNamedParameter(self::DOKTYPE_RECYCLER, \PDO::PARAM_INT)
+                    )
+                )
+                ->execute()
+                ->fetch();
+
+            // Only look for version overlay if page record is not supplied; This assumes
+            // that the input record is overlaid with preview version, if any!
+            $this->versionOL('pages', $pageRec);
+        }
+        // Set first Page uid:
+        if (!$firstPageUid) {
+            $firstPageUid = $pageRec['uid'];
+        }
+        // Look for mount pid value plus other required circumstances:
+        $mount_pid = (int)$pageRec['mount_pid'];
+        if (is_array($pageRec) && (int)$pageRec['doktype'] === self::DOKTYPE_MOUNTPOINT && $mount_pid > 0 && !in_array($mount_pid, $prevMountPids, true)) {
+            // Get the mount point record (to verify its general existence):
+            $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');
+            $queryBuilder->getRestrictions()
+                ->removeAll()
+                ->add(GeneralUtility::makeInstance(DeletedRestriction::class));
+
+            $mountRec = $queryBuilder->select('uid', 'pid', 'doktype', 'mount_pid', 'mount_pid_ol', 't3ver_state')
+                ->from('pages')
+                ->where(
+                    $queryBuilder->expr()->eq(
+                        'uid',
+                        $queryBuilder->createNamedParameter($mount_pid, \PDO::PARAM_INT)
+                    ),
+                    $queryBuilder->expr()->neq(
+                        'doktype',
+                        $queryBuilder->createNamedParameter(self::DOKTYPE_RECYCLER, \PDO::PARAM_INT)
+                    )
+                )
+                ->execute()
+                ->fetch();
+
+            $this->versionOL('pages', $mountRec);
+            if (is_array($mountRec)) {
+                // Look for recursive mount point:
+                $prevMountPids[] = $mount_pid;
+                $recursiveMountPid = $this->getMountPointInfo($mount_pid, $mountRec, $prevMountPids, $firstPageUid);
+                // Return mount point information:
+                $result = $recursiveMountPid ?: [
+                    'mount_pid' => $mount_pid,
+                    'overlay' => $pageRec['mount_pid_ol'],
+                    'MPvar' => $mount_pid . '-' . $firstPageUid,
+                    'mount_point_rec' => $pageRec,
+                    'mount_pid_rec' => $mountRec
+                ];
+            } else {
+                // Means, there SHOULD have been a mount point, but there was none!
+                $result = -1;
+            }
+        }
+        $cache->set($cacheIdentifier, $result);
+        return $result;
+    }
+
+    /********************************
+     *
+     * Selecting records in general
+     *
+     ********************************/
+
+    /**
+     * Checks if a record exists and is accessible.
+     * The row is returned if everything's OK.
+     *
+     * @param string $table The table name to search
+     * @param int $uid The uid to look up in $table
+     * @param bool|int $checkPage If checkPage is set, it's also required that the page on which the record resides is accessible
+     * @return array|int Returns array (the record) if OK, otherwise blank/0 (zero)
+     */
+    public function checkRecord($table, $uid, $checkPage = 0)
+    {
+        $uid = (int)$uid;
+        if (is_array($GLOBALS['TCA'][$table]) && $uid > 0) {
+            $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table);
+            $queryBuilder->setRestrictions(GeneralUtility::makeInstance(FrontendRestrictionContainer::class));
+            $row = $queryBuilder->select('*')
+                ->from($table)
+                ->where($queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT)))
+                ->execute()
+                ->fetch();
+
+            if ($row) {
+                $this->versionOL($table, $row);
+                if (is_array($row)) {
+                    if ($checkPage) {
+                        $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
+                            ->getQueryBuilderForTable('pages');
+                        $queryBuilder->setRestrictions(GeneralUtility::makeInstance(FrontendRestrictionContainer::class));
+                        $numRows = (int)$queryBuilder->count('*')
+                            ->from('pages')
+                            ->where(
+                                $queryBuilder->expr()->eq(
+                                    'uid',
+                                    $queryBuilder->createNamedParameter($row['pid'], \PDO::PARAM_INT)
+                                )
+                            )
+                            ->execute()
+                            ->fetchColumn();
+                        if ($numRows > 0) {
+                            return $row;
+                        }
+                        return 0;
+                    }
+                    return $row;
+                }
+            }
+        }
+        return 0;
+    }
+
+    /**
+     * Returns record no matter what - except if record is deleted
+     *
+     * @param string $table The table name to search
+     * @param int $uid The uid to look up in $table
+     * @param string $fields The fields to select, default is "*
+     * @return mixed Returns array (the record) if found, otherwise blank/0 (zero)
+     * @see getPage_noCheck()
+     */
+    public function getRawRecord($table, $uid, $fields = '*')
+    {
+        $uid = (int)$uid;
+        if (isset($GLOBALS['TCA'][$table]) && is_array($GLOBALS['TCA'][$table]) && $uid > 0) {
+            $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table);
+            $queryBuilder->getRestrictions()
+                ->removeAll()
+                ->add(GeneralUtility::makeInstance(DeletedRestriction::class));
+            $row = $queryBuilder->select(...GeneralUtility::trimExplode(',', $fields, true))
+                ->from($table)
+                ->where($queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT)))
+                ->execute()
+                ->fetch();
+
+            if ($row) {
+                $this->versionOL($table, $row);
+                if (is_array($row)) {
+                    return $row;
+                }
+            }
+        }
+        return 0;
+    }
+
+    /********************************
+     *
+     * Standard clauses
+     *
+     ********************************/
+
+    /**
+     * Returns a part of a WHERE clause which will filter out records with start/end
+     * times or hidden/fe_groups fields set to values that should de-select them
+     * according to the current time, preview settings or user login. Definitely a
+     * frontend function.
+     *
+     * Is using the $GLOBALS['TCA'] arrays "ctrl" part where the key "enablefields"
+     * determines for each table which of these features applies to that table.
+     *
+     * @param string $table Table name found in the $GLOBALS['TCA'] array
+     * @param int $show_hidden If $show_hidden is set (0/1), any hidden-fields in records are ignored. NOTICE: If you call this function, consider what to do with the show_hidden parameter. Maybe it should be set? See ContentObjectRenderer->enableFields where it's implemented correctly.
+     * @param array $ignore_array Array you can pass where keys can be "disabled", "starttime", "endtime", "fe_group" (keys from "enablefields" in TCA) and if set they will make sure that part of the clause is not added. Thus disables the specific part of the clause. For previewing etc.
+     * @throws \InvalidArgumentException
+     * @return string The clause starting like " AND ...=... AND ...=...
+     */
+    public function enableFields($table, $show_hidden = -1, $ignore_array = [])
+    {
+        if ($show_hidden === -1) {
+            // If show_hidden was not set from outside, use the current context
+            $show_hidden = (int)$this->context->getPropertyFromAspect('visibility', $table === 'pages' ? 'includeHiddenPages' : 'includeHiddenContent', false);
+        }
+        // If show_hidden was not changed during the previous evaluation, do it here.
+        $ctrl = $GLOBALS['TCA'][$table]['ctrl'] ?? null;
+        $expressionBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
+            ->getQueryBuilderForTable($table)
+            ->expr();
+        $constraints = [];
+        if (is_array($ctrl)) {
+            // Delete field check:
+            if ($ctrl['delete']) {
+                $constraints[] = $expressionBuilder->eq($table . '.' . $ctrl['delete'], 0);
+            }
+            if ($ctrl['versioningWS'] ?? false) {
+                if ($this->versioningWorkspaceId === 0) {
+                    // Filter out placeholder records (new/moved/deleted items)
+                    // in case we are NOT in a versioning preview (that means we are online!)
+                    $constraints[] = $expressionBuilder->lte(
+                        $table . '.t3ver_state',
+                        new VersionState(VersionState::DEFAULT_STATE)
+                    );
+                } elseif ($table !== 'pages') {
+                    // show only records of live and of the current workspace
+                    // in case we are in a versioning preview
+                    $constraints[] = $expressionBuilder->orX(
+                        $expressionBuilder->eq($table . '.t3ver_wsid', 0),
+                        $expressionBuilder->eq($table . '.t3ver_wsid', (int)$this->versioningWorkspaceId)
+                    );
+                }
+
+                // Filter out versioned records
+                if (empty($ignore_array['pid'])) {
+                    $constraints[] = $expressionBuilder->neq($table . '.pid', -1);
+                }
+            }
+
+            // Enable fields:
+            if (is_array($ctrl['enablecolumns'])) {
+                // In case of versioning-preview, enableFields are ignored (checked in
+                // versionOL())
+                if ($this->versioningWorkspaceId === 0 || !$ctrl['versioningWS']) {
+                    if (($ctrl['enablecolumns']['disabled'] ?? false) && !$show_hidden && !($ignore_array['disabled'] ?? false)) {
+                        $field = $table . '.' . $ctrl['enablecolumns']['disabled'];
+                        $constraints[] = $expressionBuilder->eq($field, 0);
+                    }
+                    if (($ctrl['enablecolumns']['starttime'] ?? false) && !($ignore_array['starttime'] ?? false)) {
+                        $field = $table . '.' . $ctrl['enablecolumns']['starttime'];
+                        $constraints[] = $expressionBuilder->lte($field, (int)$GLOBALS['SIM_ACCESS_TIME']);
+                    }
+                    if (($ctrl['enablecolumns']['endtime'] ?? false) && !($ignore_array['endtime'] ?? false)) {
+                        $field = $table . '.' . $ctrl['enablecolumns']['endtime'];
+                        $constraints[] = $expressionBuilder->orX(
+                            $expressionBuilder->eq($field, 0),
+                            $expressionBuilder->gt($field, (int)$GLOBALS['SIM_ACCESS_TIME'])
+                        );
+                    }
+                    if (($ctrl['enablecolumns']['fe_group'] ?? false) && !($ignore_array['fe_group'] ?? false)) {
+                        $field = $table . '.' . $ctrl['enablecolumns']['fe_group'];
+                        $constraints[] = QueryHelper::stripLogicalOperatorPrefix(
+                            $this->getMultipleGroupsWhereClause($field, $table)
+                        );
+                    }
+                    // Call hook functions for additional enableColumns
+                    // It is used by the extension ingmar_accessctrl which enables assigning more
+                    // than one usergroup to content and page records
+                    $_params = [
+                        'table' => $table,
+                        'show_hidden' => $show_hidden,
+                        'ignore_array' => $ignore_array,
+                        'ctrl' => $ctrl
+                    ];
+                    foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_page.php']['addEnableColumns'] ?? [] as $_funcRef) {
+                        $constraints[] = QueryHelper::stripLogicalOperatorPrefix(
+                            GeneralUtility::callUserFunction($_funcRef, $_params, $this)
+                        );
+                    }
+                }
+            }
+        } else {
+            throw new \InvalidArgumentException('There is no entry in the $TCA array for the table "' . $table . '". This means that the function enableFields() is called with an invalid table name as argument.', 1283790586);
+        }
+
+        return empty($constraints) ? '' : ' AND ' . $expressionBuilder->andX(...$constraints);
+    }
+
+    /**
+     * Creating where-clause for checking group access to elements in enableFields
+     * function
+     *
+     * @param string $field Field with group list
+     * @param string $table Table name
+     * @return string AND sql-clause
+     * @see enableFields()
+     */
+    public function getMultipleGroupsWhereClause($field, $table)
+    {
+        if (!$this->context->hasAspect('frontend.user')) {
+            return '';
+        }
+        /** @var UserAspect $userAspect */
+        $userAspect = $this->context->getAspect('frontend.user');
+        $memberGroups = $userAspect->getGroupIds();
+
+        $expressionBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
+            ->getQueryBuilderForTable($table)
+            ->expr();
+        $orChecks = [];
+        // If the field is empty, then OK
+        $orChecks[] = $expressionBuilder->eq($field, $expressionBuilder->literal(''));
+        // If the field is NULL, then OK
+        $orChecks[] = $expressionBuilder->isNull($field);
+        // If the field contains zero, then OK
+        $orChecks[] = $expressionBuilder->eq($field, $expressionBuilder->literal('0'));
+        foreach ($memberGroups as $value) {
+            $orChecks[] = $expressionBuilder->inSet($field, $expressionBuilder->literal($value));
+        }
+
+        return' AND (' . $expressionBuilder->orX(...$orChecks) . ')';
+    }
+
+    /**********************
+     *
+     * Versioning Preview
+     *
+     **********************/
+
+    /**
+     * Finding online PID for offline version record
+     *
+     * ONLY active when backend user is previewing records. MUST NEVER affect a site
+     * served which is not previewed by backend users!!!
+     *
+     * Will look if the "pid" value of the input record is -1 (it is an offline
+     * version) and if the table supports versioning; if so, it will translate the -1
+     * PID into the PID of the original record.
+     *
+     * Used whenever you are tracking something back, like making the root line.
+     *
+     * Principle; Record offline! => Find online?
+     *
+     * @param string $table Table name
+     * @param array $rr Record array passed by reference. As minimum, "pid" and "uid" fields must exist! "t3ver_oid" and "t3ver_wsid" is nice and will save you a DB query.
+     * @see BackendUtility::fixVersioningPid(), versionOL(), getRootLine()
+     */
+    public function fixVersioningPid($table, &$rr)
+    {
+        if ($this->versioningWorkspaceId > 0 && is_array($rr) && (int)$rr['pid'] === -1 && $GLOBALS['TCA'][$table]['ctrl']['versioningWS']) {
+            $oid = 0;
+            $wsid = 0;
+            // Check values for t3ver_oid and t3ver_wsid:
+            if (isset($rr['t3ver_oid']) && isset($rr['t3ver_wsid'])) {
+                // If "t3ver_oid" is already a field, just set this:
+                $oid = $rr['t3ver_oid'];
+                $wsid = $rr['t3ver_wsid'];
+            } else {
+                // Otherwise we have to expect "uid" to be in the record and look up based
+                // on this:
+                $uid = (int)$rr['uid'];
+                if ($uid > 0) {
+                    $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table);
+                    $queryBuilder->getRestrictions()
+                        ->removeAll()
+                        ->add(GeneralUtility::makeInstance(DeletedRestriction::class));
+                    $newPidRec = $queryBuilder->select('t3ver_oid', 't3ver_wsid')
+                        ->from($table)
+                        ->where($queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT)))
+                        ->execute()
+                        ->fetch();
+
+                    if (is_array($newPidRec)) {
+                        $oid = $newPidRec['t3ver_oid'];
+                        $wsid = $newPidRec['t3ver_wsid'];
+                    }
+                }
+            }
+            // If workspace ids matches and ID of current online version is found, look up
+            // the PID value of that:
+            if ($oid && (int)$wsid === (int)$this->versioningWorkspaceId) {
+                $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table);
+                $queryBuilder->getRestrictions()
+                    ->removeAll()
+                    ->add(GeneralUtility::makeInstance(DeletedRestriction::class));
+                $oidRec = $queryBuilder->select('pid')
+                    ->from($table)
+                    ->where($queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($oid, \PDO::PARAM_INT)))
+                    ->execute()
+                    ->fetch();
+
+                if (is_array($oidRec)) {
+                    // SWAP uid as well? Well no, because when fixing a versioning PID happens it is
+                    // assumed that this is a "branch" type page and therefore the uid should be
+                    // kept (like in versionOL()). However if the page is NOT a branch version it
+                    // should not happen - but then again, direct access to that uid should not
+                    // happen!
+                    $rr['_ORIG_pid'] = $rr['pid'];
+                    $rr['pid'] = $oidRec['pid'];
+                }
+            }
+        }
+        // Changing PID in case of moving pointer:
+        if ($movePlhRec = $this->getMovePlaceholder($table, $rr['uid'], 'pid')) {
+            $rr['pid'] = $movePlhRec['pid'];
+        }
+    }
+
+    /**
+     * Versioning Preview Overlay
+     *
+     * ONLY active when backend user is previewing records. MUST NEVER affect a site
+     * served which is not previewed by backend users!!!
+     *
+     * Generally ALWAYS used when records are selected based on uid or pid. If
+     * records are selected on other fields than uid or pid (eg. "email = ....") then
+     * usage might produce undesired results and that should be evaluated on
+     * individual basis.
+     *
+     * Principle; Record online! => Find offline?
+     *
+     * @param string $table Table name
+     * @param array $row Record array passed by reference. As minimum, the "uid", "pid" and "t3ver_state" fields must exist! The record MAY be set to FALSE in which case the calling function should act as if the record is forbidden to access!
+     * @param bool $unsetMovePointers If set, the $row is cleared in case it is a move-pointer. This is only for preview of moved records (to remove the record from the original location so it appears only in the new location)
+     * @param bool $bypassEnableFieldsCheck Unless this option is TRUE, the $row is unset if enablefields for BOTH the version AND the online record deselects it. This is because when versionOL() is called it is assumed that the online record is already selected with no regards to it's enablefields. However, after looking for a new version the online record enablefields must ALSO be evaluated of course. This is done all by this function!
+     * @see fixVersioningPid(), BackendUtility::workspaceOL()
+     */
+    public function versionOL($table, &$row, $unsetMovePointers = false, $bypassEnableFieldsCheck = false)
+    {
+        if ($this->versioningWorkspaceId > 0 && is_array($row)) {
+            // will overlay any movePlhOL found with the real record, which in turn
+            // will be overlaid with its workspace version if any.
+            $movePldSwap = $this->movePlhOL($table, $row);
+            // implode(',',array_keys($row)) = Using fields from original record to make
+            // sure no additional fields are selected. This is best for eg. getPageOverlay()
+            // Computed properties are excluded since those would lead to SQL errors.
+            $fieldNames = implode(',', array_keys($this->purgeComputedProperties($row)));
+            if ($wsAlt = $this->getWorkspaceVersionOfRecord($this->versioningWorkspaceId, $table, $row['uid'], $fieldNames, $bypassEnableFieldsCheck)) {
+                if (is_array($wsAlt)) {
+                    // Always fix PID (like in fixVersioningPid() above). [This is usually not
+                    // the important factor for versioning OL]
+                    // Keep the old (-1) - indicates it was a version...
+                    $wsAlt['_ORIG_pid'] = $wsAlt['pid'];
+                    // Set in the online versions PID.
+                    $wsAlt['pid'] = $row['pid'];
+                    // For versions of single elements or page+content, preserve online UID and PID
+                    // (this will produce true "overlay" of element _content_, not any references)
+                    // For page+content the "_ORIG_uid" should actually be used as PID for selection.
+                    $wsAlt['_ORIG_uid'] = $wsAlt['uid'];
+                    $wsAlt['uid'] = $row['uid'];
+                    // Changing input record to the workspace version alternative:
+                    $row = $wsAlt;
+                    // Check if it is deleted/new
+                    $rowVersionState = VersionState::cast($row['t3ver_state'] ?? null);
+                    if (
+                        $rowVersionState->equals(VersionState::NEW_PLACEHOLDER)
+                        || $rowVersionState->equals(VersionState::DELETE_PLACEHOLDER)
+                    ) {
+                        // Unset record if it turned out to be deleted in workspace
+                        $row = false;
+                    }
+                    // Check if move-pointer in workspace (unless if a move-placeholder is the
+                    // reason why it appears!):
+                    // You have to specifically set $unsetMovePointers in order to clear these
+                    // because it is normally a display issue if it should be shown or not.
+                    if (
+                        (
+                            $rowVersionState->equals(VersionState::MOVE_POINTER)
+                            && !$movePldSwap
+                        ) && $unsetMovePointers
+                    ) {
+                        // Unset record if it turned out to be deleted in workspace
+                        $row = false;
+                    }
+                } else {
+                    // No version found, then check if t3ver_state = VersionState::NEW_PLACEHOLDER
+                    // (online version is dummy-representation)
+                    // Notice, that unless $bypassEnableFieldsCheck is TRUE, the $row is unset if
+                    // enablefields for BOTH the version AND the online record deselects it. See
+                    // note for $bypassEnableFieldsCheck
+                    /** @var \TYPO3\CMS\Core\Versioning\VersionState $versionState */
+                    $versionState = VersionState::cast($row['t3ver_state']);
+                    if ($wsAlt <= -1 || $versionState->indicatesPlaceholder()) {
+                        // Unset record if it turned out to be "hidden"
+                        $row = false;
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * Checks if record is a move-placeholder
+     * (t3ver_state==VersionState::MOVE_PLACEHOLDER) and if so it will set $row to be
+     * the pointed-to live record (and return TRUE) Used from versionOL
+     *
+     * @param string $table Table name
+     * @param array $row Row (passed by reference) - only online records...
+     * @return bool TRUE if overlay is made.
+     * @see BackendUtility::movePlhOl()
+     */
+    protected function movePlhOL($table, &$row)
+    {
+        if (!empty($GLOBALS['TCA'][$table]['ctrl']['versioningWS'])
+            && (int)VersionState::cast($row['t3ver_state'])->equals(VersionState::MOVE_PLACEHOLDER)
+        ) {
+            $moveID = 0;
+            // If t3ver_move_id is not found, then find it (but we like best if it is here)
+            if (!isset($row['t3ver_move_id'])) {
+                if ((int)$row['uid'] > 0) {
+                    $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table);
+                    $queryBuilder->getRestrictions()
+                        ->removeAll()
+                        ->add(GeneralUtility::makeInstance(DeletedRestriction::class));
+                    $moveIDRec = $queryBuilder->select('t3ver_move_id')
+                        ->from($table)
+                        ->where($queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($row['uid'], \PDO::PARAM_INT)))
+                        ->execute()
+                        ->fetch();
+
+                    if (is_array($moveIDRec)) {
+                        $moveID = $moveIDRec['t3ver_move_id'];
+                    }
+                }
+            } else {
+                $moveID = $row['t3ver_move_id'];
+            }
+            // Find pointed-to record.
+            if ($moveID) {
+                $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table);
+                $queryBuilder->setRestrictions(GeneralUtility::makeInstance(FrontendRestrictionContainer::class));
+                $origRow = $queryBuilder->select(...array_keys($this->purgeComputedProperties($row)))
+                    ->from($table)
+                    ->where(
+                        $queryBuilder->expr()->eq(
+                            'uid',
+                            $queryBuilder->createNamedParameter($moveID, \PDO::PARAM_INT)
+                        )
+                    )
+                    ->setMaxResults(1)
+                    ->execute()
+                    ->fetch();
+
+                if ($origRow) {
+                    $row = $origRow;
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+    /**
+     * Returns move placeholder of online (live) version
+     *
+     * @param string $table Table name
+     * @param int $uid Record UID of online version
+     * @param string $fields Field list, default is *
+     * @return array If found, the record, otherwise nothing.
+     * @see BackendUtility::getMovePlaceholder()
+     */
+    protected function getMovePlaceholder($table, $uid, $fields = '*')
+    {
+        $workspace = (int)$this->versioningWorkspaceId;
+        if (!empty($GLOBALS['TCA'][$table]['ctrl']['versioningWS']) && $workspace > 0) {
+            // Select workspace version of record:
+            $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table);
+            $queryBuilder->getRestrictions()
+                ->removeAll()
+                ->add(GeneralUtility::makeInstance(DeletedRestriction::class));
+
+            $row = $queryBuilder->select(...GeneralUtility::trimExplode(',', $fields, true))
+                ->from($table)
+                ->where(
+                    $queryBuilder->expr()->neq('pid', $queryBuilder->createNamedParameter(-1, \PDO::PARAM_INT)),
+                    $queryBuilder->expr()->eq(
+                        't3ver_state',
+                        $queryBuilder->createNamedParameter(
+                            (string)VersionState::cast(VersionState::MOVE_PLACEHOLDER),
+                            \PDO::PARAM_INT
+                        )
+                    ),
+                    $queryBuilder->expr()->eq(
+                        't3ver_move_id',
+                        $queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT)
+                    ),
+                    $queryBuilder->expr()->eq(
+                        't3ver_wsid',
+                        $queryBuilder->createNamedParameter($workspace, \PDO::PARAM_INT)
+                    )
+                )
+                ->setMaxResults(1)
+                ->execute()
+                ->fetch();
+
+            if (is_array($row)) {
+                return $row;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * Select the version of a record for a workspace
+     *
+     * @param int $workspace Workspace ID
+     * @param string $table Table name to select from
+     * @param int $uid Record uid for which to find workspace version.
+     * @param string $fields Field list to select
+     * @param bool $bypassEnableFieldsCheck If TRUE, enablefields are not checked for.
+     * @return mixed If found, return record, otherwise other value: Returns 1 if version was sought for but not found, returns -1/-2 if record (offline/online) existed but had enableFields that would disable it. Returns FALSE if not in workspace or no versioning for record. Notice, that the enablefields of the online record is also tested.
+     * @see BackendUtility::getWorkspaceVersionOfRecord()
+     */
+    public function getWorkspaceVersionOfRecord($workspace, $table, $uid, $fields = '*', $bypassEnableFieldsCheck = false)
+    {
+        if ($workspace !== 0 && !empty($GLOBALS['TCA'][$table]['ctrl']['versioningWS'])) {
+            $workspace = (int)$workspace;
+            $uid = (int)$uid;
+            // Select workspace version of record, only testing for deleted.
+            $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table);
+            $queryBuilder->getRestrictions()
+                ->removeAll()
+                ->add(GeneralUtility::makeInstance(DeletedRestriction::class));
+
+            $newrow = $queryBuilder->select(...GeneralUtility::trimExplode(',', $fields, true))
+                ->from($table)
+                ->where(
+                    $queryBuilder->expr()->eq('pid', $queryBuilder->createNamedParameter(-1, \PDO::PARAM_INT)),
+                    $queryBuilder->expr()->eq(
+                        't3ver_oid',
+                        $queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT)
+                    ),
+                    $queryBuilder->expr()->eq(
+                        't3ver_wsid',
+                        $queryBuilder->createNamedParameter($workspace, \PDO::PARAM_INT)
+                    )
+                )
+                ->setMaxResults(1)
+                ->execute()
+                ->fetch();
+
+            // If version found, check if it could have been selected with enableFields on
+            // as well:
+            $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table);
+            $queryBuilder->setRestrictions(GeneralUtility::makeInstance(FrontendRestrictionContainer::class));
+            // Remove the frontend workspace restriction because we are testing a version record
+            $queryBuilder->getRestrictions()->removeByType(FrontendWorkspaceRestriction::class);
+            $queryBuilder->select('uid')
+                ->from($table)
+                ->setMaxResults(1);
+
+            if (is_array($newrow)) {
+                $queryBuilder->where(
+                    $queryBuilder->expr()->eq('pid', $queryBuilder->createNamedParameter(-1, \PDO::PARAM_INT)),
+                    $queryBuilder->expr()->eq(
+                        't3ver_oid',
+                        $queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT)
+                    ),
+                    $queryBuilder->expr()->eq(
+                        't3ver_wsid',
+                        $queryBuilder->createNamedParameter($workspace, \PDO::PARAM_INT)
+                    )
+                );
+                if ($bypassEnableFieldsCheck || $queryBuilder->execute()->fetchColumn()) {
+                    // Return offline version, tested for its enableFields.
+                    return $newrow;
+                }
+                // Return -1 because offline version was de-selected due to its enableFields.
+                return -1;
+            }
+            // OK, so no workspace version was found. Then check if online version can be
+            // selected with full enable fields and if so, return 1:
+            $queryBuilder->where(
+                $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT))
+                );
+            if ($bypassEnableFieldsCheck || $queryBuilder->execute()->fetchColumn()) {
+                // Means search was done, but no version found.
+                return 1;
+            }
+            // Return -2 because the online record was de-selected due to its enableFields.
+            return -2;
+        }
+        // No look up in database because versioning not enabled / or workspace not
+        // offline
+        return false;
+    }
+
+    /**
+     * Purges computed properties from database rows,
+     * such as _ORIG_uid or _ORIG_pid for instance.
+     *
+     * @param array $row
+     * @return array
+     */
+    protected function purgeComputedProperties(array $row)
+    {
+        foreach ($this->computedPropertyNames as $computedPropertyName) {
+            if (array_key_exists($computedPropertyName, $row)) {
+                unset($row[$computedPropertyName]);
+            }
+        }
+        return $row;
+    }
+
+    /**
+     * @return VariableFrontend
+     */
+    protected function getRuntimeCache(): VariableFrontend
+    {
+        return GeneralUtility::makeInstance(CacheManager::class)->getCache('runtime');
+    }
+}
diff --git a/typo3/sysext/core/Classes/Domain/Repository/PageRepositoryGetPageHookInterface.php b/typo3/sysext/core/Classes/Domain/Repository/PageRepositoryGetPageHookInterface.php
new file mode 100644 (file)
index 0000000..6c2fff1
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+namespace TYPO3\CMS\Core\Domain\Repository;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+/**
+ * Interface for classes which hook into pageSelect and do additional getPage processing
+ */
+interface PageRepositoryGetPageHookInterface
+{
+    /**
+     * Modifies the DB params
+     *
+     * @param int $uid The page ID
+     * @param bool $disableGroupAccessCheck If set, the check for group access is disabled. VERY rarely used
+     * @param PageRepository $parentObject Parent object
+     */
+    public function getPage_preProcess(&$uid, &$disableGroupAccessCheck, PageRepository $parentObject);
+}
diff --git a/typo3/sysext/core/Classes/Domain/Repository/PageRepositoryGetPageOverlayHookInterface.php b/typo3/sysext/core/Classes/Domain/Repository/PageRepositoryGetPageOverlayHookInterface.php
new file mode 100644 (file)
index 0000000..db2b17d
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+namespace TYPO3\CMS\Core\Domain\Repository;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+/**
+ * Interface for classes which hook into \TYPO3\CMS\Core\Domain\Repository\PageRepository
+ */
+interface PageRepositoryGetPageOverlayHookInterface
+{
+    /**
+     * enables to preprocess the pageoverlay
+     *
+     * @param array $pageInput The page record
+     * @param int $lUid The overlay language
+     * @param PageRepository $parent The calling parent object
+     */
+    public function getPageOverlay_preProcess(&$pageInput, &$lUid, PageRepository $parent);
+}
diff --git a/typo3/sysext/core/Classes/Domain/Repository/PageRepositoryGetRecordOverlayHookInterface.php b/typo3/sysext/core/Classes/Domain/Repository/PageRepositoryGetRecordOverlayHookInterface.php
new file mode 100644 (file)
index 0000000..1892da1
--- /dev/null
@@ -0,0 +1,43 @@
+<?php
+namespace TYPO3\CMS\Core\Domain\Repository;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+/**
+ * Interface for classes which hook into \TYPO3\CMS\Core\Domain\Repository\PageRepository
+ */
+interface PageRepositoryGetRecordOverlayHookInterface
+{
+    /**
+     * Enables to preprocess a record overlay
+     *
+     * @param string $table
+     * @param array $row
+     * @param int $sys_language_content
+     * @param string $OLmode
+     * @param PageRepository $parent
+     */
+    public function getRecordOverlay_preProcess($table, &$row, &$sys_language_content, $OLmode, PageRepository $parent);
+
+    /**
+     * Enables to postprocess a record overlay
+     *
+     * @param string $table
+     * @param array $row
+     * @param int $sys_language_content
+     * @param string $OLmode
+     * @param PageRepository $parent
+     */
+    public function getRecordOverlay_postProcess($table, &$row, &$sys_language_content, $OLmode, PageRepository $parent);
+}
diff --git a/typo3/sysext/core/Classes/Domain/Repository/PageRepositoryInitHookInterface.php b/typo3/sysext/core/Classes/Domain/Repository/PageRepositoryInitHookInterface.php
new file mode 100644 (file)
index 0000000..775fdf5
--- /dev/null
@@ -0,0 +1,28 @@
+<?php
+namespace TYPO3\CMS\Core\Domain\Repository;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+/**
+ * Interface for classes which hook into pageSelect and do additional getPage processing
+ */
+interface PageRepositoryInitHookInterface
+{
+    /**
+     * Modifies the DB params
+     *
+     * @param PageRepository $parentObject Parent object
+     */
+    public function init_postProcess(PageRepository $parentObject);
+}
index 9f07560..11abd25 100644 (file)
@@ -20,9 +20,9 @@ use TYPO3\CMS\Core\Context\Context;
 use TYPO3\CMS\Core\Context\LanguageAspectFactory;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Database\Query\QueryBuilder;
+use TYPO3\CMS\Core\Domain\Repository\PageRepository;
 use TYPO3\CMS\Core\Site\SiteLanguageAwareTrait;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Frontend\Page\PageRepository;
 
 /**
  * Classic usage when using a "URL segment" (e.g. slug) field within a database table.
index d82e36b..4fe35c0 100644 (file)
@@ -20,9 +20,9 @@ use TYPO3\CMS\Core\Context\Context;
 use TYPO3\CMS\Core\Context\LanguageAspectFactory;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Database\Query\QueryBuilder;
+use TYPO3\CMS\Core\Domain\Repository\PageRepository;
 use TYPO3\CMS\Core\Site\SiteLanguageAwareTrait;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Frontend\Page\PageRepository;
 
 /**
  * Very useful for building an a path segment from a combined value of the database.
index 8c1bd8b..a9ab8fa 100644 (file)
@@ -28,6 +28,7 @@ use TYPO3\CMS\Core\Context\LanguageAspectFactory;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
 use TYPO3\CMS\Core\Database\Query\Restriction\FrontendWorkspaceRestriction;
+use TYPO3\CMS\Core\Domain\Repository\PageRepository;
 use TYPO3\CMS\Core\Exception\SiteNotFoundException;
 use TYPO3\CMS\Core\Http\NormalizedParams;
 use TYPO3\CMS\Core\Http\Uri;
@@ -44,7 +45,6 @@ use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
 use TYPO3\CMS\Core\Site\SiteFinder;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Frontend\Page\CacheHashCalculator;
-use TYPO3\CMS\Frontend\Page\PageRepository;
 
 /**
  * Page Router - responsible for a page based on a request, by looking up the slug of the page path.
index fc61166..ea8896e 100644 (file)
@@ -21,13 +21,13 @@ use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Database\Query\Restriction\AbstractRestrictionContainer;
 use TYPO3\CMS\Core\Database\Query\Restriction\DefaultRestrictionContainer;
 use TYPO3\CMS\Core\Database\Query\Restriction\HiddenRestriction;
+use TYPO3\CMS\Core\Domain\Repository\PageRepository;
 use TYPO3\CMS\Core\Package\PackageManager;
 use TYPO3\CMS\Core\TimeTracker\TimeTracker;
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Frontend\Configuration\TypoScript\ConditionMatching\ConditionMatcher;
 use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
-use TYPO3\CMS\Frontend\Page\PageRepository;
 
 /**
  * Template object that is responsible for generating the TypoScript template based on template records.
index 3b624bf..3459edc 100644 (file)
@@ -21,13 +21,13 @@ use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Database\Query\QueryBuilder;
 use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
 use TYPO3\CMS\Core\Database\Query\Restriction\HiddenRestriction;
+use TYPO3\CMS\Core\Domain\Repository\PageRepository;
 use TYPO3\CMS\Core\Exception\Page\BrokenRootLineException;
 use TYPO3\CMS\Core\Exception\Page\CircularRootLineException;
 use TYPO3\CMS\Core\Exception\Page\MountPointsDisabledException;
 use TYPO3\CMS\Core\Exception\Page\PageNotFoundException;
 use TYPO3\CMS\Core\Exception\Page\PagePropertyRelationNotFoundException;
 use TYPO3\CMS\Core\Versioning\VersionState;
-use TYPO3\CMS\Frontend\Page\PageRepository;
 
 /**
  * A utility resolving and Caching the Rootline generation
index 1bafc80..af34903 100644 (file)
@@ -82,12 +82,12 @@ return [
                     ],
                     [
                         'LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf:doktype.I.0',
-                        (string)\TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_DEFAULT,
+                        (string)\TYPO3\CMS\Core\Domain\Repository\PageRepository::DOKTYPE_DEFAULT,
                         'apps-pagetree-page-default'
                     ],
                     [
                         'LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.doktype.I.4',
-                        (string)\TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_BE_USER_SECTION,
+                        (string)\TYPO3\CMS\Core\Domain\Repository\PageRepository::DOKTYPE_BE_USER_SECTION,
                         'apps-pagetree-page-backend-users'
                     ],
                     [
@@ -96,17 +96,17 @@ return [
                     ],
                     [
                         'LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.doktype.I.2',
-                        (string)\TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_SHORTCUT,
+                        (string)\TYPO3\CMS\Core\Domain\Repository\PageRepository::DOKTYPE_SHORTCUT,
                         'apps-pagetree-page-shortcut'
                     ],
                     [
                         'LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.doktype.I.5',
-                        (string)\TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_MOUNTPOINT,
+                        (string)\TYPO3\CMS\Core\Domain\Repository\PageRepository::DOKTYPE_MOUNTPOINT,
                         'apps-pagetree-page-mountpoint'
                     ],
                     [
                         'LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.doktype.I.8',
-                        (string)\TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_LINK,
+                        (string)\TYPO3\CMS\Core\Domain\Repository\PageRepository::DOKTYPE_LINK,
                         'apps-pagetree-page-shortcut-external'
                     ],
                     [
@@ -115,21 +115,21 @@ return [
                     ],
                     [
                         'LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf:doktype.I.folder',
-                        (string)\TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_SYSFOLDER,
+                        (string)\TYPO3\CMS\Core\Domain\Repository\PageRepository::DOKTYPE_SYSFOLDER,
                         'apps-pagetree-folder-default'
                     ],
                     [
                         'LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf:doktype.I.2',
-                        (string)\TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_RECYCLER,
+                        (string)\TYPO3\CMS\Core\Domain\Repository\PageRepository::DOKTYPE_RECYCLER,
                         'apps-filetree-folder-recycler'
                     ],
                     [
                         'LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.doktype.I.7',
-                        (string)\TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_SPACER,
+                        (string)\TYPO3\CMS\Core\Domain\Repository\PageRepository::DOKTYPE_SPACER,
                         'apps-pagetree-spacer'
                     ]
                 ],
-                'default' => (string)\TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_DEFAULT,
+                'default' => (string)\TYPO3\CMS\Core\Domain\Repository\PageRepository::DOKTYPE_DEFAULT,
             ]
         ],
         'title' => [
@@ -581,19 +581,19 @@ return [
                 'items' => [
                     [
                         'LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.shortcut_mode.I.0',
-                        \TYPO3\CMS\Frontend\Page\PageRepository::SHORTCUT_MODE_NONE
+                        \TYPO3\CMS\Core\Domain\Repository\PageRepository::SHORTCUT_MODE_NONE
                     ],
                     [
                         'LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.shortcut_mode.I.1',
-                        \TYPO3\CMS\Frontend\Page\PageRepository::SHORTCUT_MODE_FIRST_SUBPAGE
+                        \TYPO3\CMS\Core\Domain\Repository\PageRepository::SHORTCUT_MODE_FIRST_SUBPAGE
                     ],
                     [
                         'LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.shortcut_mode.I.2',
-                        \TYPO3\CMS\Frontend\Page\PageRepository::SHORTCUT_MODE_RANDOM_SUBPAGE
+                        \TYPO3\CMS\Core\Domain\Repository\PageRepository::SHORTCUT_MODE_RANDOM_SUBPAGE
                     ],
                     [
                         'LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.shortcut_mode.I.3',
-                        \TYPO3\CMS\Frontend\Page\PageRepository::SHORTCUT_MODE_PARENT_PAGE
+                        \TYPO3\CMS\Core\Domain\Repository\PageRepository::SHORTCUT_MODE_PARENT_PAGE
                     ]
                 ],
                 'default' => 0,
@@ -898,7 +898,7 @@ return [
     ],
     'types' => [
         // normal
-        (string)\TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_DEFAULT => [
+        (string)\TYPO3\CMS\Core\Domain\Repository\PageRepository::DOKTYPE_DEFAULT => [
             'showitem' => '
                 --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general,
                     --palette--;;standard,
@@ -931,7 +931,7 @@ return [
             '
         ],
         // external URL
-        (string)\TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_LINK => [
+        (string)\TYPO3\CMS\Core\Domain\Repository\PageRepository::DOKTYPE_LINK => [
             'showitem' => '
                 --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general,
                     doktype,
@@ -961,7 +961,7 @@ return [
             '
         ],
         // shortcut
-        (string)\TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_SHORTCUT => [
+        (string)\TYPO3\CMS\Core\Domain\Repository\PageRepository::DOKTYPE_SHORTCUT => [
             'showitem' => '
                 --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general,
                     doktype,
@@ -992,7 +992,7 @@ return [
             '
         ],
         // mount page
-        (string)\TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_MOUNTPOINT => [
+        (string)\TYPO3\CMS\Core\Domain\Repository\PageRepository::DOKTYPE_MOUNTPOINT => [
             'showitem' => '
                 --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general,
                     doktype,
@@ -1023,7 +1023,7 @@ return [
             '
         ],
         // spacer
-        (string)\TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_SPACER => [
+        (string)\TYPO3\CMS\Core\Domain\Repository\PageRepository::DOKTYPE_SPACER => [
             'showitem' => '
                 --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general,
                     --palette--;;standard,
@@ -1043,7 +1043,7 @@ return [
             '
         ],
         // Folder
-        (string)\TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_SYSFOLDER => [
+        (string)\TYPO3\CMS\Core\Domain\Repository\PageRepository::DOKTYPE_SYSFOLDER => [
             'showitem' => '
                 --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general,
                     --palette--;;standard,
@@ -1066,7 +1066,7 @@ return [
             '
         ],
         // Trash
-        (string)\TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_RECYCLER => [
+        (string)\TYPO3\CMS\Core\Domain\Repository\PageRepository::DOKTYPE_RECYCLER => [
             'showitem' => '
                 --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general,
                     --palette--;;standard,
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-88746-PageRepositoryPHPClassMovedFromFrontendToCoreExtension.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-88746-PageRepositoryPHPClassMovedFromFrontendToCoreExtension.rst
new file mode 100644 (file)
index 0000000..6aab7f6
--- /dev/null
@@ -0,0 +1,50 @@
+.. include:: ../../Includes.txt
+
+====================================================================================
+Deprecation: #88746 - PageRepository PHP class moved from Frontend to Core Extension
+====================================================================================
+
+See :issue:`88746`
+
+Description
+===========
+
+In previous TYPO3 versions, accessing records was mixed between Frontend (handled by PageRepository)
+and Backend (handled by static methods in BackendUtility). In TYPO3 v9, the Context API was introduced
+and PageRepository now acts as a strong database accessor which is not bound to Frontend anymore,
+at all.
+
+In addition, various places of the backend also used PageRepository already, which violated the
+separation of packages, as TYPO3 Core aims to strictly separate Frontend and Backend application
+coe.
+
+In the case of PageRepository, the code is used by both applications, and is therefore moved
+to Core system extension (EXT:core), and renamed to `TYPO3\CMS\Core\Domain\Repository\PageRepository`.
+
+Until TYPO3 v9, it was placed in `TYPO3\CMS\Frontend\Page\PageRepository`.
+
+In addition, all interface'd hooks are moved to EXT:core as well with the same PHP namespace.
+
+
+Impact
+======
+
+A class alias was introduced which does not trigger any deprecations, so both variants
+still work as before, however it is recommended to rename any calls to the PHP class.
+
+No other functionality was changed.
+
+
+Affected Installations
+======================
+
+Any TYPO3 installation with custom PHP extensions accessing PageRepository directly.
+
+
+Migration
+=========
+
+Replace any PHP references of :php:`TYPO3\CMS\Frontend\Page\PageRepository`
+to :php:`TYPO3\CMS\Core\Domain\Repository\PageRepository` in any custom PHP code.
+
+.. index:: Frontend, PHP-API, FullyScanned, ext:frontend
\ No newline at end of file
diff --git a/typo3/sysext/core/Migrations/Code/ClassAliasMap.php b/typo3/sysext/core/Migrations/Code/ClassAliasMap.php
new file mode 100644 (file)
index 0000000..d0cd072
--- /dev/null
@@ -0,0 +1,8 @@
+<?php
+return [
+    'TYPO3\\CMS\\Frontend\\Page\\PageRepository' => \TYPO3\CMS\Core\Domain\Repository\PageRepository::class,
+    'TYPO3\\CMS\\Frontend\\Page\\PageRepositoryGetPageHookInterface' => \TYPO3\CMS\Core\Domain\Repository\PageRepositoryGetPageHookInterface::class,
+    'TYPO3\\CMS\\Frontend\\Page\\PageRepositoryGetPageOverlayHookInterface' => \TYPO3\CMS\Core\Domain\Repository\PageRepositoryGetPageOverlayHookInterface::class,
+    'TYPO3\\CMS\\Frontend\\Page\\PageRepositoryGetRecordOverlayHookInterface' => \TYPO3\CMS\Core\Domain\Repository\PageRepositoryGetRecordOverlayHookInterface::class,
+    'TYPO3\\CMS\\Frontend\\Page\\PageRepositoryInitHookInterface' => \TYPO3\CMS\Core\Domain\Repository\PageRepositoryInitHookInterface::class,
+];
diff --git a/typo3/sysext/core/Migrations/Code/LegacyClassesForIde.php b/typo3/sysext/core/Migrations/Code/LegacyClassesForIde.php
new file mode 100644 (file)
index 0000000..8984b80
--- /dev/null
@@ -0,0 +1,22 @@
+<?php
+namespace {
+    die('Access denied');
+}
+
+namespace TYPO3\CMS\Frontend\Page {
+    class PageRepository extends \TYPO3\CMS\Core\Domain\Repository\PageRepository
+    {
+    }
+    interface PageRepositoryGetPageHookInterface extends \TYPO3\CMS\Core\Domain\Repository\PageRepositoryGetPageHookInterface
+    {
+    }
+    interface PageRepositoryGetPageOverlayHookInterface extends \TYPO3\CMS\Core\Domain\Repository\PageRepositoryGetPageOverlayHookInterface
+    {
+    }
+    interface PageRepositoryGetRecordOverlayHookInterface extends \TYPO3\CMS\Core\Domain\Repository\PageRepositoryGetRecordOverlayHookInterface
+    {
+    }
+    interface PageRepositoryInitHookInterface extends \TYPO3\CMS\Core\Domain\Repository\PageRepositoryInitHookInterface
+    {
+    }
+}
diff --git a/typo3/sysext/core/Tests/Functional/Domain/Repository/PageRepositoryTest.php b/typo3/sysext/core/Tests/Functional/Domain/Repository/PageRepositoryTest.php
new file mode 100644 (file)
index 0000000..0104249
--- /dev/null
@@ -0,0 +1,530 @@
+<?php
+namespace TYPO3\CMS\Core\Tests\Functional\Domain\Repository;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+use Prophecy\Argument;
+use TYPO3\CMS\Core\Context\Context;
+use TYPO3\CMS\Core\Context\LanguageAspect;
+use TYPO3\CMS\Core\Context\WorkspaceAspect;
+use TYPO3\CMS\Core\Database\ConnectionPool;
+use TYPO3\CMS\Core\Domain\Repository\PageRepository;
+use TYPO3\CMS\Core\Domain\Repository\PageRepositoryGetPageHookInterface;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+
+/**
+ * Test case
+ */
+class PageRepositoryTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTestCase
+{
+    protected $coreExtensionsToLoad = ['frontend'];
+
+    protected function setUp(): void
+    {
+        parent::setUp();
+        $this->importDataSet(__DIR__ . '/../../Fixtures/pages.xml');
+    }
+
+    /**
+     * @test
+     */
+    public function getMenuSingleUidRoot()
+    {
+        $subject = new PageRepository();
+        $rows = $subject->getMenu(1, 'uid, title');
+        $this->assertArrayHasKey(2, $rows);
+        $this->assertArrayHasKey(3, $rows);
+        $this->assertArrayHasKey(4, $rows);
+        $this->assertCount(3, $rows);
+    }
+
+    /**
+     * @test
+     */
+    public function getMenuSingleUidSubpage()
+    {
+        $subject = new PageRepository();
+        $rows = $subject->getMenu(2, 'uid, title');
+        $this->assertArrayHasKey(5, $rows);
+        $this->assertArrayHasKey(6, $rows);
+        $this->assertArrayHasKey(7, $rows);
+        $this->assertCount(3, $rows);
+    }
+
+    /**
+     * @test
+     */
+    public function getMenuMultipleUid()
+    {
+        $subject = new PageRepository();
+        $rows = $subject->getMenu([2, 3], 'uid, title');
+        $this->assertArrayHasKey(5, $rows);
+        $this->assertArrayHasKey(6, $rows);
+        $this->assertArrayHasKey(7, $rows);
+        $this->assertArrayHasKey(8, $rows);
+        $this->assertArrayHasKey(9, $rows);
+        $this->assertCount(5, $rows);
+    }
+
+    /**
+     * @test
+     */
+    public function getMenuPageOverlay()
+    {
+        $subject = new PageRepository(new Context([
+            'language' => new LanguageAspect(1)
+        ]));
+
+        $rows = $subject->getMenu([2, 3], 'uid, title');
+        $this->assertEquals('Attrappe 1-2-5', $rows[5]['title']);
+        $this->assertEquals('Attrappe 1-2-6', $rows[6]['title']);
+        $this->assertEquals('Dummy 1-2-7', $rows[7]['title']);
+        $this->assertEquals('Dummy 1-3-8', $rows[8]['title']);
+        $this->assertEquals('Attrappe 1-3-9', $rows[9]['title']);
+        $this->assertCount(5, $rows);
+    }
+
+    /**
+     * @test
+     */
+    public function getPageOverlayById()
+    {
+        $subject = new PageRepository();
+        $row = $subject->getPageOverlay(1, 1);
+        $this->assertOverlayRow($row);
+        $this->assertEquals('Wurzel 1', $row['title']);
+        $this->assertEquals('901', $row['_PAGES_OVERLAY_UID']);
+        $this->assertEquals(1, $row['_PAGES_OVERLAY_LANGUAGE']);
+    }
+
+    /**
+     * @test
+     */
+    public function getPageOverlayByIdWithoutTranslation()
+    {
+        $subject = new PageRepository();
+        $row = $subject->getPageOverlay(4, 1);
+        $this->assertIsArray($row);
+        $this->assertCount(0, $row);
+    }
+
+    /**
+     * @test
+     */
+    public function getPageOverlayByRow()
+    {
+        $subject = new PageRepository();
+        $orig = $subject->getPage(1);
+        $row = $subject->getPageOverlay($orig, 1);
+        $this->assertOverlayRow($row);
+        $this->assertEquals(1, $row['uid']);
+        $this->assertEquals('Wurzel 1', $row['title']);
+        $this->assertEquals('901', $row['_PAGES_OVERLAY_UID']);
+        $this->assertEquals(1, $row['_PAGES_OVERLAY_LANGUAGE']);
+    }
+
+    /**
+     * @test
+     */
+    public function getPageOverlayByRowWithoutTranslation()
+    {
+        $subject = new PageRepository();
+        $orig = $subject->getPage(4);
+        $row = $subject->getPageOverlay($orig, 1);
+        $this->assertIsArray($row);
+        $this->assertEquals(4, $row['uid']);
+        $this->assertEquals('Dummy 1-4', $row['title']);//original title
+    }
+
+    /**
+     * @test
+     */
+    public function getPagesOverlayByIdSingle()
+    {
+        $subject = new PageRepository(new Context([
+            'language' => new LanguageAspect(1)
+        ]));
+        $rows = $subject->getPagesOverlay([1]);
+        $this->assertIsArray($rows);
+        $this->assertCount(1, $rows);
+        $this->assertArrayHasKey(0, $rows);
+
+        $row = $rows[0];
+        $this->assertOverlayRow($row);
+        $this->assertEquals('Wurzel 1', $row['title']);
+        $this->assertEquals('901', $row['_PAGES_OVERLAY_UID']);
+        $this->assertEquals(1, $row['_PAGES_OVERLAY_LANGUAGE']);
+    }
+
+    /**
+     * @test
+     */
+    public function getPagesOverlayByIdMultiple()
+    {
+        $subject = new PageRepository(new Context([
+            'language' => new LanguageAspect(1)
+        ]));
+        $rows = $subject->getPagesOverlay([1, 5]);
+        $this->assertIsArray($rows);
+        $this->assertCount(2, $rows);
+        $this->assertArrayHasKey(0, $rows);
+        $this->assertArrayHasKey(1, $rows);
+
+        $row = $rows[0];
+        $this->assertOverlayRow($row);
+        $this->assertEquals('Wurzel 1', $row['title']);
+        $this->assertEquals('901', $row['_PAGES_OVERLAY_UID']);
+        $this->assertEquals(1, $row['_PAGES_OVERLAY_LANGUAGE']);
+
+        $row = $rows[1];
+        $this->assertOverlayRow($row);
+        $this->assertEquals('Attrappe 1-2-5', $row['title']);
+        $this->assertEquals('904', $row['_PAGES_OVERLAY_UID']);
+        $this->assertEquals(1, $row['_PAGES_OVERLAY_LANGUAGE']);
+    }
+
+    /**
+     * @test
+     */
+    public function getPagesOverlayByIdMultipleSomeNotOverlaid()
+    {
+        $subject = new PageRepository(new Context([
+            'language' => new LanguageAspect(1)
+        ]));
+        $rows = $subject->getPagesOverlay([1, 4, 5, 8]);
+        $this->assertIsArray($rows);
+        $this->assertCount(2, $rows);
+        $this->assertArrayHasKey(0, $rows);
+        $this->assertArrayHasKey(2, $rows);
+
+        $row = $rows[0];
+        $this->assertOverlayRow($row);
+        $this->assertEquals('Wurzel 1', $row['title']);
+
+        $row = $rows[2];
+        $this->assertOverlayRow($row);
+        $this->assertEquals('Attrappe 1-2-5', $row['title']);
+    }
+
+    /**
+     * @test
+     */
+    public function getPagesOverlayByRowSingle()
+    {
+        $subject = new PageRepository();
+        $origRow = $subject->getPage(1);
+
+        $subject = new PageRepository(new Context([
+            'language' => new LanguageAspect(1)
+        ]));
+        $rows = $subject->getPagesOverlay([$origRow]);
+        $this->assertIsArray($rows);
+        $this->assertCount(1, $rows);
+        $this->assertArrayHasKey(0, $rows);
+
+        $row = $rows[0];
+        $this->assertOverlayRow($row);
+        $this->assertEquals('Wurzel 1', $row['title']);
+        $this->assertEquals('901', $row['_PAGES_OVERLAY_UID']);
+        $this->assertEquals(1, $row['_PAGES_OVERLAY_LANGUAGE']);
+    }
+
+    /**
+     * @test
+     */
+    public function getPagesOverlayByRowMultiple()
+    {
+        $subject = new PageRepository();
+        $orig1 = $subject->getPage(1);
+        $orig2 = $subject->getPage(5);
+
+        $subject = new PageRepository(new Context([
+            'language' => new LanguageAspect(1)
+        ]));
+        $rows = $subject->getPagesOverlay([1 => $orig1, 5 => $orig2]);
+        $this->assertIsArray($rows);
+        $this->assertCount(2, $rows);
+        $this->assertArrayHasKey(1, $rows);
+        $this->assertArrayHasKey(5, $rows);
+
+        $row = $rows[1];
+        $this->assertOverlayRow($row);
+        $this->assertEquals('Wurzel 1', $row['title']);
+        $this->assertEquals('901', $row['_PAGES_OVERLAY_UID']);
+        $this->assertEquals(1, $row['_PAGES_OVERLAY_LANGUAGE']);
+
+        $row = $rows[5];
+        $this->assertOverlayRow($row);
+        $this->assertEquals('Attrappe 1-2-5', $row['title']);
+        $this->assertEquals('904', $row['_PAGES_OVERLAY_UID']);
+        $this->assertEquals(1, $row['_PAGES_OVERLAY_LANGUAGE']);
+    }
+
+    /**
+     * @test
+     */
+    public function getPagesOverlayByRowMultipleSomeNotOverlaid()
+    {
+        $subject = new PageRepository();
+        $orig1 = $subject->getPage(1);
+        $orig2 = $subject->getPage(7);
+        $orig3 = $subject->getPage(9);
+
+        $subject = new PageRepository(new Context([
+            'language' => new LanguageAspect(1)
+        ]));
+        $rows = $subject->getPagesOverlay([$orig1, $orig2, $orig3]);
+        $this->assertIsArray($rows);
+        $this->assertCount(3, $rows);
+        $this->assertArrayHasKey(0, $rows);
+        $this->assertArrayHasKey(1, $rows);
+        $this->assertArrayHasKey(2, $rows);
+
+        $row = $rows[0];
+        $this->assertOverlayRow($row);
+        $this->assertEquals('Wurzel 1', $row['title']);
+
+        $row = $rows[1];
+        $this->assertNotOverlayRow($row);
+        $this->assertEquals('Dummy 1-2-7', $row['title']);
+
+        $row = $rows[2];
+        $this->assertOverlayRow($row);
+        $this->assertEquals('Attrappe 1-3-9', $row['title']);
+    }
+
+    /**
+     * Tests whether the getPage Hook is called correctly.
+     *
+     * @test
+     */
+    public function isGetPageHookCalled()
+    {
+        // Create a hook mock object
+        $getPageHookProphet = $this->prophesize(\stdClass::class);
+        $getPageHookProphet->willImplement(PageRepositoryGetPageHookInterface::class);
+        $getPageHookProphet->getPage_preProcess(42, false, Argument::type(PageRepository::class))->shouldBeCalled();
+        $getPageHookMock = $getPageHookProphet->reveal();
+        $className = get_class($getPageHookMock);
+
+        // Register hook mock object
+        GeneralUtility::addInstance($className, $getPageHookMock);
+        $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_page.php']['getPage'][] = $className;
+        $subject = new PageRepository();
+        $subject->getPage(42, false);
+    }
+
+    /**
+     * @test
+     */
+    public function initSetsPublicPropertyCorrectlyForWorkspacePreview()
+    {
+        $workspaceId = 2;
+        $subject = new PageRepository(new Context([
+            'workspace' => new WorkspaceAspect($workspaceId)
+        ]));
+
+        $connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('pages');
+
+        $expectedSQL = sprintf(
+            ' AND (%s = 0) AND ((%s = 0) OR (%s = 2)) AND (%s < 200)',
+            $connection->quoteIdentifier('pages.deleted'),
+            $connection->quoteIdentifier('pages.t3ver_wsid'),
+            $connection->quoteIdentifier('pages.t3ver_wsid'),
+            $connection->quoteIdentifier('pages.doktype')
+        );
+
+        $this->assertSame($expectedSQL, $subject->where_hid_del);
+    }
+
+    /**
+     * @test
+     */
+    public function initSetsPublicPropertyCorrectlyForLive()
+    {
+        $GLOBALS['SIM_ACCESS_TIME'] = 123;
+
+        $subject = new PageRepository(new Context());
+
+        $connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('pages');
+        $expectedSQL = sprintf(
+            ' AND ((%s = 0) AND (%s <= 0) AND (%s <> -1) AND (%s = 0) AND (%s <= 123) AND ((%s = 0) OR (%s > 123))) AND (%s < 200)',
+            $connection->quoteIdentifier('pages.deleted'),
+            $connection->quoteIdentifier('pages.t3ver_state'),
+            $connection->quoteIdentifier('pages.pid'),
+            $connection->quoteIdentifier('pages.hidden'),
+            $connection->quoteIdentifier('pages.starttime'),
+            $connection->quoteIdentifier('pages.endtime'),
+            $connection->quoteIdentifier('pages.endtime'),
+            $connection->quoteIdentifier('pages.doktype')
+        );
+
+        $this->assertSame($expectedSQL, $subject->where_hid_del);
+    }
+
+    ////////////////////////////////
+    // Tests concerning workspaces
+    ////////////////////////////////
+
+    /**
+     * @test
+     */
+    public function previewShowsPagesFromLiveAndCurrentWorkspace()
+    {
+        // initialization
+        $wsid = 987654321;
+        // simulate calls from \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController->fetch_the_id()
+        $subject = new PageRepository(new Context([
+            'workspace' => new WorkspaceAspect($wsid)
+        ]));
+
+        $pageRec = $subject->getPage(11);
+
+        $this->assertEquals(11, $pageRec['uid']);
+        $this->assertEquals(11, $pageRec['t3ver_oid']);
+        $this->assertEquals(987654321, $pageRec['t3ver_wsid']);
+        $this->assertEquals(-1, $pageRec['t3ver_state']);
+    }
+
+    /**
+     * @test
+     */
+    public function getWorkspaceVersionReturnsTheCorrectMethod()
+    {
+        // initialization
+        $wsid = 987654321;
+
+        // simulate calls from \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController->fetch_the_id()
+        $subject = new PageRepository(new Context([
+            'workspace' => new WorkspaceAspect($wsid)
+        ]));
+
+        $pageRec = $subject->getWorkspaceVersionOfRecord($wsid, 'pages', 11);
+
+        $this->assertEquals(12, $pageRec['uid']);
+        $this->assertEquals(11, $pageRec['t3ver_oid']);
+        $this->assertEquals(987654321, $pageRec['t3ver_wsid']);
+        $this->assertEquals(-1, $pageRec['t3ver_state']);
+    }
+
+    ////////////////////////////////
+    // Tests concerning versioning
+    ////////////////////////////////
+
+    /**
+     * @test
+     */
+    public function enableFieldsHidesVersionedRecordsAndPlaceholders()
+    {
+        $table = $this->getUniqueId('aTable');
+        $GLOBALS['TCA'][$table] = [
+            'ctrl' => [
+                'versioningWS' => true
+            ]
+        ];
+
+        $subject = new PageRepository(new Context());
+
+        $conditions = $subject->enableFields($table);
+        $connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable($table);
+
+        $this->assertThat(
+            $conditions,
+            $this->stringContains(' AND (' . $connection->quoteIdentifier($table . '.t3ver_state') . ' <= 0)'),
+            'Versioning placeholders'
+        );
+        $this->assertThat(
+            $conditions,
+            $this->stringContains(' AND (' . $connection->quoteIdentifier($table . '.pid') . ' <> -1)'),
+            'Records from page -1'
+        );
+    }
+
+    /**
+     * @test
+     */
+    public function enableFieldsDoesNotHidePlaceholdersInPreview()
+    {
+        $table = $this->getUniqueId('aTable');
+        $GLOBALS['TCA'][$table] = [
+            'ctrl' => [
+                'versioningWS' => true
+            ]
+        ];
+
+        $subject = new PageRepository(new Context([
+            'workspace' => new WorkspaceAspect(13)
+        ]));
+
+        $conditions = $subject->enableFields($table);
+        $connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable($table);
+
+        $this->assertThat(
+            $conditions,
+            $this->logicalNot($this->stringContains(' AND (' . $connection->quoteIdentifier($table . '.t3ver_state') . ' <= 0)')),
+            'No versioning placeholders'
+        );
+        $this->assertThat(
+            $conditions,
+            $this->stringContains(' AND (' . $connection->quoteIdentifier($table . '.pid') . ' <> -1)'),
+            'Records from page -1'
+        );
+    }
+
+    /**
+     * @test
+     */
+    public function enableFieldsDoesFilterToCurrentAndLiveWorkspaceForRecordsInPreview()
+    {
+        $table = $this->getUniqueId('aTable');
+        $GLOBALS['TCA'][$table] = [
+            'ctrl' => [
+                'versioningWS' => true
+            ]
+        ];
+
+        $subject = new PageRepository(new Context([
+            'workspace' => new WorkspaceAspect(2)
+        ]));
+
+        $conditions = $subject->enableFields($table);
+        $connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable($table);
+
+        $this->assertThat(
+            $conditions,
+            $this->stringContains(' AND ((' . $connection->quoteIdentifier($table . '.t3ver_wsid') . ' = 0) OR (' . $connection->quoteIdentifier($table . '.t3ver_wsid') . ' = 2))'),
+            'No versioning placeholders'
+        );
+    }
+
+    protected function assertOverlayRow($row)
+    {
+        $this->assertIsArray($row);
+
+        $this->assertArrayHasKey('_PAGES_OVERLAY', $row);
+        $this->assertArrayHasKey('_PAGES_OVERLAY_UID', $row);
+        $this->assertArrayHasKey('_PAGES_OVERLAY_LANGUAGE', $row);
+
+        $this->assertTrue($row['_PAGES_OVERLAY']);
+    }
+
+    protected function assertNotOverlayRow($row)
+    {
+        $this->assertIsArray($row);
+
+        $this->assertFalse(isset($row['_PAGES_OVERLAY']));
+        $this->assertFalse(isset($row['_PAGES_OVERLAY_UID']));
+        $this->assertFalse(isset($row['_PAGES_OVERLAY_LANGUAGE']));
+    }
+}
diff --git a/typo3/sysext/core/Tests/Functional/Fixtures/pages.xml b/typo3/sysext/core/Tests/Functional/Fixtures/pages.xml
new file mode 100644 (file)
index 0000000..d709aa3
--- /dev/null
@@ -0,0 +1,143 @@
+<?xml version="1.0" encoding="utf-8"?>
+<dataset>
+    <pages>
+        <uid>1</uid>
+        <pid>0</pid>
+        <title>Root 1</title>
+        <deleted>0</deleted>
+        <slug>/</slug>
+        <perms_everybody>15</perms_everybody>
+    </pages>
+    <pages>
+        <uid>2</uid>
+        <pid>1</pid>
+        <title>Dummy 1-2</title>
+        <deleted>0</deleted>
+        <perms_everybody>15</perms_everybody>
+    </pages>
+    <pages>
+        <uid>3</uid>
+        <pid>1</pid>
+        <title>Dummy 1-3</title>
+        <deleted>0</deleted>
+        <perms_everybody>15</perms_everybody>
+    </pages>
+    <pages>
+        <uid>4</uid>
+        <pid>1</pid>
+        <title>Dummy 1-4</title>
+        <deleted>0</deleted>
+        <perms_everybody>15</perms_everybody>
+    </pages>
+    <pages>
+        <uid>5</uid>
+        <pid>2</pid>
+        <title>Dummy 1-2-5</title>
+        <deleted>0</deleted>
+        <perms_everybody>15</perms_everybody>
+    </pages>
+    <pages>
+        <uid>6</uid>
+        <pid>2</pid>
+        <title>Dummy 1-2-6</title>
+        <deleted>0</deleted>
+        <perms_everybody>15</perms_everybody>
+    </pages>
+    <pages>
+        <uid>7</uid>
+        <pid>2</pid>
+        <title>Dummy 1-2-7</title>
+        <deleted>0</deleted>
+        <perms_everybody>15</perms_everybody>
+    </pages>
+    <pages>
+        <uid>8</uid>
+        <pid>3</pid>
+        <title>Dummy 1-3-8</title>
+        <deleted>0</deleted>
+        <perms_everybody>15</perms_everybody>
+    </pages>
+    <pages>
+        <uid>9</uid>
+        <pid>3</pid>
+        <title>Dummy 1-3-9</title>
+        <deleted>0</deleted>
+        <perms_everybody>15</perms_everybody>
+    </pages>
+    <pages>
+        <uid>10</uid>
+        <pid>4</pid>
+        <title>Dummy 1-4-10</title>
+        <deleted>0</deleted>
+        <perms_everybody>15</perms_everybody>
+    </pages>
+    <pages>
+        <uid>11</uid>
+        <pid>0</pid>
+        <title>Workspace Root</title>
+        <deleted>0</deleted>
+        <t3ver_oid>0</t3ver_oid>
+        <t3ver_wsid>987654321</t3ver_wsid>
+        <t3ver_state>1</t3ver_state>
+        <perms_everybody>15</perms_everybody>
+    </pages>
+    <pages>
+        <uid>12</uid>
+        <pid>-1</pid>
+        <title>Workspace Root</title>
+        <deleted>0</deleted>
+        <t3ver_oid>11</t3ver_oid>
+        <t3ver_wsid>987654321</t3ver_wsid>
+        <t3ver_state>-1</t3ver_state>
+        <perms_everybody>15</perms_everybody>
+    </pages>
+
+    <pages>
+        <uid>901</uid>
+        <pid>0</pid>
+        <l10n_parent>1</l10n_parent>
+        <sys_language_uid>1</sys_language_uid>
+        <title>Wurzel 1</title>
+        <deleted>0</deleted>
+    </pages>
+    <pages>
+        <uid>902</uid>
+        <pid>1</pid>
+        <l10n_parent>2</l10n_parent>
+        <sys_language_uid>1</sys_language_uid>
+        <title>Attrappe 1-2</title>
+        <deleted>0</deleted>
+    </pages>
+    <pages>
+        <uid>903</uid>
+        <pid>1</pid>
+        <l10n_parent>3</l10n_parent>
+        <sys_language_uid>1</sys_language_uid>
+        <title>Attrappe 1-3</title>
+        <deleted>0</deleted>
+    </pages>
+    <pages>
+        <uid>904</uid>
+        <pid>2</pid>
+        <l10n_parent>5</l10n_parent>
+        <sys_language_uid>1</sys_language_uid>
+        <title>Attrappe 1-2-5</title>
+        <deleted>0</deleted>
+    </pages>
+    <pages>
+        <uid>905</uid>
+        <pid>2</pid>
+        <l10n_parent>6</l10n_parent>
+        <sys_language_uid>1</sys_language_uid>
+        <title>Attrappe 1-2-6</title>
+        <deleted>0</deleted>
+    </pages>
+    <pages>
+        <uid>906</uid>
+        <pid>3</pid>
+        <l10n_parent>9</l10n_parent>
+        <sys_language_uid>1</sys_language_uid>
+        <title>Attrappe 1-3-9</title>
+        <deleted>0</deleted>
+    </pages>
+</dataset>
index c0a3c26..60b99fd 100644 (file)
@@ -15,9 +15,9 @@ namespace TYPO3\CMS\Core\Tests\Functional\Tca;
  */
 
 use TYPO3\CMS\Backend\Tests\Functional\Form\FormTestService;
+use TYPO3\CMS\Core\Domain\Repository\PageRepository;
 use TYPO3\CMS\Core\Localization\LanguageService;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Frontend\Page\PageRepository;
 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
 
 class PagesVisibleFieldsTest extends FunctionalTestCase
diff --git a/typo3/sysext/core/Tests/Unit/Domain/Repository/PageRepositoryTest.php b/typo3/sysext/core/Tests/Unit/Domain/Repository/PageRepositoryTest.php
new file mode 100644 (file)
index 0000000..602ca08
--- /dev/null
@@ -0,0 +1,118 @@
+<?php
+namespace TYPO3\CMS\Core\Tests\Unit\Domain\Repository;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+use TYPO3\CMS\Core\Context\Context;
+use TYPO3\CMS\Core\Domain\Repository\PageRepository;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
+
+/**
+ * Test case
+ */
+class PageRepositoryTest extends UnitTestCase
+{
+    /**
+     * @var PageRepository|\TYPO3\TestingFramework\Core\AccessibleObjectInterface
+     */
+    protected $pageSelectObject;
+
+    protected $defaultTcaForPages = [
+        'ctrl' => [
+            'label' => 'title',
+            'tstamp' => 'tstamp',
+            'sortby' => 'sorting',
+            'type' => 'doktype',
+            'versioningWS' => true,
+            'origUid' => 't3_origuid',
+            'delete' => 'deleted',
+            'enablecolumns' => [
+                'disabled' => 'hidden',
+                'starttime' => 'starttime',
+                'endtime' => 'endtime',
+                'fe_group' => 'fe_group'
+            ],
+        ],
+        'columns' => []
+    ];
+
+    /**
+     * Sets up this testcase
+     */
+    protected function setUp(): void
+    {
+        parent::setUp();
+        $this->pageSelectObject = $this->getAccessibleMock(PageRepository::class, ['getMultipleGroupsWhereClause'], [], '', false);
+        $this->pageSelectObject->_set('context', new Context());
+        $this->pageSelectObject->expects($this->any())->method('getMultipleGroupsWhereClause')->will($this->returnValue(' AND 1=1'));
+    }
+
+    ///////////////////////////////
+    // Tests concerning getExtURL
+    ///////////////////////////////
+    /**
+     * @test
+     */
+    public function getExtUrlForDokType3UsesTheSameValue()
+    {
+        $this->assertEquals('http://www.example.com', $this->pageSelectObject->getExtURL([
+            'doktype' => PageRepository::DOKTYPE_LINK,
+            'url' => 'http://www.example.com'
+        ]));
+    }
+
+    /**
+     * @test
+     */
+    public function getExtUrlForDokType3PrependsSiteUrl()
+    {
+        $this->assertEquals(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . 'hello/world/', $this->pageSelectObject->getExtURL([
+            'doktype' => PageRepository::DOKTYPE_LINK,
+            'url' => 'hello/world/'
+        ]));
+    }
+
+    /**
+     * @test
+     */
+    public function getExtUrlForDokType3AssumesAbsoluteUrl()
+    {
+        $this->assertEquals('/hello/world/', $this->pageSelectObject->getExtURL([
+            'doktype' => PageRepository::DOKTYPE_LINK,
+            'url' => '/hello/world/'
+        ]));
+    }
+
+    /**
+     * @test
+     */
+    public function getExtUrlForDokType3UsesEmailAsSameValue()
+    {
+        $this->assertEquals('mailto:mail@typo3-test.com', $this->pageSelectObject->getExtURL([
+            'doktype' => PageRepository::DOKTYPE_LINK,
+            'url' => 'mailto:mail@typo3-test.com'
+        ]));
+    }
+
+    /**
+     * @test
+     */
+    public function getExtUrlForDokType3UsesValidEmailWithoutProtocolAsEmail()
+    {
+        $this->assertEquals('mailto:mail@typo3-test.com', $this->pageSelectObject->getExtURL([
+            'doktype' => PageRepository::DOKTYPE_LINK,
+            'url' => 'mail@typo3-test.com'
+        ]));
+    }
+}
index 60ad06c..0a7d8e1 100644 (file)
@@ -22,9 +22,9 @@ use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
 use TYPO3\CMS\Core\Context\Context;
 use TYPO3\CMS\Core\Context\LanguageAspect;
 use TYPO3\CMS\Core\Context\WorkspaceAspect;
+use TYPO3\CMS\Core\Domain\Repository\PageRepository;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\RootlineUtility;
-use TYPO3\CMS\Frontend\Page\PageRepository;
 use TYPO3\TestingFramework\Core\AccessibleObjectInterface;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
index 4fad777..cc3937b 100644 (file)
                                "partOfMinimalUsableSystem": true
                        },
                        "extension-key": "core"
+               },
+               "typo3/class-alias-loader": {
+                       "class-alias-maps": [
+                               "Migrations/Code/ClassAliasMap.php"
+                       ]
                }
        },
        "autoload": {
index 8bee24d..be4efde 100644 (file)
@@ -9,15 +9,15 @@ defined('TYPO3_MODE') or die();
  * types, and for every type the entries simply overrides the entries in the 'default' type!
  */
 $GLOBALS['PAGES_TYPES'] = [
-    (string)\TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_BE_USER_SECTION => [
+    (string)\TYPO3\CMS\Core\Domain\Repository\PageRepository::DOKTYPE_BE_USER_SECTION => [
         'allowedTables' => '*'
     ],
-    (string)\TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_SYSFOLDER => [
+    (string)\TYPO3\CMS\Core\Domain\Repository\PageRepository::DOKTYPE_SYSFOLDER => [
         //  Doktype 254 is a 'Folder' - a general purpose storage folder for whatever you like.
         // In CMS context it's NOT a viewable page. Can contain any element.
         'allowedTables' => '*'
     ],
-    (string)\TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_RECYCLER => [
+    (string)\TYPO3\CMS\Core\Domain\Repository\PageRepository::DOKTYPE_RECYCLER => [
         // Doktype 255 is a recycle-bin.
         'allowedTables' => '*'
     ],
index 28bed8a..ace3333 100644 (file)
@@ -47,7 +47,7 @@ class DataMapper
     /**
      * A reference to the page select object providing methods to perform language and work space overlays
      *
-     * @var \TYPO3\CMS\Frontend\Page\PageRepository
+     * @var \TYPO3\CMS\Core\Domain\Repository\PageRepository
      */
     protected $pageSelectObject;
 
index 64bb6d3..0bd5eb3 100644 (file)
@@ -24,6 +24,7 @@ use TYPO3\CMS\Core\Context\WorkspaceAspect;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Database\Query\QueryBuilder;
 use TYPO3\CMS\Core\Database\Query\Restriction\FrontendRestrictionContainer;
+use TYPO3\CMS\Core\Domain\Repository\PageRepository;
 use TYPO3\CMS\Core\SingletonInterface;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
@@ -39,7 +40,6 @@ use TYPO3\CMS\Extbase\Persistence\QueryInterface;
 use TYPO3\CMS\Extbase\Service\CacheService;
 use TYPO3\CMS\Extbase\Service\EnvironmentService;
 use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
-use TYPO3\CMS\Frontend\Page\PageRepository;
 
 /**
  * A Storage backend
index 6d68ce1..440c960 100644 (file)
@@ -20,6 +20,7 @@ use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Database\Query\Expression\CompositeExpression;
 use TYPO3\CMS\Core\Database\Query\Expression\ExpressionBuilder;
 use TYPO3\CMS\Core\Database\Query\QueryBuilder;
+use TYPO3\CMS\Core\Domain\Repository\PageRepository;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
 use TYPO3\CMS\Extbase\DomainObject\AbstractDomainObject;
@@ -37,7 +38,6 @@ use TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface;
 use TYPO3\CMS\Extbase\Persistence\Generic\Storage\Exception\BadConstraintException;
 use TYPO3\CMS\Extbase\Persistence\QueryInterface;
 use TYPO3\CMS\Extbase\Service\EnvironmentService;
-use TYPO3\CMS\Frontend\Page\PageRepository;
 
 /**
  * QueryParser, converting the qom to string representation
@@ -749,7 +749,7 @@ class Typo3DbQueryParser
         $statement = '';
         if ($ignoreEnableFields && !$includeDeleted) {
             if (!empty($enableFieldsToBeIgnored)) {
-                // array_combine() is necessary because of the way \TYPO3\CMS\Frontend\Page\PageRepository::enableFields() is implemented
+                // array_combine() is necessary because of the way \TYPO3\CMS\Core\Domain\Repository\PageRepository::enableFields() is implemented
                 $statement .= $this->getPageRepository()->enableFields($tableName, -1, array_combine($enableFieldsToBeIgnored, $enableFieldsToBeIgnored));
             } elseif (!empty($GLOBALS['TCA'][$tableName]['ctrl']['delete'])) {
                 $statement .= ' AND ' . $tableName . '.' . $GLOBALS['TCA'][$tableName]['ctrl']['delete'] . '=0';
@@ -798,7 +798,7 @@ class Typo3DbQueryParser
 
         // Select all entries for the current language
         // If any language is set -> get those entries which are not translated yet
-        // They will be removed by \TYPO3\CMS\Frontend\Page\PageRepository::getRecordOverlay if not matching overlay mode
+        // They will be removed by \TYPO3\CMS\Core\Domain\Repository\PageRepository::getRecordOverlay if not matching overlay mode
         $languageField = $GLOBALS['TCA'][$tableName]['ctrl']['languageField'];
 
         $transOrigPointerField = $GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerField'] ?? '';
index b1f10f6..0a3dc1b 100644 (file)
@@ -18,13 +18,13 @@ namespace TYPO3\CMS\Extbase\Tests\Functional\Persistence;
 use PHPUnit\Framework\MockObject\MockObject;
 use TYPO3\CMS\Core\Context\Context;
 use TYPO3\CMS\Core\Context\LanguageAspect;
+use TYPO3\CMS\Core\Domain\Repository\PageRepository;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager;
 use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
 use TYPO3\CMS\Extbase\Persistence\QueryInterface;
 use TYPO3\CMS\Extbase\Reflection\ObjectAccess;
 use TYPO3\CMS\Extbase\Service\EnvironmentService;
-use TYPO3\CMS\Frontend\Page\PageRepository;
 
 class QueryLocalizedDataTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTestCase
 {
index 98af204..f6cb6db 100644 (file)
@@ -19,10 +19,10 @@ use ExtbaseTeam\BlogExample\Domain\Model\Post;
 use PHPUnit\Framework\MockObject\MockObject;
 use TYPO3\CMS\Core\Context\Context;
 use TYPO3\CMS\Core\Context\LanguageAspect;
+use TYPO3\CMS\Core\Domain\Repository\PageRepository;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extbase\Persistence\QueryInterface;
 use TYPO3\CMS\Extbase\Service\EnvironmentService;
-use TYPO3\CMS\Frontend\Page\PageRepository;
 
 class TranslationTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTestCase
 {
index aa5e5f9..78f8bc6 100644 (file)
@@ -21,9 +21,9 @@ use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Database\Query\Expression\ExpressionBuilder;
 use TYPO3\CMS\Core\Database\Query\QueryBuilder;
 use TYPO3\CMS\Core\Database\Query\Restriction\FrontendRestrictionContainer;
+use TYPO3\CMS\Core\Domain\Repository\PageRepository;
 use TYPO3\CMS\Extbase\Object\ObjectManager;
 use TYPO3\CMS\Extbase\Service\EnvironmentService;
-use TYPO3\CMS\Frontend\Page\PageRepository;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
index 30cfb16..9046673 100644 (file)
@@ -14,8 +14,8 @@ namespace TYPO3\CMS\Frontend\Aspect;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Domain\Repository\PageRepository;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Frontend\Page\PageRepository;
 
 /**
  * Class FileMetadataTranslationAspect
index 95a0fbd..7bd8373 100644 (file)
@@ -18,8 +18,8 @@ use TYPO3\CMS\Core\Context\Context;
 use TYPO3\CMS\Core\Database\Connection;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Database\Query\Restriction\FrontendRestrictionContainer;
+use TYPO3\CMS\Core\Domain\Repository\PageRepository;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Frontend\Page\PageRepository;
 
 /**
  * Extend category collection for the frontend, to collect related records
index 81c2460..1481dde 100644 (file)
@@ -31,6 +31,7 @@ use TYPO3\CMS\Core\Database\Query\QueryBuilder;
 use TYPO3\CMS\Core\Database\Query\QueryHelper;
 use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
 use TYPO3\CMS\Core\Database\Query\Restriction\FrontendRestrictionContainer;
+use TYPO3\CMS\Core\Domain\Repository\PageRepository;
 use TYPO3\CMS\Core\Html\HtmlParser;
 use TYPO3\CMS\Core\Imaging\ImageManipulation\Area;
 use TYPO3\CMS\Core\Imaging\ImageManipulation\CropVariantCollection;
@@ -68,7 +69,6 @@ use TYPO3\CMS\Frontend\ContentObject\Exception\ProductionExceptionHandler;
 use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
 use TYPO3\CMS\Frontend\Http\UrlProcessorInterface;
 use TYPO3\CMS\Frontend\Imaging\GifBuilder;
-use TYPO3\CMS\Frontend\Page\PageRepository;
 use TYPO3\CMS\Frontend\Resource\FilePathSanitizer;
 use TYPO3\CMS\Frontend\Service\TypoLinkCodecService;
 use TYPO3\CMS\Frontend\Typolink\AbstractTypolinkBuilder;
index fa76520..687eaf6 100644 (file)
@@ -199,7 +199,7 @@ class FilesContentObject extends AbstractContentObject
     }
 
     /**
-     * @return \TYPO3\CMS\Frontend\Page\PageRepository
+     * @return \TYPO3\CMS\Core\Domain\Repository\PageRepository
      */
     protected function getPageRepository()
     {
index a1817ad..814e4d3 100644 (file)
@@ -19,6 +19,7 @@ use TYPO3\CMS\Core\Context\Context;
 use TYPO3\CMS\Core\Context\LanguageAspect;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Database\RelationHandler;
+use TYPO3\CMS\Core\Domain\Repository\PageRepository;
 use TYPO3\CMS\Core\Exception\SiteNotFoundException;
 use TYPO3\CMS\Core\Site\Entity\NullSite;
 use TYPO3\CMS\Core\Site\Entity\SiteInterface;
@@ -30,7 +31,6 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
 use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
 use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
-use TYPO3\CMS\Frontend\Page\PageRepository;
 use TYPO3\CMS\Frontend\Typolink\PageLinkBuilder;
 
 /**
index d6d72d8..ae03d48 100644 (file)
@@ -15,10 +15,10 @@ namespace TYPO3\CMS\Frontend\ContentObject;
  */
 
 use TYPO3\CMS\Core\Database\RelationHandler;
+use TYPO3\CMS\Core\Domain\Repository\PageRepository;
 use TYPO3\CMS\Core\TimeTracker\TimeTracker;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Frontend\Category\Collection\CategoryCollection;
-use TYPO3\CMS\Frontend\Page\PageRepository;
 
 /**
  * Contains RECORDS class object.
index 3c709b6..4dcc4eb 100644 (file)
@@ -35,6 +35,7 @@ use TYPO3\CMS\Core\Database\ConnectionPool;
 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\Domain\Repository\PageRepository;
 use TYPO3\CMS\Core\Error\Http\PageNotFoundException;
 use TYPO3\CMS\Core\Error\Http\ServiceUnavailableException;
 use TYPO3\CMS\Core\Error\Http\ShortcutTargetPageNotFoundException;
@@ -68,7 +69,6 @@ use TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication;
 use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
 use TYPO3\CMS\Frontend\Page\CacheHashCalculator;
 use TYPO3\CMS\Frontend\Page\PageAccessFailureReasons;
-use TYPO3\CMS\Frontend\Page\PageRepository;
 use TYPO3\CMS\Frontend\Resource\FilePathSanitizer;
 
 /**
index 1e9b277..2835283 100644 (file)
@@ -19,10 +19,10 @@ use Psr\Http\Message\ResponseInterface;
 use Psr\Http\Message\ServerRequestInterface;
 use Psr\Http\Server\MiddlewareInterface;
 use Psr\Http\Server\RequestHandlerInterface;
+use TYPO3\CMS\Core\Domain\Repository\PageRepository;
 use TYPO3\CMS\Core\Http\RedirectResponse;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
-use TYPO3\CMS\Frontend\Page\PageRepository;
 
 /**
  * Checks mount points, shortcuts and redirects to the target.
diff --git a/typo3/sysext/frontend/Classes/Page/PageRepository.php b/typo3/sysext/frontend/Classes/Page/PageRepository.php
deleted file mode 100644 (file)
index 65b7637..0000000
+++ /dev/null
@@ -1,1740 +0,0 @@
-<?php
-namespace TYPO3\CMS\Frontend\Page;
-
-/*
- * This file is part of the TYPO3 CMS project.
- *
- * It is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License, either version 2
- * of the License, or any later version.
- *
- * For the full copyright and license information, please read the
- * LICENSE.txt file that was distributed with this source code.
- *
- * The TYPO3 project - inspiring people to share!
- */
-
-use Psr\Log\LoggerAwareInterface;
-use Psr\Log\LoggerAwareTrait;
-use TYPO3\CMS\Core\Cache\CacheManager;
-use TYPO3\CMS\Core\Cache\Frontend\VariableFrontend;
-use TYPO3\CMS\Core\Context\Context;
-use TYPO3\CMS\Core\Context\Exception\AspectNotFoundException;
-use TYPO3\CMS\Core\Context\LanguageAspect;
-use TYPO3\CMS\Core\Context\UserAspect;
-use TYPO3\CMS\Core\Database\Connection;
-use TYPO3\CMS\Core\Database\ConnectionPool;
-use TYPO3\CMS\Core\Database\Query\QueryHelper;
-use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
-use TYPO3\CMS\Core\Database\Query\Restriction\FrontendRestrictionContainer;
-use TYPO3\CMS\Core\Database\Query\Restriction\FrontendWorkspaceRestriction;
-use TYPO3\CMS\Core\Error\Http\ShortcutTargetPageNotFoundException;
-use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Core\Utility\MathUtility;
-use TYPO3\CMS\Core\Versioning\VersionState;
-
-/**
- * Page functions, a lot of sql/pages-related functions
- *
- * Mainly used in the frontend but also in some cases in the backend. It's
- * important to set the right $where_hid_del in the object so that the
- * functions operate properly
- * @see \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::fetch_the_id()
- */
-class PageRepository implements LoggerAwareInterface
-{
-    use LoggerAwareTrait;
-
-    /**
-     * This is not the final clauses. There will normally be conditions for the
-     * hidden, starttime and endtime fields as well. You MUST initialize the object
-     * by the init() function
-     *
-     * @var string
-     */
-    public $where_hid_del = ' AND pages.deleted=0';
-
-    /**
-     * Clause for fe_group access
-     *
-     * @var string
-     */
-    public $where_groupAccess = '';
-
-    /**
-     * Can be migrated away later to use context API directly.
-     *
-     * @var int
-     */
-    protected $sys_language_uid = 0;
-
-    /**
-     * Can be migrated away later to use context API directly.
-     * Workspace ID for preview
-     * If > 0, versioning preview of other record versions is allowed. THIS MUST
-     * ONLY BE SET IF the page is not cached and truly previewed by a backend
-     * user!
-     *
-     * @var int
-     */
-    protected $versioningWorkspaceId = 0;
-
-    /**
-     * Computed properties that are added to database rows.
-     *
-     * @var array
-     */
-    protected $computedPropertyNames = [
-        '_LOCALIZED_UID',
-        '_MP_PARAM',
-        '_ORIG_uid',
-        '_ORIG_pid',
-        '_PAGES_OVERLAY',
-        '_PAGES_OVERLAY_UID',
-        '_PAGES_OVERLAY_LANGUAGE',
-        '_PAGES_OVERLAY_REQUESTEDLANGUAGE',
-    ];
-
-    /**
-     * Named constants for "magic numbers" of the field doktype
-     */
-    const DOKTYPE_DEFAULT = 1;
-    const DOKTYPE_LINK = 3;
-    const DOKTYPE_SHORTCUT = 4;
-    const DOKTYPE_BE_USER_SECTION = 6;
-    const DOKTYPE_MOUNTPOINT = 7;
-    const DOKTYPE_SPACER = 199;
-    const DOKTYPE_SYSFOLDER = 254;
-    const DOKTYPE_RECYCLER = 255;
-
-    /**
-     * Named constants for "magic numbers" of the field shortcut_mode
-     */
-    const SHORTCUT_MODE_NONE = 0;
-    const SHORTCUT_MODE_FIRST_SUBPAGE = 1;
-    const SHORTCUT_MODE_RANDOM_SUBPAGE = 2;
-    const SHORTCUT_MODE_PARENT_PAGE = 3;
-
-    /**
-     * @var Context
-     */
-    protected $context;
-
-    /**
-     * PageRepository constructor to set the base context, this will effectively remove the necessity for
-     * setting properties from the outside.
-     *
-     * @param Context $context
-     */
-    public function __construct(Context $context = null)
-    {
-        $this->context = $context ?? GeneralUtility::makeInstance(Context::class);
-        $this->versioningWorkspaceId = $this->context->getPropertyFromAspect('workspace', 'id');
-        // Only set up the where clauses for pages when TCA is set. This usually happens only in tests.
-        // Once all tests are written very well, this can be removed again
-        if (isset($GLOBALS['TCA']['pages'])) {
-            $this->init($this->context->getPropertyFromAspect('visibility', 'includeHiddenPages'));
-            $this->where_groupAccess = $this->getMultipleGroupsWhereClause('pages.fe_group', 'pages');
-            $this->sys_language_uid = (int)$this->context->getPropertyFromAspect('language', 'id', 0);
-        }
-    }
-
-    /**
-     * init() MUST be run directly after creating a new template-object
-     * This sets the internal variable $this->where_hid_del to the correct where
-     * clause for page records taking deleted/hidden/starttime/endtime/t3ver_state
-     * into account
-     *
-     * @param bool $show_hidden If $show_hidden is TRUE, the hidden-field is ignored!! Normally this should be FALSE. Is used for previewing.
-     * @internal
-     */
-    protected function init($show_hidden)
-    {
-        $this->where_groupAccess = '';
-
-        $expressionBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
-            ->getQueryBuilderForTable('pages')
-            ->expr();
-        if ($this->versioningWorkspaceId > 0) {
-            // For version previewing, make sure that enable-fields are not
-            // de-selecting hidden pages - we need versionOL() to unset them only
-            // if the overlay record instructs us to.
-            // Clear where_hid_del and restrict to live and current workspaces
-            $this->where_hid_del = ' AND ' . $expressionBuilder->andX(
-                $expressionBuilder->eq('pages.deleted', 0),
-                $expressionBuilder->orX(
-                    $expressionBuilder->eq('pages.t3ver_wsid', 0),
-                    $expressionBuilder->eq('pages.t3ver_wsid', (int)$this->versioningWorkspaceId)
-                ),
-                $expressionBuilder->lt('pages.doktype', 200)
-            );
-        } else {
-            // add starttime / endtime, and check for hidden/deleted
-            // Filter out new/deleted place-holder pages in case we are NOT in a
-            // versioning preview (that means we are online!)
-            $this->where_hid_del = ' AND ' . (string)$expressionBuilder->andX(
-                QueryHelper::stripLogicalOperatorPrefix(
-                    $this->enableFields('pages', $show_hidden, ['fe_group' => true])
-                ),
-                $expressionBuilder->lt('pages.doktype', 200)
-            );
-        }
-        if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][self::class]['init'] ?? false)) {
-            foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][self::class]['init'] as $classRef) {
-                $hookObject = GeneralUtility::makeInstance($classRef);
-                if (!$hookObject instanceof PageRepositoryInitHookInterface) {
-                    throw new \UnexpectedValueException($classRef . ' must implement interface ' . PageRepositoryInitHookInterface::class, 1379579812);
-                }
-                $hookObject->init_postProcess($this);
-            }
-        }
-    }
-
-    /**************************
-     *
-     * Selecting page records
-     *
-     **************************/
-
-    /**
-     * Loads the full page record for the given page ID.
-     *
-     * The page record is either served from a first-level cache or loaded from the
-     * database. If no page can be found, an empty array is returned.
-     *
-     * Language overlay and versioning overlay are applied. Mount Point
-     * handling is not done, an overlaid Mount Point is not replaced.
-     *
-     * The result is conditioned by the public properties where_groupAccess
-     * and where_hid_del that are preset by the init() method.
-     *
-     * @see PageRepository::where_groupAccess
-     * @see PageRepository::where_hid_del
-     *
-     * By default the usergroup access check is enabled. Use the second method argument
-     * to disable the usergroup access check.
-     *
-     * The given UID can be preprocessed by registering a hook class that is
-     * implementing the PageRepositoryGetPageHookInterface into the configuration array
-     * $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_page.php']['getPage'].
-     *
-     * @param int $uid The page id to look up
-     * @param bool $disableGroupAccessCheck set to true to disable group access check
-     * @return array The resulting page record with overlays or empty array
-     * @throws \UnexpectedValueException
-     * @see PageRepository::getPage_noCheck()
-     */
-    public function getPage($uid, $disableGroupAccessCheck = false)
-    {
-        // Hook to manipulate the page uid for special overlay handling
-        foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_page.php']['getPage'] ?? [] as $className) {
-            $hookObject = GeneralUtility::makeInstance($className);
-            if (!$hookObject instanceof PageRepositoryGetPageHookInterface) {
-                throw new \UnexpectedValueException($className . ' must implement interface ' . PageRepositoryGetPageHookInterface::class, 1251476766);
-            }
-            $hookObject->getPage_preProcess($uid, $disableGroupAccessCheck, $this);
-        }
-        $cacheIdentifier = 'PageRepository_getPage_' . md5(
-            implode(
-                '-',
-                [
-                    $uid,
-                    $disableGroupAccessCheck ? '' : $this->where_groupAccess,
-                    $this->where_hid_del,
-                    $this->sys_language_uid
-                ]
-            )
-        );
-        $cache = $this->getRuntimeCache();
-        $cacheEntry = $cache->get($cacheIdentifier);
-        if (is_array($cacheEntry)) {
-            return $cacheEntry;
-        }
-        $result = [];
-        $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');
-        $queryBuilder->getRestrictions()->removeAll();
-        $queryBuilder->select('*')
-            ->from('pages')
-            ->where(
-                $queryBuilder->expr()->eq('uid', (int)$uid),
-                QueryHelper::stripLogicalOperatorPrefix($this->where_hid_del)
-            );
-
-        if (!$disableGroupAccessCheck) {
-            $queryBuilder->andWhere(QueryHelper::stripLogicalOperatorPrefix($this->where_groupAccess));
-        }
-
-        $row = $queryBuilder->execute()->fetch();
-        if ($row) {
-            $this->versionOL('pages', $row);
-            if (is_array($row)) {
-                $result = $this->getPageOverlay($row);
-            }
-        }
-        $cache->set($cacheIdentifier, $result);
-        return $result;
-    }
-
-    /**
-     * Return the $row for the page with uid = $uid WITHOUT checking for
-     * ->where_hid_del (start- and endtime or hidden). Only "deleted" is checked!
-     *
-     * @param int $uid The page id to look up
-     * @return array The page row with overlaid localized fields. Empty array if no page.
-     * @see getPage()
-     */
-    public function getPage_noCheck($uid)
-    {
-        $cache = $this->getRuntimeCache();
-        $cacheIdentifier = 'PageRepository_getPage_noCheck_' . $uid . '_' . $this->sys_language_uid . '_' . $this->versioningWorkspaceId;
-        $cacheEntry = $cache->get($cacheIdentifier);
-        if ($cacheEntry !== false) {
-            return $cacheEntry;
-        }
-
-        $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');
-        $queryBuilder->getRestrictions()
-            ->removeAll()
-            ->add(GeneralUtility::makeInstance(DeletedRestriction::class));
-        $row = $queryBuilder->select('*')
-            ->from('pages')
-            ->where($queryBuilder->expr()->eq('uid', (int)$uid))
-            ->execute()
-            ->fetch();
-
-        $result = [];
-        if ($row) {
-            $this->versionOL('pages', $row);
-            if (is_array($row)) {
-                $result = $this->getPageOverlay($row);
-            }
-        }
-        $cache->set($cacheIdentifier, $result);
-        return $result;
-    }
-
-    /**
-     * Master helper method to overlay a record to a language.
-     *
-     * Be aware that for pages the languageId is taken, and for all other records the contentId.
-     * This might change through a feature switch in the future.
-     *
-     * @param string $table the name of the table, should be a TCA table with localization enabled
-     * @param array $row the current (full-fletched) record.
-     * @return array|null
-     */
-    public function getLanguageOverlay(string $table, array $row)
-    {
-        // table is not localizable, so return directly
-        if (!isset($GLOBALS['TCA'][$table]['ctrl']['languageField'])) {
-            return $row;
-        }
-        try {
-            /** @var LanguageAspect $languageAspect */
-            $languageAspect = $this->context->getAspect('language');
-            if ($languageAspect->doOverlays()) {
-                if ($table === 'pages') {
-                    return $this->getPageOverlay($row, $languageAspect->getId());
-                }
-                return $this->getRecordOverlay(
-                    $table,
-                    $row,
-                    $languageAspect->getContentId(),
-                    $languageAspect->getOverlayType() === $languageAspect::OVERLAYS_MIXED ? '1' : 'hideNonTranslated'
-                );
-            }
-        } catch (AspectNotFoundException $e) {
-            // no overlays
-        }
-        return $row;
-    }
-
-    /**
-     * Returns the relevant page overlay record fields
-     *
-     * @param mixed $pageInput If $pageInput is an integer, it's the pid of the pageOverlay record and thus the page overlay record is returned. If $pageInput is an array, it's a page-record and based on this page record the language record is found and OVERLAID before the page record is returned.
-     * @param int $languageUid Language UID if you want to set an alternative value to $this->sys_language_uid which is default. Should be >=0
-     * @throws \UnexpectedValueException
-     * @return array Page row which is overlaid with language_overlay record (or the overlay record alone)
-     */
-    public function getPageOverlay($pageInput, $languageUid = null)
-    {
-        $rows = $this->getPagesOverlay([$pageInput], $languageUid);
-        // Always an array in return
-        return $rows[0] ?? [];
-    }
-
-    /**
-     * Returns the relevant page overlay record fields
-     *
-     * @param array $pagesInput Array of integers or array of arrays. If each value is an integer, it's the pids of the pageOverlay records and thus the page overlay records are returned. If each value is an array, it's page-records and based on this page records the language records are found and OVERLAID before the page records are returned.
-     * @param int $languageUid Language UID if you want to set an alternative value to $this->sys_language_uid which is default. Should be >=0
-     * @throws \UnexpectedValueException
-     * @return array Page rows which are overlaid with language_overlay record.
-     *               If the input was an array of integers, missing records are not
-     *               included. If the input were page rows, untranslated pages
-     *               are returned.
-     */
-    public function getPagesOverlay(array $pagesInput, $languageUid = null)
-    {
-        if (empty($pagesInput)) {
-            return [];
-        }
-        if ($languageUid === null) {
-            $languageUid = $this->sys_language_uid;
-        }
-        foreach ($pagesInput as &$origPage) {
-            foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_page.php']['getPageOverlay'] ?? [] as $className) {
-                $hookObject = GeneralUtility::makeInstance($className);
-                if (!$hookObject instanceof PageRepositoryGetPageOverlayHookInterface) {
-                    throw new \UnexpectedValueException($className . ' must implement interface ' . PageRepositoryGetPageOverlayHookInterface::class, 1269878881);
-                }
-                $hookObject->getPageOverlay_preProcess($origPage, $languageUid, $this);
-            }
-        }
-        unset($origPage);
-
-        $overlays = [];
-        // If language UID is different from zero, do overlay:
-        if ($languageUid) {
-            $languageUids = array_merge([$languageUid], $this->getLanguageFallbackChain(null));
-
-            $pageIds = [];
-            foreach ($pagesInput as $origPage) {
-                if (is_array($origPage)) {
-                    // Was the whole record
-                    $pageIds[] = (int)$origPage['uid'];
-                } else {
-                    // Was the id
-                    $pageIds[] = (int)$origPage;
-                }
-            }
-            $overlays = $this->getPageOverlaysForLanguageUids($pageIds, $languageUids);
-        }
-
-        // Create output:
-        $pagesOutput = [];
-        foreach ($pagesInput as $key => $origPage) {
-            if (is_array($origPage)) {
-                $pagesOutput[$key] = $origPage;
-                if (isset($overlays[$origPage['uid']])) {
-                    // Overwrite the original field with the overlay
-                    foreach ($overlays[$origPage['uid']] as $fieldName => $fieldValue) {
-                        if ($fieldName !== 'uid' && $fieldName !== 'pid') {
-                            $pagesOutput[$key][$fieldName] = $fieldValue;
-                        }
-                    }
-                }
-            } else {
-                if (isset($overlays[$origPage])) {
-                    $pagesOutput[$key] = $overlays[$origPage];
-                }
-            }
-        }
-        return $pagesOutput;
-    }
-
-    /**
-     * Checks whether the passed (translated or default language) page is accessible with the given language settings.
-     *
-     * @param array $page the page translation record or the page in the default language
-     * @param LanguageAspect $languageAspect
-     * @return bool true if the given page translation record is suited for the given language ID
-     * @internal only in use for HMENU generation for now
-     */
-    public function isPageSuitableForLanguage(array $page, LanguageAspect $languageAspect): bool
-    {
-        $languageUid = $languageAspect->getId();
-        // Checks if the default language version can be shown
-        // Block page is set, if l18n_cfg allows plus: 1) Either default language or 2) another language but NO overlay record set for page!
-        if (GeneralUtility::hideIfDefaultLanguage($page['l18n_cfg']) && (!$languageUid || $languageUid && !$page['_PAGES_OVERLAY'])) {
-            return false;
-        }
-        if ($languageUid > 0 && GeneralUtility::hideIfNotTranslated($page['l18n_cfg'])) {
-            if (!$page['_PAGES_OVERLAY'] || (int)$page['_PAGES_OVERLAY_LANGUAGE'] !== $languageUid) {
-                return false;
-            }
-        } elseif ($languageUid > 0) {
-            $languageUids = array_merge([$languageUid], $this->getLanguageFallbackChain($languageAspect));
-            return in_array((int)$page['sys_language_uid'], $languageUids, true);
-        }
-        return true;
-    }
-
-    /**
-     * Returns the cleaned fallback chain from the current language aspect, if there is one.
-     *
-     * @param LanguageAspect|null $languageAspect
-     * @return int[]
-     */
-    protected function getLanguageFallbackChain(?LanguageAspect $languageAspect): array
-    {
-        $languageAspect = $languageAspect ?? $this->context->getAspect('language');
-        return array_filter($languageAspect->getFallbackChain(), function ($item) {
-            return MathUtility::canBeInterpretedAsInteger($item);
-        });
-    }
-
-    /**
-     * Returns the first match of overlays for pages in the passed languages.
-     *
-     * NOTE regarding the query restrictions:
-     * Currently the visibility aspect within the FrontendRestrictionContainer will allow
-     * page translation records to be selected as they are child-records of a page.
-     * However you may argue that the visibility flag should determine this.
-     * But that's not how it's done right now.
-     *
-     * @param array $pageUids
-     * @param array $languageUids uid of sys_language, please note that the order is important here.
-     * @return array
-     */
-    protected function getPageOverlaysForLanguageUids(array $pageUids, array $languageUids): array
-    {
-        // Remove default language ("0")
-        $languageUids = array_filter($languageUids);
-        $languageField = $GLOBALS['TCA']['pages']['ctrl']['languageField'];
-        $overlays = [];
-
-        foreach ($pageUids as $pageId) {
-            // Create a map based on the order of values in $languageUids. Those entries reflect the order of the language + fallback chain.
-            // We can't work with database ordering since there is no common SQL clause to order by e.g. [7, 1, 2].
-            $orderedListByLanguages = array_flip($languageUids);
-
-            $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');
-            $queryBuilder->setRestrictions(GeneralUtility::makeInstance(FrontendRestrictionContainer::class));
-            $result = $queryBuilder->select('*')
-                ->from('pages')
-                ->where(
-                    $queryBuilder->expr()->eq(
-                        $GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField'],
-                        $queryBuilder->createNamedParameter($pageId, \PDO::PARAM_INT)
-                    ),
-                    $queryBuilder->expr()->in(
-                        $GLOBALS['TCA']['pages']['ctrl']['languageField'],
-                        $queryBuilder->createNamedParameter($languageUids, Connection::PARAM_INT_ARRAY)
-                    )
-                )
-                ->execute();
-
-            // Create a list of rows ordered by values in $languageUids
-            while ($row = $result->fetch()) {
-                $orderedListByLanguages[$row[$languageField]] = $row;
-            }
-
-            foreach ($orderedListByLanguages as $languageUid => $row) {
-                if (!is_array($row)) {
-                    continue;
-                }
-
-                // Found a result for the current language id
-                $this->versionOL('pages', $row);
-                if (is_array($row)) {
-                    $row['_PAGES_OVERLAY'] = true;
-                    $row['_PAGES_OVERLAY_UID'] = $row['uid'];
-                    $row['_PAGES_OVERLAY_LANGUAGE'] = $languageUid;
-                    $row['_PAGES_OVERLAY_REQUESTEDLANGUAGE'] = $languageUids[0];
-                    // Unset vital fields that are NOT allowed to be overlaid:
-                    unset($row['uid'], $row['pid']);
-                    $overlays[$pageId] = $row;
-
-                    // Language fallback found, stop querying further languages
-                    break;
-                }
-            }
-        }
-
-        return $overlays;
-    }
-
-    /**
-     * Creates language-overlay for records in general (where translation is found
-     * in records from the same table)
-     *
-     * @param string $table Table name
-     * @param array $row Record to overlay. Must contain uid, pid and $table]['ctrl']['languageField']
-     * @param int $sys_language_content Pointer to the sys_language uid for content on the site.
-     * @param string $OLmode Overlay mode. If "hideNonTranslated" then records without translation will not be returned  un-translated but unset (and return value is FALSE)
-     * @throws \UnexpectedValueException
-     * @return mixed Returns the input record, possibly overlaid with a translation.  But if $OLmode is "hideNonTranslated" then it will return FALSE if no translation is found.
-     */
-    public function getRecordOverlay($table, $row, $sys_language_content, $OLmode = '')
-    {
-        foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_page.php']['getRecordOverlay'] ?? [] as $className) {
-            $hookObject = GeneralUtility::makeInstance($className);
-            if (!$hookObject instanceof PageRepositoryGetRecordOverlayHookInterface) {
-                throw new \UnexpectedValueException($className . ' must implement interface ' . PageRepositoryGetRecordOverlayHookInterface::class, 1269881658);
-            }
-            $hookObject->getRecordOverlay_preProcess($table, $row, $sys_language_content, $OLmode, $this);
-        }
-
-        $tableControl = $GLOBALS['TCA'][$table]['ctrl'] ?? [];
-
-        if (!empty($tableControl['languageField'])
-            // Return record for ALL languages untouched
-            // TODO: Fix call stack to prevent this situation in the first place
-            && (int)$row[$tableControl['languageField']] !== -1
-            && !empty($tableControl['transOrigPointerField'])
-            && $row['uid'] > 0
-            && ($row['pid'] > 0 || in_array($tableControl['rootLevel'] ?? false, [true, 1, -1], true))) {
-            // Will try to overlay a record only if the sys_language_content value is larger than zero.
-            if ($sys_language_content > 0) {
-                // Must be default language, otherwise no overlaying
-                if ((int)$row[$tableControl['languageField']] === 0) {
-                    // Select overlay record:
-                    $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
-                        ->getQueryBuilderForTable($table);
-                    $queryBuilder->setRestrictions(
-                        GeneralUtility::makeInstance(FrontendRestrictionContainer::class)
-                    );
-                    $olrow = $queryBuilder->select('*')
-                        ->from($table)
-                        ->where(
-                            $queryBuilder->expr()->eq(
-                                'pid',
-                                $queryBuilder->createNamedParameter($row['pid'], \PDO::PARAM_INT)
-                            ),
-                            $queryBuilder->expr()->eq(
-                                $tableControl['languageField'],
-                                $queryBuilder->createNamedParameter($sys_language_content, \PDO::PARAM_INT)
-                            ),
-                            $queryBuilder->expr()->eq(
-                                $tableControl['transOrigPointerField'],
-                                $queryBuilder->createNamedParameter($row['uid'], \PDO::PARAM_INT)
-                            )
-                        )
-                        ->setMaxResults(1)
-                        ->execute()
-                        ->fetch();
-
-                    $this->versionOL($table, $olrow);
-                    // Merge record content by traversing all fields:
-                    if (is_array($olrow)) {
-                        if (isset($olrow['_ORIG_uid'])) {
-                            $row['_ORIG_uid'] = $olrow['_ORIG_uid'];
-                        }
-                        if (isset($olrow['_ORIG_pid'])) {
-                            $row['_ORIG_pid'] = $olrow['_ORIG_pid'];
-                        }
-                        foreach ($row as $fN => $fV) {
-                            if ($fN !== 'uid' && $fN !== 'pid' && isset($olrow[$fN])) {
-                                $row[$fN] = $olrow[$fN];
-                            } elseif ($fN === 'uid') {
-                                $row['_LOCALIZED_UID'] = $olrow['uid'];
-                            }
-                        }
-                    } elseif ($OLmode === 'hideNonTranslated' && (int)$row[$tableControl['languageField']] === 0) {
-                        // Unset, if non-translated records should be hidden. ONLY done if the source
-                        // record really is default language and not [All] in which case it is allowed.
-                        unset($row);
-                    }
-                } elseif ($sys_language_content != $row[$tableControl['languageField']]) {
-                    unset($row);
-                }
-            } else {
-                // When default language is displayed, we never want to return a record carrying
-                // another language!
-                if ($row[$tableControl['languageField']] > 0) {
-                    unset($row);
-                }
-            }
-        }
-
-        foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_page.php']['getRecordOverlay'] ?? [] as $className) {
-            $hookObject = GeneralUtility::makeInstance($className);
-            if (!$hookObject instanceof PageRepositoryGetRecordOverlayHookInterface) {
-                throw new \UnexpectedValueException($className . ' must implement interface ' . PageRepositoryGetRecordOverlayHookInterface::class, 1269881659);
-            }
-            $hookObject->getRecordOverlay_postProcess($table, $row, $sys_language_content, $OLmode, $this);
-        }
-
-        return $row;
-    }
-
-    /************************************************
-     *
-     * Page related: Menu, Domain record, Root line
-     *
-     ************************************************/
-
-    /**
-     * Returns an array with page rows for subpages of a certain page ID. This is used for menus in the frontend.
-     * If there are mount points in overlay mode the _MP_PARAM field is set to the correct MPvar.
-     *
-     * If the $pageId being input does in itself require MPvars to define a correct
-     * rootline these must be handled externally to this function.
-     *
-     * @param int|int[] $pageId The page id (or array of page ids) for which to fetch subpages (PID)
-     * @param string $fields List of fields to select. Default is "*" = all
-     * @param string $sortField The field to sort by. Default is "sorting
-     * @param string $additionalWhereClause Optional additional where clauses. Like "AND title like '%blabla%'" for instance.
-     * @param bool $checkShortcuts Check if shortcuts exist, checks by default
-     * @return array Array with key/value pairs; keys are page-uid numbers. values are the corresponding page records (with overlaid localized fields, if any)
-     * @see self::getPageShortcut(), \TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuContentObject::makeMenu()
-     */
-    public function getMenu($pageId, $fields = '*', $sortField = 'sorting', $additionalWhereClause = '', $checkShortcuts = true)
-    {
-        return $this->getSubpagesForPages((array)$pageId, $fields, $sortField, $additionalWhereClause, $checkShortcuts);
-    }
-
-    /**
-     * Returns an array with page-rows for pages with uid in $pageIds.
-     *
-     * This is used for menus. If there are mount points in overlay mode
-     * the _MP_PARAM field is set to the correct MPvar.
-     *
-     * @param int[] $pageIds Array of page ids to fetch
-     * @param string $fields List of fields to select. Default is "*" = all
-     * @param string $sortField The field to sort by. Default is "sorting"
-     * @param string $additionalWhereClause Optional additional where clauses. Like "AND title like '%blabla%'" for instance.
-     * @param bool $checkShortcuts Check if shortcuts exist, checks by default
-     * @return array Array with key/value pairs; keys are page-uid numbers. values are the corresponding page records (with overlaid localized fields, if any)
-     */
-    public function getMenuForPages(array $pageIds, $fields = '*', $sortField = 'sorting', $additionalWhereClause = '', $checkShortcuts = true)
-    {
-        return $this->getSubpagesForPages($pageIds, $fields, $sortField, $additionalWhereClause, $checkShortcuts, false);
-    }
-
-    /**
-     * Loads page records either by PIDs or by UIDs.
-     *
-     * By default the subpages of the given page IDs are loaded (as the method name suggests). If $parentPages is set
-     * to FALSE, the page records for the given page IDs are loaded directly.
-     *
-     * Concerning the rationale, please see these two other methods:
-     *
-     * @see PageRepository::getMenu()
-     * @see PageRepository::getMenuForPages()
-     *
-     * Version and language overlay are applied to the loaded records.
-     *
-     * If a record is a mount point in overlay mode, the the overlaying page record is returned in place of the
-     * record. The record is enriched by the field _MP_PARAM containing the mount point mapping for the mount
-     * point.
-     *
-     * The query can be customized by setting fields, sorting and additional WHERE clauses. If additional WHERE
-     * clauses are given, the clause must start with an operator, i.e: "AND title like '%blabla%'".
-     *
-     * The keys of the returned page records are the page UIDs.
-     *
-     * CAUTION: In case of an overlaid mount point, it is the original UID.
-     *
-     * @param int[] $pageIds PIDs or UIDs to load records for
-     * @param string $fields fields to select
-     * @param string $sortField the field to sort by
-     * @param string $additionalWhereClause optional additional WHERE clause
-     * @param bool $checkShortcuts whether to check if shortcuts exist
-     * @param bool $parentPages Switch to load pages (false) or child pages (true).
-     * @return array page records
-     *
-     * @see self::getPageShortcut()
-     * @see \TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuContentObject::makeMenu()
-     */
-    protected function getSubpagesForPages(
-        array $pageIds,
-        string $fields = '*',
-        string $sortField = 'sorting',
-        string $additionalWhereClause = '',
-        bool $checkShortcuts = true,
-        bool $parentPages = true
-    ): array {
-        $relationField = $parentPages ? 'pid' : 'uid';
-        $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');
-        $queryBuilder->getRestrictions()->removeAll();
-
-        $res = $queryBuilder->select(...GeneralUtility::trimExplode(',', $fields, true))
-            ->from('pages')
-            ->where(
-                $queryBuilder->expr()->in(
-                    $relationField,
-                    $queryBuilder->createNamedParameter($pageIds, Connection::PARAM_INT_ARRAY)
-                ),
-                $queryBuilder->expr()->eq(
-                    $GLOBALS['TCA']['pages']['ctrl']['languageField'],
-                    $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)
-                ),
-                QueryHelper::stripLogicalOperatorPrefix($this->where_hid_del),
-                QueryHelper::stripLogicalOperatorPrefix($this->where_groupAccess),
-                QueryHelper::stripLogicalOperatorPrefix($additionalWhereClause)
-            );
-
-        if (!empty($sortField)) {
-            $orderBy = QueryHelper::parseOrderBy($sortField);
-            foreach ($orderBy as $order) {
-                $res->orderBy(...$order);
-            }
-        }
-        $result = $res->execute();
-
-        $pages = [];
-        while ($page = $result->fetch()) {
-            $originalUid = $page['uid'];
-
-            // Versioning Preview Overlay
-            $this->versionOL('pages', $page, true);
-            // Skip if page got disabled due to version overlay
-            // (might be delete or move placeholder)
-            if (empty($page)) {
-                continue;
-            }
-
-            // Add a mount point parameter if needed
-            $page = $this->addMountPointParameterToPage((array)$page);
-
-            // If shortcut, look up if the target exists and is currently visible
-            if ($checkShortcuts) {
-                $page = $this->checkValidShortcutOfPage((array)$page, $additionalWhereClause);
-            }
-
-            // If the page still is there, we add it to the output
-            if (!empty($page)) {
-                $pages[$originalUid] = $page;
-            }
-        }
-
-        // Finally load language overlays
-        return $this->getPagesOverlay($pages);
-    }
-
-    /**
-     * Replaces the given page record with mounted page if required
-     *
-     * If the given page record is a mount point in overlay mode, the page
-     * record is replaced by the record of the overlaying page. The overlay
-     * record is enriched by setting the mount point mapping into the field
-     * _MP_PARAM as string for example '23-14'.
-     *
-     * In all other cases the given page record is returned as is.
-     *
-     * @todo Find a better name. The current doesn't hit the point.
-     *
-     * @param array $page The page record to handle.
-     * @return array The given page record or it's replacement.
-     */
-    protected function addMountPointParameterToPage(array $page): array
-    {
-        if (empty($page)) {
-            return [];
-        }
-
-        // $page MUST have "uid", "pid", "doktype", "mount_pid", "mount_pid_ol" fields in it
-        $mountPointInfo = $this->getMountPointInfo($page['uid'], $page);
-
-        // There is a valid mount point in overlay mode.
-        if (is_array($mountPointInfo) && $mountPointInfo['overlay']) {
-
-            // Using "getPage" is OK since we need the check for enableFields AND for type 2
-            // of mount pids we DO require a doktype < 200!
-            $mountPointPage = $this->getPage($mountPointInfo['mount_pid']);
-
-            if (!empty($mountPointPage)) {
-                $page = $mountPointPage;
-                $page['_MP_PARAM'] = $mountPointInfo['MPvar'];
-            } else {
-                $page = [];
-            }
-        }
-        return $page;
-    }
-
-    /**
-     * If shortcut, look up if the target exists and is currently visible
-     *
-     * @param array $page The page to check
-     * @param string $additionalWhereClause Optional additional where clauses. Like "AND title like '%blabla%'" for instance.
-     * @return array
-     */
-    protected function checkValidShortcutOfPage(array $page, $additionalWhereClause)
-    {
-        if (empty($page)) {
-            return [];
-        }
-
-        $dokType = (int)$page['doktype'];
-        $shortcutMode = (int)$page['shortcut_mode'];
-
-        if ($dokType === self::DOKTYPE_SHORTCUT && ($page['shortcut'] || $shortcutMode)) {
-            if ($shortcutMode === self::SHORTCUT_MODE_NONE) {
-                // No shortcut_mode set, so target is directly set in $page['shortcut']
-                $searchField = 'uid';
-                $searchUid = (int)$page['shortcut'];
-            } elseif ($shortcutMode === self::SHORTCUT_MODE_FIRST_SUBPAGE || $shortcutMode === self::SHORTCUT_MODE_RANDOM_SUBPAGE) {
-                // Check subpages - first subpage or random subpage
-                $searchField = 'pid';
-                // If a shortcut mode is set and no valid page is given to select subpags
-                // from use the actual page.
-                $searchUid = (int)$page['shortcut'] ?: $page['uid'];
-            } elseif ($shortcutMode === self::SHORTCUT_MODE_PARENT_PAGE) {
-                // Shortcut to parent page
-                $searchField = 'uid';
-                $searchUid = $page['pid'];
-            } else {
-                $searchField = '';
-                $searchUid = 0;
-            }
-
-            $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');
-            $queryBuilder->getRestrictions()->removeAll();
-            $count = $queryBuilder->count('uid')
-                ->from('pages')
-                ->where(
-                    $queryBuilder->expr()->eq(
-                        $searchField,
-                        $queryBuilder->createNamedParameter($searchUid, \PDO::PARAM_INT)
-                    ),
-                    QueryHelper::stripLogicalOperatorPrefix($this->where_hid_del),
-                    QueryHelper::stripLogicalOperatorPrefix($this->where_groupAccess),
-                    QueryHelper::stripLogicalOperatorPrefix($additionalWhereClause)
-                )
-                ->execute()
-                ->fetchColumn();
-
-            if (!$count) {
-                $page = [];
-            }
-        } elseif ($dokType === self::DOKTYPE_SHORTCUT) {
-            // Neither shortcut target nor mode is set. Remove the page from the menu.
-            $page = [];
-        }
-        return $page;
-    }
-
-    /**
-     * Get page shortcut; Finds the records pointed to by input value $SC (the shortcut value)
-     *
-     * @param int $shortcutFieldValue The value of the "shortcut" field from the pages record
-     * @param int $shortcutMode 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 $iteration 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 ShortcutTargetPageNotFoundException
-     * @return mixed Returns the page record of the page that the shortcut pointed to.
-     * @internal
-     * @see getPageAndRootline()
-     */
-    public function getPageShortcut($shortcutFieldValue, $shortcutMode, $thisUid, $iteration = 20, $pageLog = [], $disableGroupCheck = false)
-    {
-        $idArray = GeneralUtility::intExplode(',', $shortcutFieldValue);
-        // Find $page record depending on shortcut mode:
-        switch ($shortcutMode) {
-            case self::SHORTCUT_MODE_FIRST_SUBPAGE:
-            case self::SHORTCUT_MODE_RANDOM_SUBPAGE:
-                $pageArray = $this->getMenu($idArray[0] ?: $thisUid, '*', 'sorting', 'AND pages.doktype<199 AND pages.doktype!=' . self::DOKTYPE_BE_USER_SECTION);
-                $pO = 0;
-                if ($shortcutMode == self::SHORTCUT_MODE_RANDOM_SUBPAGE && !empty($pageArray)) {
-                    $pO = (int)rand(0, count($pageArray) - 1);
-                }
-                $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 ShortcutTargetPageNotFoundException($message, 1301648328);
-                }
-                break;
-            case self::SHORTCUT_MODE_PARENT_PAGE:
-                $parent = $this->getPage($idArray[0] ?: $thisUid, $disableGroupCheck);
-                $page = $this->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 ShortcutTargetPageNotFoundException($message, 1301648358);
-                }
-                break;
-            default:
-                $page = $this->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 ShortcutTargetPageNotFoundException($message, 1301648404);
-                }
-        }
-        // Check if short cut page was a shortcut itself, if so look up recursively:
-        if ($page['doktype'] == self::DOKTYPE_SHORTCUT) {
-            if (!in_array($page['uid'], $pageLog) && $iteration > 0) {
-                $pageLog[] = $page['uid'];
-                $page = $this->getPageShortcut($page['shortcut'], $page['shortcut_mode'], $page['uid'], $iteration - 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;
-    }
-
-    /**
-     * Returns the redirect URL for the input page row IF the doktype is set to 3.
-     *
-     * @param array $pagerow The page row to return URL type for
-     * @return string|bool The URL from based on the data from "pages:url". False if not found.
-     */
-    public function getExtURL($pagerow)
-    {
-        if ((int)$pagerow['doktype'] === self::DOKTYPE_LINK) {
-            $redirectTo = $pagerow['url'];
-            $uI = parse_url($redirectTo);
-            // If relative path, prefix Site URL
-            // If it's a valid email without protocol, add "mailto:"
-            if (!($uI['scheme'] ?? false)) {
-                if (GeneralUtility::validEmail($redirectTo)) {
-                    $redirectTo = 'mailto:' . $redirectTo;
-                } elseif ($redirectTo[0] !== '/') {
-                    $redirectTo = GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . $redirectTo;
-                }
-            }
-            return $redirectTo;
-        }
-        return false;
-    }
-
-    /**
-     * Returns a MountPoint array for the specified page
-     *
-     * Does a recursive search if the mounted page should be a mount page
-     * itself.
-     *
-     * Note:
-     *
-     * Recursive mount points are not supported by all parts of the core.
-     * The usage is discouraged. They may be removed from this method.
-     *
-     * @see: https://decisions.typo3.org/t/supporting-or-prohibiting-recursive-mount-points/165/3
-     *
-     * An array will be returned if mount pages are enabled, the correct
-     * doktype (7) is set for page and there IS a mount_pid with a valid
-     * record.
-     *
-     * The optional page record must contain at least uid, pid, doktype,
-     * mount_pid,mount_pid_ol. If it is not supplied it will be looked up by
-     * the system at additional costs for the lookup.
-     *
-     * Returns FALSE if no mount point was found, "-1" if there should have been
-     * one, but no connection to it, otherwise an array with information
-     * about mount pid and modes.
-     *
-     * @param int $pageId Page id to do the lookup for.
-     * @param array|bool $pageRec Optional page record for the given page.
-     * @param array $prevMountPids Internal register to prevent lookup cycles.
-     * @param int $firstPageUid The first page id.
-     * @return mixed Mount point array or failure flags (-1, false).
-     * @see \TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuContentObject
-     */
-    public function getMountPointInfo($pageId, $pageRec = false, $prevMountPids = [], $firstPageUid = 0)
-    {
-        if (!$GLOBALS['TYPO3_CONF_VARS']['FE']['enable_mount_pids']) {
-            return false;
-        }
-        $cacheIdentifier = 'PageRepository_getMountPointInfo_' . $pageId;
-        $cache = $this->getRuntimeCache();
-        if ($cache->has($cacheIdentifier)) {
-            return $cache->get($cacheIdentifier);
-        }
-        $result = false;
-        // Get pageRec if not supplied:
-        if (!is_array($pageRec)) {
-            $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');
-            $queryBuilder->getRestrictions()
-                ->removeAll()
-                ->add(GeneralUtility::makeInstance(DeletedRestriction::class));
-
-            $pageRec = $queryBuilder->select('uid', 'pid', 'doktype', 'mount_pid', 'mount_pid_ol', 't3ver_state')
-                ->from('pages')
-                ->where(
-                    $queryBuilder->expr()->eq(
-                        'uid',
-                        $queryBuilder->createNamedParameter($pageId, \PDO::PARAM_INT)
-                    ),
-                    $queryBuilder->expr()->neq(
-                        'doktype',
-                        $queryBuilder->createNamedParameter(self::DOKTYPE_RECYCLER, \PDO::PARAM_INT)
-                    )
-                )
-                ->execute()
-                ->fetch();
-
-            // Only look for version overlay if page record is not supplied; This assumes
-            // that the input record is overlaid with preview version, if any!
-            $this->versionOL('pages', $pageRec);
-        }
-        // Set first Page uid:
-        if (!$firstPageUid) {
-            $firstPageUid = $pageRec['uid'];
-        }
-        // Look for mount pid value plus other required circumstances:
-        $mount_pid = (int)$pageRec['mount_pid'];
-        if (is_array($pageRec) && (int)$pageRec['doktype'] === self::DOKTYPE_MOUNTPOINT && $mount_pid > 0 && !in_array($mount_pid, $prevMountPids, true)) {
-            // Get the mount point record (to verify its general existence):
-            $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');
-            $queryBuilder->getRestrictions()
-                ->removeAll()
-                ->add(GeneralUtility::makeInstance(DeletedRestriction::class));
-
-            $mountRec = $queryBuilder->select('uid', 'pid', 'doktype', 'mount_pid', 'mount_pid_ol', 't3ver_state')
-                ->from('pages')
-                ->where(
-                    $queryBuilder->expr()->eq(
-                        'uid',
-                        $queryBuilder->createNamedParameter($mount_pid, \PDO::PARAM_INT)
-                    ),
-                    $queryBuilder->expr()->neq(
-                        'doktype',
-                        $queryBuilder->createNamedParameter(self::DOKTYPE_RECYCLER, \PDO::PARAM_INT)
-                    )
-                )
-                ->execute()
-                ->fetch();
-
-            $this->versionOL('pages', $mountRec);
-            if (is_array($mountRec)) {
-                // Look for recursive mount point:
-                $prevMountPids[] = $mount_pid;
-                $recursiveMountPid = $this->getMountPointInfo($mount_pid, $mountRec, $prevMountPids, $firstPageUid);
-                // Return mount point information:
-                $result = $recursiveMountPid ?: [
-                    'mount_pid' => $mount_pid,
-                    'overlay' => $pageRec['mount_pid_ol'],
-                    'MPvar' => $mount_pid . '-' . $firstPageUid,
-                    'mount_point_rec' => $pageRec,
-                    'mount_pid_rec' => $mountRec
-                ];
-            } else {
-                // Means, there SHOULD have been a mount point, but there was none!
-                $result = -1;
-            }
-        }
-        $cache->set($cacheIdentifier, $result);
-        return $result;
-    }
-
-    /********************************
-     *
-     * Selecting records in general
-     *
-     ********************************/
-
-    /**
-     * Checks if a record exists and is accessible.
-     * The row is returned if everything's OK.
-     *
-     * @param string $table The table name to search
-     * @param int $uid The uid to look up in $table
-     * @param bool|int $checkPage If checkPage is set, it's also required that the page on which the record resides is accessible
-     * @return array|int Returns array (the record) if OK, otherwise blank/0 (zero)
-     */
-    public function checkRecord($table, $uid, $checkPage = 0)
-    {
-        $uid = (int)$uid;
-        if (is_array($GLOBALS['TCA'][$table]) && $uid > 0) {
-            $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table);
-            $queryBuilder->setRestrictions(GeneralUtility::makeInstance(FrontendRestrictionContainer::class));
-            $row = $queryBuilder->select('*')
-                ->from($table)
-                ->where($queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT)))
-                ->execute()
-                ->fetch();
-
-            if ($row) {
-                $this->versionOL($table, $row);
-                if (is_array($row)) {
-                    if ($checkPage) {
-                        $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
-                            ->getQueryBuilderForTable('pages');
-                        $queryBuilder->setRestrictions(GeneralUtility::makeInstance(FrontendRestrictionContainer::class));
-                        $numRows = (int)$queryBuilder->count('*')
-                            ->from('pages')
-                            ->where(
-                                $queryBuilder->expr()->eq(
-                                    'uid',
-                                    $queryBuilder->createNamedParameter($row['pid'], \PDO::PARAM_INT)
-                                )
-                            )
-                            ->execute()
-                            ->fetchColumn();
-                        if ($numRows > 0) {
-                            return $row;
-                        }
-                        return 0;
-                    }
-                    return $row;
-                }
-            }
-        }
-        return 0;
-    }
-
-    /**
-     * Returns record no matter what - except if record is deleted
-     *
-     * @param string $table The table name to search
-     * @param int $uid The uid to look up in $table
-     * @param string $fields The fields to select, default is "*
-     * @return mixed Returns array (the record) if found, otherwise blank/0 (zero)
-     * @see getPage_noCheck()
-     */
-    public function getRawRecord($table, $uid, $fields = '*')
-    {
-        $uid = (int)$uid;
-        if (isset($GLOBALS['TCA'][$table]) && is_array($GLOBALS['TCA'][$table]) && $uid > 0) {
-            $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table);
-            $queryBuilder->getRestrictions()
-                ->removeAll()
-                ->add(GeneralUtility::makeInstance(DeletedRestriction::class));
-            $row = $queryBuilder->select(...GeneralUtility::trimExplode(',', $fields, true))
-                ->from($table)
-                ->where($queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT)))
-                ->execute()
-                ->fetch();
-
-            if ($row) {
-                $this->versionOL($table, $row);
-                if (is_array($row)) {
-                    return $row;
-                }
-            }
-        }
-        return 0;
-    }
-
-    /********************************
-     *
-     * Standard clauses
-     *
-     ********************************/
-
-    /**
-     * Returns a part of a WHERE clause which will filter out records with start/end
-     * times or hidden/fe_groups fields set to values that should de-select them
-     * according to the current time, preview settings or user login. Definitely a
-     * frontend function.
-     *
-     * Is using the $GLOBALS['TCA'] arrays "ctrl" part where the key "enablefields"
-     * determines for each table which of these features applies to that table.
-     *
-     * @param string $table Table name found in the $GLOBALS['TCA'] array
-     * @param int $show_hidden If $show_hidden is set (0/1), any hidden-fields in records are ignored. NOTICE: If you call this function, consider what to do with the show_hidden parameter. Maybe it should be set? See ContentObjectRenderer->enableFields where it's implemented correctly.
-     * @param array $ignore_array Array you can pass where keys can be "disabled", "starttime", "endtime", "fe_group" (keys from "enablefields" in TCA) and if set they will make sure that part of the clause is not added. Thus disables the specific part of the clause. For previewing etc.
-     * @throws \InvalidArgumentException
-     * @return string The clause starting like " AND ...=... AND ...=...
-     */
-    public function enableFields($table, $show_hidden = -1, $ignore_array = [])
-    {
-        if ($show_hidden === -1) {
-            // If show_hidden was not set from outside, use the current context
-            $show_hidden = (int)$this->context->getPropertyFromAspect('visibility', $table === 'pages' ? 'includeHiddenPages' : 'includeHiddenContent', false);
-        }
-        // If show_hidden was not changed during the previous evaluation, do it here.
-        $ctrl = $GLOBALS['TCA'][$table]['ctrl'] ?? null;
-        $expressionBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
-            ->getQueryBuilderForTable($table)
-            ->expr();
-        $constraints = [];
-        if (is_array($ctrl)) {
-            // Delete field check:
-            if ($ctrl['delete']) {
-                $constraints[] = $expressionBuilder->eq($table . '.' . $ctrl['delete'], 0);
-            }
-            if ($ctrl['versioningWS'] ?? false) {
-                if ($this->versioningWorkspaceId === 0) {
-                    // Filter out placeholder records (new/moved/deleted items)
-                    // in case we are NOT in a versioning preview (that means we are online!)
-                    $constraints[] = $expressionBuilder->lte(
-                        $table . '.t3ver_state',
-                        new VersionState(VersionState::DEFAULT_STATE)
-                    );
-                } elseif ($table !== 'pages') {
-                    // show only records of live and of the current workspace
-                    // in case we are in a versioning preview
-                    $constraints[] = $expressionBuilder->orX(
-                        $expressionBuilder->eq($table . '.t3ver_wsid', 0),
-                        $expressionBuilder->eq($table . '.t3ver_wsid', (int)$this->versioningWorkspaceId)
-                    );
-                }
-
-                // Filter out versioned records
-                if (empty($ignore_array['pid'])) {
-                    $constraints[] = $expressionBuilder->neq($table . '.pid', -1);
-                }
-            }
-
-            // Enable fields:
-            if (is_array($ctrl['enablecolumns'])) {
-                // In case of versioning-preview, enableFields are ignored (checked in
-                // versionOL())
-                if ($this->versioningWorkspaceId === 0 || !$ctrl['versioningWS']) {
-                    if (($ctrl['enablecolumns']['disabled'] ?? false) && !$show_hidden && !($ignore_array['disabled'] ?? false)) {
-                        $field = $table . '.' . $ctrl['enablecolumns']['disabled'];
-                        $constraints[] = $expressionBuilder->eq($field, 0);
-                    }
-                    if (($ctrl['enablecolumns']['starttime'] ?? false) && !($ignore_array['starttime'] ?? false)) {
-                        $field = $table . '.' . $ctrl['enablecolumns']['starttime'];
-                        $constraints[] = $expressionBuilder->lte($field, (int)$GLOBALS['SIM_ACCESS_TIME']);
-                    }
-                    if (($ctrl['enablecolumns']['endtime'] ?? false) && !($ignore_array['endtime'] ?? false)) {
-                        $field = $table . '.' . $ctrl['enablecolumns']['endtime'];
-                        $constraints[] = $expressionBuilder->orX(
-                            $expressionBuilder->eq($field, 0),
-                            $expressionBuilder->gt($field, (int)$GLOBALS['SIM_ACCESS_TIME'])
-                        );
-                    }
-                    if (($ctrl['enablecolumns']['fe_group'] ?? false) && !($ignore_array['fe_group'] ?? false)) {
-                        $field = $table . '.' . $ctrl['enablecolumns']['fe_group'];
-                        $constraints[] = QueryHelper::stripLogicalOperatorPrefix(
-                            $this->getMultipleGroupsWhereClause($field, $table)
-                        );
-                    }
-                    // Call hook functions for additional enableColumns
-                    // It is used by the extension ingmar_accessctrl which enables assigning more
-                    // than one usergroup to content and page records
-                    $_params = [
-                        'table' => $table,
-                        'show_hidden' => $show_hidden,
-                        'ignore_array' => $ignore_array,
-                        'ctrl' => $ctrl
-                    ];
-                    foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_page.php']['addEnableColumns'] ?? [] as $_funcRef) {
-                        $constraints[] = QueryHelper::stripLogicalOperatorPrefix(
-                            GeneralUtility::callUserFunction($_funcRef, $_params, $this)
-                        );
-                    }
-                }
-            }
-        } else {
-            throw new \InvalidArgumentException('There is no entry in the $TCA array for the table "' . $table . '". This means that the function enableFields() is called with an invalid table name as argument.', 1283790586);
-        }
-
-        return empty($constraints) ? '' : ' AND ' . $expressionBuilder->andX(...$constraints);
-    }
-
-    /**
-     * Creating where-clause for checking group access to elements in enableFields
-     * function
-     *
-     * @param string $field Field with group list
-     * @param string $table Table name
-     * @return string AND sql-clause
-     * @see enableFields()
-     */
-    public function getMultipleGroupsWhereClause($field, $table)
-    {
-        if (!$this->context->hasAspect('frontend.user')) {
-            return '';
-        }
-        /** @var UserAspect $userAspect */
-        $userAspect = $this->context->getAspect('frontend.user');
-        $memberGroups = $userAspect->getGroupIds();
-
-        $expressionBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
-            ->getQueryBuilderForTable($table)
-            ->expr();
-        $orChecks = [];
-        // If the field is empty, then OK
-        $orChecks[] = $expressionBuilder->eq($field, $expressionBuilder->literal(''));
-        // If the field is NULL, then OK
-        $orChecks[] = $expressionBuilder->isNull($field);
-        // If the field contains zero, then OK
-        $orChecks[] = $expressionBuilder->eq($field, $expressionBuilder->literal('0'));
-        foreach ($memberGroups as $value) {
-            $orChecks[] = $expressionBuilder->inSet($field, $expressionBuilder->literal($value));
-        }
-
-        return' AND (' . $expressionBuilder->orX(...$orChecks) . ')';
-    }
-
-    /**********************
-     *
-     * Versioning Preview
-     *
-     **********************/
-
-    /**
-     * Finding online PID for offline version record
-     *
-     * ONLY active when backend user is previewing records. MUST NEVER affect a site
-     * served which is not previewed by backend users!!!
-     *
-     * Will look if the "pid" value of the input record is -1 (it is an offline
-     * version) and if the table supports versioning; if so, it will translate the -1
-     * PID into the PID of the original record.
-     *
-     * Used whenever you are tracking something back, like making the root line.
-     *
-     * Principle; Record offline! => Find online?
-     *
-     * @param string $table Table name
-     * @param array $rr Record array passed by reference. As minimum, "pid" and "uid" fields must exist! "t3ver_oid" and "t3ver_wsid" is nice and will save you a DB query.
-     * @see BackendUtility::fixVersioningPid(), versionOL(), getRootLine()
-     */
-    public function fixVersioningPid($table, &$rr)
-    {
-        if ($this->versioningWorkspaceId > 0 && is_array($rr) && (int)$rr['pid'] === -1 && $GLOBALS['TCA'][$table]['ctrl']['versioningWS']) {
-            $oid = 0;
-            $wsid = 0;
-            // Check values for t3ver_oid and t3ver_wsid:
-            if (isset($rr['t3ver_oid']) && isset($rr['t3ver_wsid'])) {
-                // If "t3ver_oid" is already a field, just set this:
-                $oid = $rr['t3ver_oid'];
-                $wsid = $rr['t3ver_wsid'];
-            } else {
-                // Otherwise we have to expect "uid" to be in the record and look up based
-                // on this:
-                $uid = (int)$rr['uid'];
-                if ($uid > 0) {
-                    $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table);
-                    $queryBuilder->getRestrictions()
-                        ->removeAll()
-                        ->add(GeneralUtility::makeInstance(DeletedRestriction::class));
-                    $newPidRec = $queryBuilder->select('t3ver_oid', 't3ver_wsid')
-                        ->from($table)
-                        ->where($queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT)))
-                        ->execute()
-                        ->fetch();
-
-                    if (is_array($newPidRec)) {
-                        $oid = $newPidRec['t3ver_oid'];
-                        $wsid = $newPidRec['t3ver_wsid'];
-                    }
-                }
-            }
-            // If workspace ids matches and ID of current online version is found, look up
-            // the PID value of that:
-            if ($oid && (int)$wsid === (int)$this->versioningWorkspaceId) {
-                $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table);
-                $queryBuilder->getRestrictions()
-                    ->removeAll()
-                    ->add(GeneralUtility::makeInstance(DeletedRestriction::class));
-                $oidRec = $queryBuilder->select('pid')
-                    ->from($table)
-                    ->where($queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($oid, \PDO::PARAM_INT)))
-                    ->execute()
-                    ->fetch();
-
-                if (is_array($oidRec)) {
-                    // SWAP uid as well? Well no, because when fixing a versioning PID happens it is
-                    // assumed that this is a "branch" type page and therefore the uid should be
-                    // kept (like in versionOL()). However if the page is NOT a branch version it
-                    // should not happen - but then again, direct access to that uid should not
-                    // happen!
-                    $rr['_ORIG_pid'] = $rr['pid'];
-                    $rr['pid'] = $oidRec['pid'];
-                }
-            }
-        }
-        // Changing PID in case of moving pointer:
-        if ($movePlhRec = $this->getMovePlaceholder($table, $rr['uid'], 'pid')) {
-            $rr['pid'] = $movePlhRec['pid'];
-        }
-    }
-
-    /**
-     * Versioning Preview Overlay
-     *
-     * ONLY active when backend user is previewing records. MUST NEVER affect a site
-     * served which is not previewed by backend users!!!
-     *
-     * Generally ALWAYS used when records are selected based on uid or pid. If
-     * records are selected on other fields than uid or pid (eg. "email = ....") then
-     * usage might produce undesired results and that should be evaluated on
-     * individual basis.
-     *
-     * Principle; Record online! => Find offline?
-     *
-     * @param string $table Table name
-     * @param array $row Record array passed by reference. As minimum, the "uid", "pid" and "t3ver_state" fields must exist! The record MAY be set to FALSE in which case the calling function should act as if the record is forbidden to access!
-     * @param bool $unsetMovePointers If set, the $row is cleared in case it is a move-pointer. This is only for preview of moved records (to remove the record from the original location so it appears only in the new location)
-     * @param bool $bypassEnableFieldsCheck Unless this option is TRUE, the $row is unset if enablefields for BOTH the version AND the online record deselects it. This is because when versionOL() is called it is assumed that the online record is already selected with no regards to it's enablefields. However, after looking for a new version the online record enablefields must ALSO be evaluated of course. This is done all by this function!
-     * @see fixVersioningPid(), BackendUtility::workspaceOL()
-     */
-    public function versionOL($table, &$row, $unsetMovePointers = false, $bypassEnableFieldsCheck = false)
-    {
-        if ($this->versioningWorkspaceId > 0 && is_array($row)) {
-            // will overlay any movePlhOL found with the real record, which in turn
-            // will be overlaid with its workspace version if any.
-            $movePldSwap = $this->movePlhOL($table, $row);
-            // implode(',',array_keys($row)) = Using fields from original record to make
-            // sure no additional fields are selected. This is best for eg. getPageOverlay()
-            // Computed properties are excluded since those would lead to SQL errors.
-            $fieldNames = implode(',', array_keys($this->purgeComputedProperties($row)));
-            if ($wsAlt = $this->getWorkspaceVersionOfRecord($this->versioningWorkspaceId, $table, $row['uid'], $fieldNames, $bypassEnableFieldsCheck)) {
-                if (is_array($wsAlt)) {
-                    // Always fix PID (like in fixVersioningPid() above). [This is usually not
-                    // the important factor for versioning OL]
-                    // Keep the old (-1) - indicates it was a version...
-                    $wsAlt['_ORIG_pid'] = $wsAlt['pid'];
-                    // Set in the online versions PID.
-                    $wsAlt['pid'] = $row['pid'];
-                    // For versions of single elements or page+content, preserve online UID and PID
-                    // (this will produce true "overlay" of element _content_, not any references)
-                    // For page+content the "_ORIG_uid" should actually be used as PID for selection.
-                    $wsAlt['_ORIG_uid'] = $wsAlt['uid'];
-                    $wsAlt['uid'] = $row['uid'];
-                    // Changing input record to the workspace version alternative:
-                    $row = $wsAlt;
-                    // Check if it is deleted/new
-                    $rowVersionState = VersionState::cast($row['t3ver_state'] ?? null);
-                    if (
-                        $rowVersionState->equals(VersionState::NEW_PLACEHOLDER)
-                        || $rowVersionState->equals(VersionState::DELETE_PLACEHOLDER)
-                    ) {
-                        // Unset record if it turned out to be deleted in workspace
-                        $row = false;
-                    }
-                    // Check if move-pointer in workspace (unless if a move-placeholder is the
-                    // reason why it appears!):
-                    // You have to specifically set $unsetMovePointers in order to clear these
-                    // because it is normally a display issue if it should be shown or not.
-                    if (
-                        (
-                            $rowVersionState->equals(VersionState::MOVE_POINTER)
-                            && !$movePldSwap
-                        ) && $unsetMovePointers
-                    ) {
-                        // Unset record if it turned out to be deleted in workspace
-                        $row = false;
-                    }
-                } else {
-                    // No version found, then check if t3ver_state = VersionState::NEW_PLACEHOLDER
-                    // (online version is dummy-representation)
-                    // Notice, that unless $bypassEnableFieldsCheck is TRUE, the $row is unset if
-                    // enablefields for BOTH the version AND the online record deselects it. See
-                    // note for $bypassEnableFieldsCheck
-                    /** @var \TYPO3\CMS\Core\Versioning\VersionState $versionState */
-                    $versionState = VersionState::cast($row['t3ver_state']);
-                    if ($wsAlt <= -1 || $versionState->indicatesPlaceholder()) {
-                        // Unset record if it turned out to be "hidden"
-                        $row = false;
-                    }
-                }
-            }
-        }
-    }
-
-    /**
-     * Checks if record is a move-placeholder
-     * (t3ver_state==VersionState::MOVE_PLACEHOLDER) and if so it will set $row to be
-     * the pointed-to live record (and return TRUE) Used from versionOL
-     *
-     * @param string $table Table name
-     * @param array $row Row (passed by reference) - only online records...
-     * @return bool TRUE if overlay is made.
-     * @see BackendUtility::movePlhOl()
-     */
-    protected function movePlhOL($table, &$row)
-    {
-        if (!empty($GLOBALS['TCA'][$table]['ctrl']['versioningWS'])
-            && (int)VersionState::cast($row['t3ver_state'])->equals(VersionState::MOVE_PLACEHOLDER)
-        ) {
-            $moveID = 0;
-            // If t3ver_move_id is not found, then find it (but we like best if it is here)
-            if (!isset($row['t3ver_move_id'])) {
-                if ((int)$row['uid'] > 0) {
-                    $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table);
-                    $queryBuilder->getRestrictions()
-                        ->removeAll()
-                        ->add(GeneralUtility::makeInstance(DeletedRestriction::class));
-                    $moveIDRec = $queryBuilder->select('t3ver_move_id')
-                        ->from($table)
-                        ->where($queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($row['uid'], \PDO::PARAM_INT)))
-                        ->execute()
-                        ->fetch();
-
-                    if (is_array($moveIDRec)) {
-                        $moveID = $moveIDRec['t3ver_move_id'];
-                    }
-                }
-            } else {
-                $moveID = $row['t3ver_move_id'];
-            }
-            // Find pointed-to record.
-            if ($moveID) {
-                $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table);
-                $queryBuilder->setRestrictions(GeneralUtility::makeInstance(FrontendRestrictionContainer::class));
-                $origRow = $queryBuilder->select(...array_keys($this->purgeComputedProperties($row)))
-                    ->from($table)
-                    ->where(
-                        $queryBuilder->expr()->eq(
-                            'uid',
-                            $queryBuilder->createNamedParameter($moveID, \PDO::PARAM_INT)
-                        )
-                    )
-                    ->setMaxResults(1)
-                    ->execute()
-                    ->fetch();
-
-                if ($origRow) {
-                    $row = $origRow;
-                    return true;
-                }
-            }
-        }
-        return false;
-    }
-
-    /**
-     * Returns move placeholder of online (live) version
-     *
-     * @param string $table Table name
-     * @param int $uid Record UID of online version
-     * @param string $fields Field list, default is *
-     * @return array If found, the record, otherwise nothing.
-     * @see BackendUtility::getMovePlaceholder()
-     */
-    protected function getMovePlaceholder($table, $uid, $fields = '*')
-    {
-        $workspace = (int)$this->versioningWorkspaceId;
-        if (!empty($GLOBALS['TCA'][$table]['ctrl']['versioningWS']) && $workspace > 0) {
-            // Select workspace version of record:
-            $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table);
-            $queryBuilder->getRestrictions()
-                ->removeAll()
-                ->add(GeneralUtility::makeInstance(DeletedRestriction::class));
-
-            $row = $queryBuilder->select(...GeneralUtility::trimExplode(',', $fields, true))
-                ->from($table)
-                ->where(
-                    $queryBuilder->expr()->neq('pid', $queryBuilder->createNamedParameter(-1, \PDO::PARAM_INT)),
-                    $queryBuilder->expr()->eq(
-                        't3ver_state',
-                        $queryBuilder->createNamedParameter(
-                            (string)VersionState::cast(VersionState::MOVE_PLACEHOLDER),
-                            \PDO::PARAM_INT
-                        )
-                    ),
-                    $queryBuilder->expr()->eq(
-                        't3ver_move_id',
-                        $queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT)
-                    ),
-                    $queryBuilder->expr()->eq(
-                        't3ver_wsid',
-                        $queryBuilder->createNamedParameter($workspace, \PDO::PARAM_INT)
-                    )
-                )
-                ->setMaxResults(1)
-                ->execute()
-                ->fetch();
-
-            if (is_array($row)) {
-                return $row;
-            }
-        }
-        return false;
-    }
-
-    /**
-     * Select the version of a record for a workspace
-     *
-     * @param int $workspace Workspace ID
-     * @param string $table Table name to select from
-     * @param int $uid Record uid for which to find workspace version.
-     * @param string $fields Field list to select
-     * @param bool $bypassEnableFieldsCheck If TRUE, enablefields are not checked for.
-     * @return mixed If found, return record, otherwise other value: Returns 1 if version was sought for but not found, returns -1/-2 if record (offline/online) existed but had enableFields that would disable it. Returns FALSE if not in workspace or no versioning for record. Notice, that the enablefields of the online record is also tested.
-     * @see BackendUtility::getWorkspaceVersionOfRecord()
-     */
-    public function getWorkspaceVersionOfRecord($workspace, $table, $uid, $fields = '*', $bypassEnableFieldsCheck = false)
-    {
-        if ($workspace !== 0 && !empty($GLOBALS['TCA'][$table]['ctrl']['versioningWS'])) {
-            $workspace = (int)$workspace;
-            $uid = (int)$uid;
-            // Select workspace version of record, only testing for deleted.
-            $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table);
-            $queryBuilder->getRestrictions()
-                ->removeAll()
-                ->add(GeneralUtility::makeInstance(DeletedRestriction::class));
-
-            $newrow = $queryBuilder->select(...GeneralUtility::trimExplode(',', $fields, true))
-                ->from($table)
-                ->where(
-                    $queryBuilder->expr()->eq('pid', $queryBuilder->createNamedParameter(-1, \PDO::PARAM_INT)),
-                    $queryBuilder->expr()->eq(
-                        't3ver_oid',
-                        $queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT)
-                    ),
-                    $queryBuilder->expr()->eq(
-                        't3ver_wsid',
-                        $queryBuilder->createNamedParameter($workspace, \PDO::PARAM_INT)
-                    )
-                )
-                ->setMaxResults(1)
-                ->execute()
-                ->fetch();
-
-            // If version found, check if it could have been selected with enableFields on
-            // as well:
-            $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table);
-            $queryBuilder->setRestrictions(GeneralUtility::makeInstance(FrontendRestrictionContainer::class));
-            // Remove the frontend workspace restriction because we are testing a version record
-            $queryBuilder->getRestrictions()->removeByType(FrontendWorkspaceRestriction::class);
-            $queryBuilder->select('uid')
-                ->from($table)
-                ->setMaxResults(1);
-
-            if (is_array($newrow)) {
-                $queryBuilder->where(
-                    $queryBuilder->expr()->eq('pid', $queryBuilder->createNamedParameter(-1, \PDO::PARAM_INT)),
-                    $queryBuilder->expr()->eq(
-                        't3ver_oid',
-                        $queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT)
-                    ),
-                    $queryBuilder->expr()->eq(
-                        't3ver_wsid',
-                        $queryBuilder->createNamedParameter($workspace, \PDO::PARAM_INT)
-                    )
-                );
-                if ($bypassEnableFieldsCheck || $queryBuilder->execute()->fetchColumn()) {
-                    // Return offline version, tested for its enableFields.
-                    return $newrow;
-                }
-                // Return -1 because offline version was de-selected due to its enableFields.
-                return -1;
-            }
-            // OK, so no workspace version was found. Then check if online version can be
-            // selected with full enable fields and if so, return 1:
-            $queryBuilder->where(
-                $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT))
-                );
-            if ($bypassEnableFieldsCheck || $queryBuilder->execute()->fetchColumn()) {
-                // Means search was done, but no version found.
-                return 1;
-            }
-            // Return -2 because the online record was de-selected due to its enableFields.
-            return -2;
-        }
-        // No look up in database because versioning not enabled / or workspace not
-        // offline
-        return false;
-    }
-
-    /**
-     * Purges computed properties from database rows,
-     * such as _ORIG_uid or _ORIG_pid for instance.
-     *
-     * @param array $row
-     * @return array
-     */
-    protected function purgeComputedProperties(array $row)
-    {
-        foreach ($this->computedPropertyNames as $computedPropertyName) {
-            if (array_key_exists($computedPropertyName, $row)) {
-                unset($row[$computedPropertyName]);
-            }
-        }
-        return $row;
-    }
-
-    /**
-     * @return VariableFrontend
-     */
-    protected function getRuntimeCache(): VariableFrontend
-    {
-        return GeneralUtility::makeInstance(CacheManager::class)->getCache('runtime');
-    }
-}
diff --git a/typo3/sysext/frontend/Classes/Page/PageRepositoryGetPageHookInterface.php b/typo3/sysext/frontend/Classes/Page/PageRepositoryGetPageHookInterface.php
deleted file mode 100644 (file)
index 67af1df..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-<?php
-namespace TYPO3\CMS\Frontend\Page;
-
-/*
- * This file is part of the TYPO3 CMS project.
- *
- * It is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License, either version 2
- * of the License, or any later version.
- *
- * For the full copyright and license information, please read the
- * LICENSE.txt file that was distributed with this source code.
- *
- * The TYPO3 project - inspiring people to share!
- */
-
-/**
- * Interface for classes which hook into pageSelect and do additional getPage processing
- */
-interface PageRepositoryGetPageHookInterface
-{
-    /**
-     * Modifies the DB params
-     *
-     * @param int $uid The page ID
-     * @param bool $disableGroupAccessCheck If set, the check for group access is disabled. VERY rarely used
-     * @param \TYPO3\CMS\Frontend\Page\PageRepository $parentObject Parent object
-     */
-    public function getPage_preProcess(&$uid, &$disableGroupAccessCheck, PageRepository $parentObject);
-}
diff --git a/typo3/sysext/frontend/Classes/Page/PageRepositoryGetPageOverlayHookInterface.php b/typo3/sysext/frontend/Classes/Page/PageRepositoryGetPageOverlayHookInterface.php
deleted file mode 100644 (file)
index ef901d7..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-<?php
-namespace TYPO3\CMS\Frontend\Page;
-
-/*
- * This file is part of the TYPO3 CMS project.
- *
- * It is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License, either version 2
- * of the License, or any later version.
- *
- * For the full copyright and license information, please read the
- * LICENSE.txt file that was distributed with this source code.
- *
- * The TYPO3 project - inspiring people to share!
- */
-
-/**
- * Interface for classes which hook into \TYPO3\CMS\Frontend\Page\PageRepository
- */
-interface PageRepositoryGetPageOverlayHookInterface
-{
-    /**
-     * enables to preprocess the pageoverlay
-     *
-     * @param array $pageInput The page record
-     * @param int $lUid The overlay language
-     * @param \TYPO3\CMS\Frontend\Page\PageRepository $parent The calling parent object
-     */
-    public function getPageOverlay_preProcess(&$pageInput, &$lUid, PageRepository $parent);
-}
diff --git a/typo3/sysext/frontend/Classes/Page/PageRepositoryGetRecordOverlayHookInterface.php b/typo3/sysext/frontend/Classes/Page/PageRepositoryGetRecordOverlayHookInterface.php
deleted file mode 100644 (file)
index 43b497a..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-<?php
-namespace TYPO3\CMS\Frontend\Page;
-
-/*
- * This file is part of the TYPO3 CMS project.
- *
- * It is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License, either version 2
- * of the License, or any later version.
- *
- * For the full copyright and license information, please read the
- * LICENSE.txt file that was distributed with this source code.
- *
- * The TYPO3 project - inspiring people to share!
- */
-
-/**
- * Interface for classes which hook into \TYPO3\CMS\Frontend\Page\PageRepository
- */
-interface PageRepositoryGetRecordOverlayHookInterface
-{
-    /**
-     * Enables to preprocess a record overlay
-     *
-     * @param string $table
-     * @param array $row
-     * @param int $sys_language_content
-     * @param string $OLmode
-     * @param \TYPO3\CMS\Frontend\Page\PageRepository $parent
-     */
-    public function getRecordOverlay_preProcess($table, &$row, &$sys_language_content, $OLmode, PageRepository $parent);
-
-    /**
-     * Enables to postprocess a record overlay
-     *
-     * @param string $table
-     * @param array $row
-     * @param int $sys_language_content
-     * @param string $OLmode
-     * @param \TYPO3\CMS\Frontend\Page\PageRepository $parent
-     */
-    public function getRecordOverlay_postProcess($table, &$row, &$sys_language_content, $OLmode, PageRepository $parent);
-}
diff --git a/typo3/sysext/frontend/Classes/Page/PageRepositoryInitHookInterface.php b/typo3/sysext/frontend/Classes/Page/PageRepositoryInitHookInterface.php
deleted file mode 100644 (file)
index 8f3f08f..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<?php
-namespace TYPO3\CMS\Frontend\Page;
-
-/*
- * This file is part of the TYPO3 CMS project.
- *
- * It is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License, either version 2
- * of the License, or any later version.
- *
- * For the full copyright and license information, please read the
- * LICENSE.txt file that was distributed with this source code.
- *
- * The TYPO3 project - inspiring people to share!
- */
-
-/**
- * Interface for classes which hook into pageSelect and do additional getPage processing
- */
-interface PageRepositoryInitHookInterface
-{
-    /**
-     * Modifies the DB params
-     *
-     * @param \TYPO3\CMS\Frontend\Page\PageRepository $parentObject Parent object
-     */
-    public function init_postProcess(PageRepository $parentObject);
-}
index e184dc3..061e570 100644 (file)
@@ -16,6 +16,7 @@ namespace TYPO3\CMS\Frontend\Typolink;
  */
 
 use TYPO3\CMS\Core\Context\Context;
+use TYPO3\CMS\Core\Domain\Repository\PageRepository;
 use TYPO3\CMS\Core\Http\ServerRequestFactory;
 use TYPO3\CMS\Core\Routing\PageArguments;
 use TYPO3\CMS\Core\Service\DependencyOrderingService;
@@ -28,7 +29,6 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
 use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
 use TYPO3\CMS\Frontend\Http\UrlProcessorInterface;
-use TYPO3\CMS\Frontend\Page\PageRepository;
 
 /**
  * Abstract class to provide proper helper for most types necessary
index bc27af7..d0d9e9e 100644 (file)
@@ -23,6 +23,7 @@ use TYPO3\CMS\Core\Context\LanguageAspect;
 use TYPO3\CMS\Core\Context\LanguageAspectFactory;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
+use TYPO3\CMS\Core\Domain\Repository\PageRepository;
 use TYPO3\CMS\Core\Exception\Page\RootLineException;
 use TYPO3\CMS\Core\Exception\SiteNotFoundException;
 use TYPO3\CMS\Core\Routing\InvalidRouteArgumentsException;
@@ -35,7 +36,6 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
 use TYPO3\CMS\Core\Utility\RootlineUtility;
 use TYPO3\CMS\Frontend\ContentObject\TypolinkModifyLinkConfigForPageLinksHookInterface;
-use TYPO3\CMS\Frontend\Page\PageRepository;
 
 /**
  * Builds a TypoLink to a certain page
index 4ab102f..ad92c91 100644 (file)
@@ -251,7 +251,7 @@ return [
     ],
     'types' => [
         // normal
-        (string)\TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_DEFAULT => [
+        (string)\TYPO3\CMS\Core\Domain\Repository\PageRepository::DOKTYPE_DEFAULT => [
             'showitem' => '
                 --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general,
                     --palette--;;standard,
@@ -271,7 +271,7 @@ return [
             '
         ],
         // external URL
-        (string)\TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_LINK => [
+        (string)\TYPO3\CMS\Core\Domain\Repository\PageRepository::DOKTYPE_LINK => [
             'showitem' => '
                 --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general,
                     doktype,
@@ -291,7 +291,7 @@ return [
             '
         ],
         // shortcut
-        (string)\TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_SHORTCUT => [
+        (string)\TYPO3\CMS\Core\Domain\Repository\PageRepository::DOKTYPE_SHORTCUT => [
             'showitem' => '
                 --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general,
                     doktype,
@@ -312,7 +312,7 @@ return [
             '
         ],
         // mount page
-        (string)\TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_MOUNTPOINT => [
+        (string)\TYPO3\CMS\Core\Domain\Repository\PageRepository::DOKTYPE_MOUNTPOINT => [
             'showitem' => '
                 --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general,
                     --palette--;;standard,
@@ -331,7 +331,7 @@ return [
             '
         ],
         // spacer
-        (string)\TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_SPACER => [
+        (string)\TYPO3\CMS\Core\Domain\Repository\PageRepository::DOKTYPE_SPACER => [
             'showitem' => '
                 --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general,
                     --palette--;;standard,
@@ -345,7 +345,7 @@ return [
             '
         ],
         // sysfolder
-        (string)\TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_SYSFOLDER => [
+        (string)\TYPO3\CMS\Core\Domain\Repository\PageRepository::DOKTYPE_SYSFOLDER => [
             'showitem' => '
                 --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general,
                     --palette--;;standard,
@@ -360,7 +360,7 @@ return [
             '
         ],
         // trash
-        (string)\TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_RECYCLER => [
+        (string)\TYPO3\CMS\Core\Domain\Repository\PageRepository::DOKTYPE_RECYCLER => [
             'showitem' => '
                 --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general,
                     --palette--;;standard,
index 35e6341..f4801f6 100644 (file)
@@ -18,6 +18,7 @@ namespace TYPO3\CMS\Frontend\Tests\Functional\Configuration\TypoScript\Condition
 use Prophecy\Argument;
 use TYPO3\CMS\Core\Context\Context;
 use TYPO3\CMS\Core\Context\UserAspect;
+use TYPO3\CMS\Core\Domain\Repository\PageRepository;
 use TYPO3\CMS\Core\Http\ServerRequest;
 use TYPO3\CMS\Core\Log\Logger;
 use TYPO3\CMS\Core\Routing\PageArguments;
@@ -27,7 +28,6 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication;
 use TYPO3\CMS\Frontend\Configuration\TypoScript\ConditionMatching\ConditionMatcher;
 use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
-use TYPO3\CMS\Frontend\Page\PageRepository;
 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
 
 /**
index a31f79c..542c452 100644 (file)
@@ -16,6 +16,7 @@ namespace TYPO3\CMS\Frontend\Tests\Functional\ContentObject;
 
 use TYPO3\CMS\Core\Context\Context;
 use TYPO3\CMS\Core\Database\ConnectionPool;
+use TYPO3\CMS\Core\Domain\Repository\PageRepository;
 use TYPO3\CMS\Core\Routing\PageArguments;
 use TYPO3\CMS\Core\Site\SiteFinder;
 use TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait;
@@ -23,7 +24,6 @@ use TYPO3\CMS\Core\TypoScript\TemplateService;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
 use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
-use TYPO3\CMS\Frontend\Page\PageRepository;
 use TYPO3\CMS\Frontend\Typolink\PageLinkBuilder;
 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
 
index 9c25a5f..bb23ca7 100644 (file)
@@ -14,8 +14,8 @@ namespace TYPO3\CMS\Frontend\Tests\Functional\Controller;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Domain\Repository\PageRepository;
 use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
-use TYPO3\CMS\Frontend\Page\PageRepository;
 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
 
 /**
diff --git a/typo3/sysext/frontend/Tests/Functional/Fixtures/pages.xml b/typo3/sysext/frontend/Tests/Functional/Fixtures/pages.xml
deleted file mode 100644 (file)
index d709aa3..0000000
+++ /dev/null
@@ -1,143 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<dataset>
-    <pages>
-        <uid>1</uid>
-        <pid>0</pid>
-        <title>Root 1</title>
-        <deleted>0</deleted>
-        <slug>/</slug>
-        <perms_everybody>15</perms_everybody>
-    </pages>
-    <pages>
-        <uid>2</uid>
-        <pid>1</pid>
-        <title>Dummy 1-2</title>
-        <deleted>0</deleted>
-        <perms_everybody>15</perms_everybody>
-    </pages>
-    <pages>
-        <uid>3</uid>
-        <pid>1</pid>
-        <title>Dummy 1-3</title>
-        <deleted>0</deleted>
-        <perms_everybody>15</perms_everybody>
-    </pages>
-    <pages>
-        <uid>4</uid>
-        <pid>1</pid>
-        <title>Dummy 1-4</title>
-        <deleted>0</deleted>
-        <perms_everybody>15</perms_everybody>
-    </pages>
-    <pages>
-        <uid>5</uid>
-        <pid>2</pid>
-        <title>Dummy 1-2-5</title>
-        <deleted>0</deleted>
-        <perms_everybody>15</perms_everybody>
-    </pages>
-    <pages>
-        <uid>6</uid>
-        <pid>2</pid>
-        <title>Dummy 1-2-6</title>
-        <deleted>0</deleted>
-        <perms_everybody>15</perms_everybody>
-    </pages>
-    <pages>
-        <uid>7</uid>
-        <pid>2</pid>
-        <title>Dummy 1-2-7</title>
-        <deleted>0</deleted>
-        <perms_everybody>15</perms_everybody>
-    </pages>
-    <pages>
-        <uid>8</uid>
-        <pid>3</pid>
-        <title>Dummy 1-3-8</title>
-        <deleted>0</deleted>
-        <perms_everybody>15</perms_everybody>
-    </pages>
-    <pages>
-        <uid>9</uid>
-        <pid>3</pid>
-        <title>Dummy 1-3-9</title>
-        <deleted>0</deleted>
-        <perms_everybody>15</perms_everybody>
-    </pages>
-    <pages>
-        <uid>10</uid>
-        <pid>4</pid>
-        <title>Dummy 1-4-10</title>
-        <deleted>0</deleted>
-        <perms_everybody>15</perms_everybody>
-    </pages>
-    <pages>
-        <uid>11</uid>
-        <pid>0</pid>
-        <title>Workspace Root</title>
-        <deleted>0</deleted>
-        <t3ver_oid>0</t3ver_oid>
-        <t3ver_wsid>987654321</t3ver_wsid>
-        <t3ver_state>1</t3ver_state>
-        <perms_everybody>15</perms_everybody>
-    </pages>
-    <pages>
-        <uid>12</uid>
-        <pid>-1</pid>
-        <title>Workspace Root</title>
-        <deleted>0</deleted>
-        <t3ver_oid>11</t3ver_oid>
-        <t3ver_wsid>987654321</t3ver_wsid>
-        <t3ver_state>-1</t3ver_state>
-        <perms_everybody>15</perms_everybody>
-    </pages>
-
-    <pages>
-        <uid>901</uid>
-        <pid>0</pid>
-        <l10n_parent>1</l10n_parent>
-        <sys_language_uid>1</sys_language_uid>
-        <title>Wurzel 1</title>
-        <deleted>0</deleted>
-    </pages>
-    <pages>
-        <uid>902</uid>
-        <pid>1</pid>
-        <l10n_parent>2</l10n_parent>
-        <sys_language_uid>1</sys_language_uid>
-        <title>Attrappe 1-2</title>
-        <deleted>0</deleted>
-    </pages>
-    <pages>
-        <uid>903</uid>
-        <pid>1</pid>
-        <l10n_parent>3</l10n_parent>
-        <sys_language_uid>1</sys_language_uid>
-        <title>Attrappe 1-3</title>
-        <deleted>0</deleted>
-    </pages>
-    <pages>
-        <uid>904</uid>
-        <pid>2</pid>
-        <l10n_parent>5</l10n_parent>
-        <sys_language_uid>1</sys_language_uid>
-        <title>Attrappe 1-2-5</title>
-        <deleted>0</deleted>
-    </pages>
-    <pages>
-        <uid>905</uid>
-        <pid>2</pid>
-        <l10n_parent>6</l10n_parent>
-        <sys_language_uid>1</sys_language_uid>
-        <title>Attrappe 1-2-6</title>
-        <deleted>0</deleted>
-    </pages>
-    <pages>
-        <uid>906</uid>
-        <pid>3</pid>
-        <l10n_parent>9</l10n_parent>
-        <sys_language_uid>1</sys_language_uid>
-        <title>Attrappe 1-3-9</title>
-        <deleted>0</deleted>
-    </pages>
-</dataset>
diff --git a/typo3/sysext/frontend/Tests/Functional/Page/PageRepositoryTest.php b/typo3/sysext/frontend/Tests/Functional/Page/PageRepositoryTest.php
deleted file mode 100644 (file)
index f0a5485..0000000
+++ /dev/null
@@ -1,530 +0,0 @@
-<?php
-namespace TYPO3\CMS\Frontend\Tests\Functional\Page;
-
-/*
- * This file is part of the TYPO3 CMS project.
- *
- * It is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License, either version 2
- * of the License, or any later version.
- *
- * For the full copyright and license information, please read the
- * LICENSE.txt file that was distributed with this source code.
- *
- * The TYPO3 project - inspiring people to share!
- */
-
-use Prophecy\Argument;
-use TYPO3\CMS\Core\Context\Context;
-use TYPO3\CMS\Core\Context\LanguageAspect;
-use TYPO3\CMS\Core\Context\WorkspaceAspect;
-use TYPO3\CMS\Core\Database\ConnectionPool;
-use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Frontend\Page\PageRepository;
-use TYPO3\CMS\Frontend\Page\PageRepositoryGetPageHookInterface;
-
-/**
- * Test case
- */
-class PageRepositoryTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTestCase
-{
-    protected $coreExtensionsToLoad = ['frontend'];
-
-    protected function setUp(): void
-    {
-        parent::setUp();
-        $this->importDataSet(__DIR__ . '/../Fixtures/pages.xml');
-    }
-
-    /**
-     * @test
-     */
-    public function getMenuSingleUidRoot()
-    {
-        $subject = new PageRepository();
-        $rows = $subject->getMenu(1, 'uid, title');
-        $this->assertArrayHasKey(2, $rows);
-        $this->assertArrayHasKey(3, $rows);
-        $this->assertArrayHasKey(4, $rows);
-        $this->assertCount(3, $rows);
-    }
-
-    /**
-     * @test
-     */
-    public function getMenuSingleUidSubpage()
-    {
-        $subject = new PageRepository();
-        $rows = $subject->getMenu(2, 'uid, title');
-        $this->assertArrayHasKey(5, $rows);
-        $this->assertArrayHasKey(6, $rows);
-        $this->assertArrayHasKey(7, $rows);
-        $this->assertCount(3, $rows);
-    }
-
-    /**
-     * @test
-     */
-    public function getMenuMultipleUid()
-    {
-        $subject = new PageRepository();
-        $rows = $subject->getMenu([2, 3], 'uid, title');
-        $this->assertArrayHasKey(5, $rows);
-        $this->assertArrayHasKey(6, $rows);
-        $this->assertArrayHasKey(7, $rows);
-        $this->assertArrayHasKey(8, $rows);
-        $this->assertArrayHasKey(9, $rows);
-        $this->assertCount(5, $rows);
-    }
-
-    /**
-     * @test
-     */
-    public function getMenuPageOverlay()
-    {
-        $subject = new PageRepository(new Context([
-            'language' => new LanguageAspect(1)
-        ]));
-
-        $rows = $subject->getMenu([2, 3], 'uid, title');
-        $this->assertEquals('Attrappe 1-2-5', $rows[5]['title']);
-        $this->assertEquals('Attrappe 1-2-6', $rows[6]['title']);
-        $this->assertEquals('Dummy 1-2-7', $rows[7]['title']);
-        $this->assertEquals('Dummy 1-3-8', $rows[8]['title']);
-        $this->assertEquals('Attrappe 1-3-9', $rows[9]['title']);
-        $this->assertCount(5, $rows);
-    }
-
-    /**
-     * @test
-     */
-    public function getPageOverlayById()
-    {
-        $subject = new PageRepository();
-        $row = $subject->getPageOverlay(1, 1);
-        $this->assertOverlayRow($row);
-        $this->assertEquals('Wurzel 1', $row['title']);
-        $this->assertEquals('901', $row['_PAGES_OVERLAY_UID']);
-        $this->assertEquals(1, $row['_PAGES_OVERLAY_LANGUAGE']);
-    }
-
-    /**
-     * @test
-     */
-    public function getPageOverlayByIdWithoutTranslation()
-    {
-        $subject = new PageRepository();
-        $row = $subject->getPageOverlay(4, 1);
-        $this->assertIsArray($row);
-        $this->assertCount(0, $row);
-    }
-
-    /**
-     * @test
-     */
-    public function getPageOverlayByRow()
-    {
-        $subject = new PageRepository();
-        $orig = $subject->getPage(1);
-        $row = $subject->getPageOverlay($orig, 1);
-        $this->assertOverlayRow($row);
-        $this->assertEquals(1, $row['uid']);
-        $this->assertEquals('Wurzel 1', $row['title']);
-        $this->assertEquals('901', $row['_PAGES_OVERLAY_UID']);
-        $this->assertEquals(1, $row['_PAGES_OVERLAY_LANGUAGE']);
-    }
-
-    /**
-     * @test
-     */
-    public function getPageOverlayByRowWithoutTranslation()
-    {
-        $subject = new PageRepository();
-        $orig = $subject->getPage(4);
-        $row = $subject->getPageOverlay($orig, 1);
-        $this->assertIsArray($row);
-        $this->assertEquals(4, $row['uid']);
-        $this->assertEquals('Dummy 1-4', $row['title']);//original title
-    }
-
-    /**
-     * @test
-     */
-    public function getPagesOverlayByIdSingle()
-    {
-        $subject = new PageRepository(new Context([
-            'language' => new LanguageAspect(1)
-        ]));
-        $rows = $subject->getPagesOverlay([1]);
-        $this->assertIsArray($rows);
-        $this->assertCount(1, $rows);
-        $this->assertArrayHasKey(0, $rows);
-
-        $row = $rows[0];
-        $this->assertOverlayRow($row);
-        $this->assertEquals('Wurzel 1', $row['title']);
-        $this->assertEquals('901', $row['_PAGES_OVERLAY_UID']);
-        $this->assertEquals(1, $row['_PAGES_OVERLAY_LANGUAGE']);
-    }
-
-    /**
-     * @test
-     */
-    public function getPagesOverlayByIdMultiple()
-    {
-        $subject = new PageRepository(new Context([
-            'language' => new LanguageAspect(1)
-        ]));
-        $rows = $subject->getPagesOverlay([1, 5]);
-        $this->assertIsArray($rows);
-        $this->assertCount(2, $rows);
-        $this->assertArrayHasKey(0, $rows);
-        $this->assertArrayHasKey(1, $rows);
-
-        $row = $rows[0];
-        $this->assertOverlayRow($row);
-        $this->assertEquals('Wurzel 1', $row['title']);
-        $this->assertEquals('901', $row['_PAGES_OVERLAY_UID']);
-        $this->assertEquals(1, $row['_PAGES_OVERLAY_LANGUAGE']);
-
-        $row = $rows[1];
-        $this->assertOverlayRow($row);
-        $this->assertEquals('Attrappe 1-2-5', $row['title']);
-        $this->assertEquals('904', $row['_PAGES_OVERLAY_UID']);
-        $this->assertEquals(1, $row['_PAGES_OVERLAY_LANGUAGE']);
-    }
-
-    /**
-     * @test
-     */
-    public function getPagesOverlayByIdMultipleSomeNotOverlaid()
-    {
-        $subject = new PageRepository(new Context([
-            'language' => new LanguageAspect(1)
-        ]));
-        $rows = $subject->getPagesOverlay([1, 4, 5, 8]);
-        $this->assertIsArray($rows);
-        $this->assertCount(2, $rows);
-        $this->assertArrayHasKey(0, $rows);
-        $this->assertArrayHasKey(2, $rows);
-
-        $row = $rows[0];
-        $this->assertOverlayRow($row);
-        $this->assertEquals('Wurzel 1', $row['title']);
-
-        $row = $rows[2];
-        $this->assertOverlayRow($row);
-        $this->assertEquals('Attrappe 1-2-5', $row['title']);
-    }
-
-    /**
-     * @test
-     */
-    public function getPagesOverlayByRowSingle()
-    {
-        $subject = new PageRepository();
-        $origRow = $subject->getPage(1);
-
-        $subject = new PageRepository(new Context([
-            'language' => new LanguageAspect(1)
-        ]));
-        $rows = $subject->getPagesOverlay([$origRow]);
-        $this->assertIsArray($rows);
-        $this->assertCount(1, $rows);
-        $this->assertArrayHasKey(0, $rows);
-
-        $row = $rows[0];
-        $this->assertOverlayRow($row);
-        $this->assertEquals('Wurzel 1', $row['title']);
-        $this->assertEquals('901', $row['_PAGES_OVERLAY_UID']);
-        $this->assertEquals(1, $row['_PAGES_OVERLAY_LANGUAGE']);
-    }
-
-    /**
-     * @test
-     */
-    public function getPagesOverlayByRowMultiple()
-    {
-        $subject = new PageRepository();
-        $orig1 = $subject->getPage(1);
-        $orig2 = $subject->getPage(5);
-
-        $subject = new PageRepository(new Context([
-            'language' => new LanguageAspect(1)
-        ]));
-        $rows = $subject->getPagesOverlay([1 => $orig1, 5 => $orig2]);
-        $this->assertIsArray($rows);
-        $this->assertCount(2, $rows);
-        $this->assertArrayHasKey(1, $rows);
-        $this->assertArrayHasKey(5, $rows);
-
-        $row = $rows[1];
-        $this->assertOverlayRow($row);
-        $this->assertEquals('Wurzel 1', $row['title']);
-        $this->assertEquals('901', $row['_PAGES_OVERLAY_UID']);
-        $this->assertEquals(1, $row['_PAGES_OVERLAY_LANGUAGE']);
-
-        $row = $rows[5];
-        $this->assertOverlayRow($row);
-        $this->assertEquals('Attrappe 1-2-5', $row['title']);
-        $this->assertEquals('904', $row['_PAGES_OVERLAY_UID']);
-        $this->assertEquals(1, $row['_PAGES_OVERLAY_LANGUAGE']);
-    }
-
-    /**
-     * @test
-     */
-    public function getPagesOverlayByRowMultipleSomeNotOverlaid()
-    {
-        $subject = new PageRepository();
-        $orig1 = $subject->getPage(1);
-        $orig2 = $subject->getPage(7);
-        $orig3 = $subject->getPage(9);
-
-        $subject = new PageRepository(new Context([
-            'language' => new LanguageAspect(1)
-        ]));
-        $rows = $subject->getPagesOverlay([$orig1, $orig2, $orig3]);
-        $this->assertIsArray($rows);
-        $this->assertCount(3, $rows);
-        $this->assertArrayHasKey(0, $rows);
-        $this->assertArrayHasKey(1, $rows);
-        $this->assertArrayHasKey(2, $rows);
-
-        $row = $rows[0];
-        $this->assertOverlayRow($row);
-        $this->assertEquals('Wurzel 1', $row['title']);
-
-        $row = $rows[1];
-        $this->assertNotOverlayRow($row);
-        $this->assertEquals('Dummy 1-2-7', $row['title']);
-
-        $row = $rows[2];
-        $this->assertOverlayRow($row);
-        $this->assertEquals('Attrappe 1-3-9', $row['title']);
-    }
-
-    /**
-     * Tests whether the getPage Hook is called correctly.
-     *
-     * @test
-     */
-    public function isGetPageHookCalled()
-    {
-        // Create a hook mock object
-        $getPageHookProphet = $this->prophesize(\stdClass::class);
-        $getPageHookProphet->willImplement(PageRepositoryGetPageHookInterface::class);
-        $getPageHookProphet->getPage_preProcess(42, false, Argument::type(PageRepository::class))->shouldBeCalled();
-        $getPageHookMock = $getPageHookProphet->reveal();
-        $className = get_class($getPageHookMock);
-
-        // Register hook mock object
-        GeneralUtility::addInstance($className, $getPageHookMock);
-        $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_page.php']['getPage'][] = $className;
-        $subject = new PageRepository();
-        $subject->getPage(42, false);
-    }
-
-    /**
-     * @test
-     */
-    public function initSetsPublicPropertyCorrectlyForWorkspacePreview()
-    {
-        $workspaceId = 2;
-        $subject = new PageRepository(new Context([
-            'workspace' => new WorkspaceAspect($workspaceId)
-        ]));
-
-        $connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('pages');
-
-        $expectedSQL = sprintf(
-            ' AND (%s = 0) AND ((%s = 0) OR (%s = 2)) AND (%s < 200)',
-            $connection->quoteIdentifier('pages.deleted'),
-            $connection->quoteIdentifier('pages.t3ver_wsid'),
-            $connection->quoteIdentifier('pages.t3ver_wsid'),
-            $connection->quoteIdentifier('pages.doktype')
-        );
-
-        $this->assertSame($expectedSQL, $subject->where_hid_del);
-    }
-
-    /**
-     * @test
-     */
-    public function initSetsPublicPropertyCorrectlyForLive()
-    {
-        $GLOBALS['SIM_ACCESS_TIME'] = 123;
-
-        $subject = new PageRepository(new Context());
-
-        $connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('pages');
-        $expectedSQL = sprintf(
-            ' AND ((%s = 0) AND (%s <= 0) AND (%s <> -1) AND (%s = 0) AND (%s <= 123) AND ((%s = 0) OR (%s > 123))) AND (%s < 200)',
-            $connection->quoteIdentifier('pages.deleted'),
-            $connection->quoteIdentifier('pages.t3ver_state'),
-            $connection->quoteIdentifier('pages.pid'),
-            $connection->quoteIdentifier('pages.hidden'),
-            $connection->quoteIdentifier('pages.starttime'),
-            $connection->quoteIdentifier('pages.endtime'),
-            $connection->quoteIdentifier('pages.endtime'),
-            $connection->quoteIdentifier('pages.doktype')
-        );
-
-        $this->assertSame($expectedSQL, $subject->where_hid_del);
-    }
-
-    ////////////////////////////////
-    // Tests concerning workspaces
-    ////////////////////////////////
-
-    /**
-     * @test
-     */
-    public function previewShowsPagesFromLiveAndCurrentWorkspace()
-    {
-        // initialization
-        $wsid = 987654321;
-        // simulate calls from \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController->fetch_the_id()
-        $subject = new PageRepository(new Context([
-            'workspace' => new WorkspaceAspect($wsid)
-        ]));
-
-        $pageRec = $subject->getPage(11);
-
-        $this->assertEquals(11, $pageRec['uid']);
-        $this->assertEquals(11, $pageRec['t3ver_oid']);
-        $this->assertEquals(987654321, $pageRec['t3ver_wsid']);
-        $this->assertEquals(-1, $pageRec['t3ver_state']);
-    }
-
-    /**
-     * @test
-     */
-    public function getWorkspaceVersionReturnsTheCorrectMethod()
-    {
-        // initialization
-        $wsid = 987654321;
-
-        // simulate calls from \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController->fetch_the_id()
-        $subject = new PageRepository(new Context([
-            'workspace' => new WorkspaceAspect($wsid)
-        ]));
-
-        $pageRec = $subject->getWorkspaceVersionOfRecord($wsid, 'pages', 11);
-
-        $this->assertEquals(12, $pageRec['uid']);
-        $this->assertEquals(11, $pageRec['t3ver_oid']);
-        $this->assertEquals(987654321, $pageRec['t3ver_wsid']);
-        $this->assertEquals(-1, $pageRec['t3ver_state']);
-    }
-
-    ////////////////////////////////
-    // Tests concerning versioning
-    ////////////////////////////////
-
-    /**
-     * @test
-     */
-    public function enableFieldsHidesVersionedRecordsAndPlaceholders()
-    {
-        $table = $this->getUniqueId('aTable');
-        $GLOBALS['TCA'][$table] = [
-            'ctrl' => [
-                'versioningWS' => true
-            ]
-        ];
-
-        $subject = new PageRepository(new Context());
-
-        $conditions = $subject->enableFields($table);
-        $connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable($table);
-
-        $this->assertThat(
-            $conditions,
-            $this->stringContains(' AND (' . $connection->quoteIdentifier($table . '.t3ver_state') . ' <= 0)'),
-            'Versioning placeholders'
-        );
-        $this->assertThat(
-            $conditions,
-            $this->stringContains(' AND (' . $connection->quoteIdentifier($table . '.pid') . ' <> -1)'),
-            'Records from page -1'
-        );
-    }
-
-    /**
-     * @test
-     */
-    public function enableFieldsDoesNotHidePlaceholdersInPreview()
-    {
-        $table = $this->getUniqueId('aTable');
-        $GLOBALS['TCA'][$table] = [
-            'ctrl' => [
-                'versioningWS' => true
-            ]
-        ];
-
-        $subject = new PageRepository(new Context([
-            'workspace' => new WorkspaceAspect(13)
-        ]));
-
-        $conditions = $subject->enableFields($table);
-        $connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable($table);
-
-        $this->assertThat(
-            $conditions,
-            $this->logicalNot($this->stringContains(' AND (' . $connection->quoteIdentifier($table . '.t3ver_state') . ' <= 0)')),
-            'No versioning placeholders'
-        );
-        $this->assertThat(
-            $conditions,
-            $this->stringContains(' AND (' . $connection->quoteIdentifier($table . '.pid') . ' <> -1)'),
-            'Records from page -1'
-        );
-    }
-
-    /**
-     * @test
-     */
-    public function enableFieldsDoesFilterToCurrentAndLiveWorkspaceForRecordsInPreview()
-    {
-        $table = $this->getUniqueId('aTable');
-        $GLOBALS['TCA'][$table] = [
-            'ctrl' => [
-                'versioningWS' => true
-            ]
-        ];
-
-        $subject = new PageRepository(new Context([
-            'workspace' => new WorkspaceAspect(2)
-        ]));
-
-        $conditions = $subject->enableFields($table);
-        $connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable($table);
-
-        $this->assertThat(
-            $conditions,
-            $this->stringContains(' AND ((' . $connection->quoteIdentifier($table . '.t3ver_wsid') . ' = 0) OR (' . $connection->quoteIdentifier($table . '.t3ver_wsid') . ' = 2))'),
-            'No versioning placeholders'
-        );
-    }
-
-    protected function assertOverlayRow($row)
-    {
-        $this->assertIsArray($row);
-
-        $this->assertArrayHasKey('_PAGES_OVERLAY', $row);
-        $this->assertArrayHasKey('_PAGES_OVERLAY_UID', $row);
-        $this->assertArrayHasKey('_PAGES_OVERLAY_LANGUAGE', $row);
-
-        $this->assertTrue($row['_PAGES_OVERLAY']);
-    }
-
-    protected function assertNotOverlayRow($row)
-    {
-        $this->assertIsArray($row);
-
-        $this->assertFalse(isset($row['_PAGES_OVERLAY']));
-        $this->assertFalse(isset($row['_PAGES_OVERLAY_UID']));
-        $this->assertFalse(isset($row['_PAGES_OVERLAY_LANGUAGE']));
-    }
-}
index 5f3f9dd..53b8829 100644 (file)
@@ -75,7 +75,7 @@ class UriPrefixRenderingTest extends FunctionalTestCase
     protected function setUp(): void
     {
         parent::setUp();
-        $this->importDataSet('EXT:frontend/Tests/Functional/Fixtures/pages.xml');
+        $this->importDataSet('EXT:core/Tests/Functional/Fixtures/pages.xml');
         $this->writeSiteConfiguration(
             'test',
             $this->buildSiteConfiguration(1, '/'),
index 1710809..082e0d7 100644 (file)
@@ -15,9 +15,9 @@ namespace TYPO3\CMS\Frontend\Tests\Functional\Tca;
  */
 
 use TYPO3\CMS\Backend\Tests\Functional\Form\FormTestService;
+use TYPO3\CMS\Core\Domain\Repository\PageRepository;
 use TYPO3\CMS\Core\Localization\LanguageService;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Frontend\Page\PageRepository;
 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
 
 class PagesLanguageOverlayVisibleFieldsTest extends FunctionalTestCase
index 7f64af3..c380f79 100644 (file)
@@ -25,6 +25,7 @@ use TYPO3\CMS\Core\Context\Context;
 use TYPO3\CMS\Core\Context\UserAspect;
 use TYPO3\CMS\Core\Context\WorkspaceAspect;
 use TYPO3\CMS\Core\Core\ApplicationContext;
+use TYPO3\CMS\Core\Domain\Repository\PageRepository;
 use TYPO3\CMS\Core\Http\ServerRequest;
 use TYPO3\CMS\Core\Http\Uri;
 use TYPO3\CMS\Core\LinkHandling\LinkService;
@@ -66,7 +67,6 @@ use TYPO3\CMS\Frontend\ContentObject\TextContentObject;
 use TYPO3\CMS\Frontend\ContentObject\UserContentObject;
 use TYPO3\CMS\Frontend\ContentObject\UserInternalContentObject;
 use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
-use TYPO3\CMS\Frontend\Page\PageRepository;
 use TYPO3\TestingFramework\Core\AccessibleObjectInterface;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
index 76abf1a..4cb0e2b 100644 (file)
@@ -22,13 +22,13 @@ use TYPO3\CMS\Core\Context\LanguageAspect;
 use TYPO3\CMS\Core\Database\Connection;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Database\Query\Expression\ExpressionBuilder;
+use TYPO3\CMS\Core\Domain\Repository\PageRepository;
 use TYPO3\CMS\Core\Http\ServerRequest;
 use TYPO3\CMS\Core\Routing\PageArguments;
 use TYPO3\CMS\Core\Site\Entity\Site;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
 use TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuContentObject;
-use TYPO3\CMS\Frontend\Page\PageRepository;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
index 2dff952..83c4c63 100644 (file)
@@ -18,12 +18,12 @@ namespace TYPO3\CMS\Frontend\Tests\Unit\Controller;
 use TYPO3\CMS\Core\Cache\Backend\NullBackend;
 use TYPO3\CMS\Core\Cache\CacheManager;
 use TYPO3\CMS\Core\Context\Context;
+use TYPO3\CMS\Core\Domain\Repository\PageRepository;
 use TYPO3\CMS\Core\Http\ServerRequestFactory;
 use TYPO3\CMS\Core\Page\PageRenderer;
 use TYPO3\CMS\Core\PageTitle\PageTitleProviderManager;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
-use TYPO3\CMS\Frontend\Page\PageRepository;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
diff --git a/typo3/sysext/frontend/Tests/Unit/Page/PageRepositoryTest.php b/typo3/sysext/frontend/Tests/Unit/Page/PageRepositoryTest.php
deleted file mode 100644 (file)
index dc93174..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-<?php
-namespace TYPO3\CMS\Frontend\Tests\Unit\Page;
-
-/*
- * This file is part of the TYPO3 CMS project.
- *
- * It is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License, either version 2
- * of the License, or any later version.
- *
- * For the full copyright and license information, please read the
- * LICENSE.txt file that was distributed with this source code.
- *
- * The TYPO3 project - inspiring people to share!
- */
-
-use TYPO3\CMS\Core\Context\Context;
-use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
-
-/**
- * Test case
- */
-class PageRepositoryTest extends UnitTestCase
-{
-    /**
-     * @var \TYPO3\CMS\Frontend\Page\PageRepository|\TYPO3\TestingFramework\Core\AccessibleObjectInterface
-     */
-    protected $pageSelectObject;
-
-    protected $defaultTcaForPages = [
-        'ctrl' => [
-            'label' => 'title',
-            'tstamp' => 'tstamp',
-            'sortby' => 'sorting',
-            'type' => 'doktype',
-            'versioningWS' => true,
-            'origUid' => 't3_origuid',
-            'delete' => 'deleted',
-            'enablecolumns' => [
-                'disabled' => 'hidden',
-                'starttime' => 'starttime',
-                'endtime' => 'endtime',
-                'fe_group' => 'fe_group'
-            ],
-        ],
-        'columns' => []
-    ];
-
-    /**
-     * Sets up this testcase
-     */
-    protected function setUp(): void
-    {
-        parent::setUp();
-        $this->pageSelectObject = $this->getAccessibleMock(\TYPO3\CMS\Frontend\Page\PageRepository::class, ['getMultipleGroupsWhereClause'], [], '', false);
-        $this->pageSelectObject->_set('context', new Context());
-        $this->pageSelectObject->expects($this->any())->method('getMultipleGroupsWhereClause')->will($this->returnValue(' AND 1=1'));
-    }
-
-    ///////////////////////////////
-    // Tests concerning getExtURL
-    ///////////////////////////////
-    /**
-     * @test
-     */
-    public function getExtUrlForDokType3UsesTheSameValue()
-    {
-        $this->assertEquals('http://www.example.com', $this->pageSelectObject->getExtURL([
-            'doktype' => \TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_LINK,
-            'url' => 'http://www.example.com'
-        ]));
-    }
-
-    /**
-     * @test
-     */
-    public function getExtUrlForDokType3PrependsSiteUrl()
-    {
-        $this->assertEquals(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . 'hello/world/', $this->pageSelectObject->getExtURL([
-            'doktype' => \TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_LINK,
-            'url' => 'hello/world/'
-        ]));
-    }
-
-    /**
-     * @test
-     */
-    public function getExtUrlForDokType3AssumesAbsoluteUrl()
-    {
-        $this->assertEquals('/hello/world/', $this->pageSelectObject->getExtURL([
-            'doktype' => \TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_LINK,
-            'url' => '/hello/world/'
-        ]));
-    }
-
-    /**
-     * @test
-     */
-    public function getExtUrlForDokType3UsesEmailAsSameValue()
-    {
-        $this->assertEquals('mailto:mail@typo3-test.com', $this->pageSelectObject->getExtURL([
-            'doktype' => \TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_LINK,
-            'url' => 'mailto:mail@typo3-test.com'
-        ]));
-    }
-
-    /**
-     * @test
-     */
-    public function getExtUrlForDokType3UsesValidEmailWithoutProtocolAsEmail()
-    {
-        $this->assertEquals('mailto:mail@typo3-test.com', $this->pageSelectObject->getExtURL([
-            'doktype' => \TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_LINK,
-            'url' => 'mail@typo3-test.com'
-        ]));
-    }
-}
index c318c9d..e4b63c5 100644 (file)
@@ -17,11 +17,11 @@ namespace TYPO3\CMS\Frontend\Tests\Unit\Typolink;
  */
 
 use Prophecy\Argument;
+use TYPO3\CMS\Core\Domain\Repository\PageRepository;
 use TYPO3\CMS\Core\TypoScript\TemplateService;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
 use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
-use TYPO3\CMS\Frontend\Page\PageRepository;
 use TYPO3\CMS\Frontend\Typolink\DatabaseRecordLinkBuilder;
 use TYPO3\CMS\Frontend\Typolink\UnableToLinkException;
 use TYPO3\CMS\Recordlist\LinkHandler\RecordLinkHandler;
index 1dbb728..4edcdce 100644 (file)
@@ -19,6 +19,7 @@ use TYPO3\CMS\Core\Context\Context;
 use TYPO3\CMS\Core\Database\Connection;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Database\Query\Restriction\FrontendRestrictionContainer;
+use TYPO3\CMS\Core\Domain\Repository\PageRepository;
 use TYPO3\CMS\Core\Exception\Page\RootLineException;
 use TYPO3\CMS\Core\Exception\SiteNotFoundException;
 use TYPO3\CMS\Core\Html\HtmlParser;
@@ -32,7 +33,6 @@ use TYPO3\CMS\Core\Utility\PathUtility;
 use TYPO3\CMS\Core\Utility\RootlineUtility;
 use TYPO3\CMS\Extbase\Annotation as Extbase;
 use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
-use TYPO3\CMS\Frontend\Page\PageRepository;
 
 /**
  * Index search frontend
index 772a754..a90bd08 100644 (file)
@@ -1281,4 +1281,29 @@ return [
             'Breaking-88500-RTEImageHandlingFunctionalityDropped.rst'
         ],
     ],
+    'TYPO3\CMS\Frontend\Page\PageRepository' => [
+        'restFiles' => [
+            'Deprecation-88746-PageRepositoryPHPClassMovedFromFrontendToCoreExtension.rst'
+        ],
+    ],
+    'TYPO3\CMS\Frontend\Page\PageRepositoryGetPageHookInterface' => [
+        'restFiles' => [
+            'Deprecation-88746-PageRepositoryPHPClassMovedFromFrontendToCoreExtension.rst'
+        ],
+    ],
+    'TYPO3\CMS\Frontend\Page\PageRepositoryGetPageOverlayHookInterface' => [
+        'restFiles' => [
+            'Deprecation-88746-PageRepositoryPHPClassMovedFromFrontendToCoreExtension.rst'
+        ],
+    ],
+    'TYPO3\CMS\Frontend\Page\PageRepositoryGetRecordOverlayHookInterface' => [
+        'restFiles' => [
+            'Deprecation-88746-PageRepositoryPHPClassMovedFromFrontendToCoreExtension.rst'
+        ],
+    ],
+    'TYPO3\CMS\Frontend\Page\PageRepositoryInitHookInterface' => [
+        'restFiles' => [
+            'Deprecation-88746-PageRepositoryPHPClassMovedFromFrontendToCoreExtension.rst'
+        ],
+    ],
 ];
index 5906464..fb04a24 100644 (file)
@@ -31,6 +31,7 @@ use TYPO3\CMS\Core\Database\Query\QueryHelper;
 use TYPO3\CMS\Core\Database\Query\Restriction\BackendWorkspaceRestriction;
 use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
 use TYPO3\CMS\Core\Database\ReferenceIndex;
+use TYPO3\CMS\Core\Domain\Repository\PageRepository;
 use TYPO3\CMS\Core\Imaging\Icon;
 use TYPO3\CMS\Core\Imaging\IconFactory;
 use TYPO3\CMS\Core\LinkHandling\Exception\UnknownLinkHandlerException;
@@ -47,7 +48,6 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\HttpUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
 use TYPO3\CMS\Core\Versioning\VersionState;
-use TYPO3\CMS\Frontend\Page\PageRepository;
 
 /**
  * Class for rendering of Web>List module
index dfbc2ed..6b5b4ca 100644 (file)
@@ -16,10 +16,10 @@ namespace TYPO3\CMS\Seo\Canonical;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Domain\Repository\PageRepository;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extbase\SignalSlot\Dispatcher;
 use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
-use TYPO3\CMS\Frontend\Page\PageRepository;
 use TYPO3\CMS\Frontend\Utility\CanonicalizationUtility;
 
 /**
index a8290fe..30afbfb 100644 (file)
@@ -21,9 +21,9 @@ use TYPO3\CMS\Core\Context\Context;
 use TYPO3\CMS\Core\Context\LanguageAspect;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Database\Query\QueryHelper;
+use TYPO3\CMS\Core\Domain\Repository\PageRepository;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
-use TYPO3\CMS\Frontend\Page\PageRepository;
 
 /**
  * Class to generate a XML sitemap for pages
index 613cb21..d7d0595 100644 (file)
@@ -297,6 +297,6 @@ $GLOBALS['TCA']['pages'] = array_replace_recursive($GLOBALS['TCA']['pages'], $tc
     --div--;LLL:EXT:seo/Resources/Private/Language/locallang_tca.xlf:pages.tabs.socialmedia,
         --palette--;;opengraph,
         --palette--;;twittercards',
-    (string)\TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_DEFAULT,
+    (string)\TYPO3\CMS\Core\Domain\Repository\PageRepository::DOKTYPE_DEFAULT,
     'after:title'
 );
index 94f780d..9788ebc 100644 (file)
@@ -18,13 +18,13 @@ namespace TYPO3\CMS\Seo\Tests\Functional\Canonical;
 
 use Psr\Log\NullLogger;
 use TYPO3\CMS\Core\Context\Context;
+use TYPO3\CMS\Core\Domain\Repository\PageRepository;
 use TYPO3\CMS\Core\Routing\PageArguments;
 use TYPO3\CMS\Core\Site\SiteFinder;
 use TYPO3\CMS\Core\TypoScript\TemplateService;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
 use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
-use TYPO3\CMS\Frontend\Page\PageRepository;
 use TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\AbstractTestCase;
 use TYPO3\CMS\Seo\Canonical\CanonicalGenerator;
 
index 2d17723..1930532 100644 (file)
@@ -22,6 +22,7 @@ use TYPO3\CMS\Backend\Template\ModuleTemplate;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
 use TYPO3\CMS\Core\Context\LanguageAspectFactory;
+use TYPO3\CMS\Core\Domain\Repository\PageRepository;
 use TYPO3\CMS\Core\Exception\SiteNotFoundException;
 use TYPO3\CMS\Core\Http\HtmlResponse;
 use TYPO3\CMS\Core\Imaging\Icon;
@@ -38,7 +39,6 @@ use TYPO3\CMS\Core\Type\Bitmask\Permission;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extbase\Mvc\View\ViewInterface;
 use TYPO3\CMS\Fluid\View\StandaloneView;
-use TYPO3\CMS\Frontend\Page\PageRepository;
 
 /**
  * Controller for viewing the frontend