|
|
@@ -2,9 +2,11 @@
|
|
|
namespace Opentalent\OtOptimizer\XClass\Core\Routing;
|
|
|
|
|
|
use Doctrine\DBAL\Connection;
|
|
|
+use TYPO3\CMS\Core\Context\LanguageAspect;
|
|
|
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\Database\Query\Restriction\WorkspaceRestriction;
|
|
|
use TYPO3\CMS\Core\Domain\Repository\PageRepository;
|
|
|
use TYPO3\CMS\Core\Exception\SiteNotFoundException;
|
|
|
use TYPO3\CMS\Core\Routing\PageSlugCandidateProvider;
|
|
|
@@ -66,22 +68,22 @@ class OtPageSlugCandidateProvider extends PageSlugCandidateProvider
|
|
|
*/
|
|
|
protected function getPagesFromDatabaseForCandidates(array $slugCandidates, int $languageId, array $excludeUids = []): array
|
|
|
{
|
|
|
- $searchLiveRecordsOnly = $this->context->getPropertyFromAspect('workspace', 'isLive');
|
|
|
+ $workspaceId = (int)$this->context->getPropertyFromAspect('workspace', 'id');
|
|
|
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
|
|
|
->getQueryBuilderForTable('pages');
|
|
|
$queryBuilder
|
|
|
->getRestrictions()
|
|
|
->removeAll()
|
|
|
->add(GeneralUtility::makeInstance(DeletedRestriction::class))
|
|
|
- ->add(GeneralUtility::makeInstance(FrontendWorkspaceRestriction::class, null, null, $searchLiveRecordsOnly));
|
|
|
+ ->add(GeneralUtility::makeInstance(WorkspaceRestriction::class, $workspaceId, true));
|
|
|
|
|
|
$statement = $queryBuilder
|
|
|
- ->select('uid', 'l10n_parent', 'pid', 'slug', 'mount_pid', 'mount_pid_ol', 't3ver_state', 'doktype', 't3ver_wsid', 't3ver_oid')
|
|
|
+ ->select('uid', 'sys_language_uid', 'l10n_parent', 'l18n_cfg', 'pid', 'slug', 'mount_pid', 'mount_pid_ol', 't3ver_state', 'doktype', 't3ver_wsid', 't3ver_oid')
|
|
|
->from('pages')
|
|
|
->where(
|
|
|
$queryBuilder->expr()->eq(
|
|
|
'sys_language_uid',
|
|
|
- $queryBuilder->createNamedParameter($languageId, \PDO::PARAM_INT)
|
|
|
+ $queryBuilder->createNamedParameter($languageId, \TYPO3\CMS\Core\Database\Connection::PARAM_INT)
|
|
|
),
|
|
|
$queryBuilder->expr()->in(
|
|
|
'slug',
|
|
|
@@ -93,10 +95,12 @@ class OtPageSlugCandidateProvider extends PageSlugCandidateProvider
|
|
|
)
|
|
|
// Exact match will be first, that's important
|
|
|
->orderBy('slug', 'desc')
|
|
|
+ // versioned records should be rendered before the live records
|
|
|
+ ->addOrderBy('t3ver_wsid', 'desc')
|
|
|
// Sort pages that are not MountPoint pages before mount points
|
|
|
->addOrderBy('mount_pid_ol', 'asc')
|
|
|
->addOrderBy('mount_pid', 'asc')
|
|
|
- ->execute();
|
|
|
+ ->executeQuery();
|
|
|
|
|
|
$pages = [];
|
|
|
$siteFinder = GeneralUtility::makeInstance(SiteFinder::class);
|
|
|
@@ -104,34 +108,30 @@ class OtPageSlugCandidateProvider extends PageSlugCandidateProvider
|
|
|
$isRecursiveCall = !empty($excludeUids);
|
|
|
|
|
|
// <----
|
|
|
- // special: patch 2021-10-05 by Opentalent, for performances reason
|
|
|
- // >> made for typo3 v10.4
|
|
|
+ // special: patch by Opentalent, for performances reason
|
|
|
+ // >> updated for typo3 v12.4
|
|
|
$siteRootPageUid = $this->site->getRootPageId();
|
|
|
$sitePages = $this->getAllSubpagesUidFor($siteRootPageUid);
|
|
|
// ---->
|
|
|
|
|
|
- while ($row = $statement->fetch()) {
|
|
|
+
|
|
|
+ while ($row = $statement->fetchAssociative()) {
|
|
|
$mountPageInformation = null;
|
|
|
- // This changes the PID value and adds a _ORIG_PID value (only different in move actions)
|
|
|
- // In live: This fetches everything in a bad way ! as there is no workspace limitation given, fetching all new and moved placeholders here!
|
|
|
- // In a workspace: Filter out versioned records (t3ver_oid=0), leaving effectively the new/move placeholders in place, where the new placeholder
|
|
|
- // However, this is checked in $siteFinder->getSiteByPageId() via RootlineUtility where overlays are happening
|
|
|
- // so the fixVersioningPid() call is probably irrelevant.
|
|
|
- $pageRepository->fixVersioningPid('pages', $row);
|
|
|
- $pageIdInDefaultLanguage = (int)($languageId > 0 ? $row['l10n_parent'] : $row['uid']);
|
|
|
+ $pageIdInDefaultLanguage = (int)($languageId > 0 ? $row['l10n_parent'] : ($row['t3ver_oid'] ?: $row['uid']));
|
|
|
// When this page was added before via recursion, this page should be skipped
|
|
|
if (in_array($pageIdInDefaultLanguage, $excludeUids, true)) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
// <----
|
|
|
- // special: patch 2021-10-05 by Opentalent, for performances reason
|
|
|
- // >> made for typo3 v10.4
|
|
|
+ // special: patch by Opentalent, for performances reason
|
|
|
+ // >> updated for typo3 v12.4
|
|
|
if (!in_array($pageIdInDefaultLanguage, $sitePages)) {
|
|
|
continue;
|
|
|
}
|
|
|
// ---->
|
|
|
|
|
|
+
|
|
|
try {
|
|
|
$isOnSameSite = $siteFinder->getSiteByPageId($pageIdInDefaultLanguage)->getRootPageId() === $this->site->getRootPageId();
|
|
|
} catch (SiteNotFoundException $e) {
|
|
|
@@ -159,7 +159,7 @@ class OtPageSlugCandidateProvider extends PageSlugCandidateProvider
|
|
|
$row['MPvar'] = $mountPageInformation['MPvar'];
|
|
|
$mountedPage = $pageRepository->getPage_noCheck($mountPageInformation['mount_pid_rec']['uid']);
|
|
|
// Ensure to fetch the slug in the translated page
|
|
|
- $mountedPage = $pageRepository->getPageOverlay($mountedPage, $languageId);
|
|
|
+ $mountedPage = $pageRepository->getLanguageOverlay('pages', $mountedPage, new LanguageAspect($languageId, $languageId));
|
|
|
// Mount wasn't connected properly, so it is skipped
|
|
|
if (!$mountedPage) {
|
|
|
continue;
|
|
|
@@ -168,7 +168,7 @@ class OtPageSlugCandidateProvider extends PageSlugCandidateProvider
|
|
|
// it must never be accessible directly, but only in the MountPoint context. Therefore we change
|
|
|
// the current ID and slug.
|
|
|
// This needs to happen before the regular case, as the $pageToAdd contains the MPvar information
|
|
|
- if (PageRepository::DOKTYPE_MOUNTPOINT === (int)$row['doktype'] && $row['mount_pid_ol']) {
|
|
|
+ if ((int)$row['doktype'] === PageRepository::DOKTYPE_MOUNTPOINT && $row['mount_pid_ol']) {
|
|
|
// If the mounted page was already added from above, this should not be added again (to include
|
|
|
// the mount point parameter).
|
|
|
if (in_array((int)$mountedPage['uid'], $excludeUids, true)) {
|
|
|
@@ -212,7 +212,6 @@ class OtPageSlugCandidateProvider extends PageSlugCandidateProvider
|
|
|
}
|
|
|
}
|
|
|
return $pages;
|
|
|
-
|
|
|
}
|
|
|
|
|
|
}
|