Project

General

Profile

Actions

Bug #89964

closed

PopulatePageSlugs.php should use order in query of getSuggestedSlugs

Added by Herman Kremer almost 5 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Install Tool
Target version:
Start date:
2019-12-16
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
9
PHP Version:
7.2
Tags:
Complexity:
easy
Is Regression:
Sprint Focus:

Description

The populate page slugs functionality in de upgrade wizard does not work correct for pages with multiple titel adjustments.
Realurl keeps for every page titel change a record in tx_realurl_pathdata.
In order to get the latest change a order should be added to the query in getSuggestedSlugs:

Add ->orderBy('expire', 'DESC')

   /**
     * Resolve prepared realurl "pagepath" for pages
     *
     * @param string $tableName
     * @return array with pageID (default language) and language ID as two-dimensional array containing the page path
     */
    protected function getSuggestedSlugs(string $tableName): array
    {
        $context = GeneralUtility::makeInstance(Context::class);
        $currentTimestamp = $context->getPropertyFromAspect('date', 'timestamp');

        $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($tableName);
        $statement = $queryBuilder
            ->select('*')
            ->from($tableName)
            ->where(
                $queryBuilder->expr()->eq('mpvar', $queryBuilder->createNamedParameter('')),
                $queryBuilder->expr()->orX(
                    $queryBuilder->expr()->eq('expire', $queryBuilder->createNamedParameter(0)),
                    $queryBuilder->expr()->gt('expire', $queryBuilder->createNamedParameter($currentTimestamp))
                )
            )
 ++         ->orderBy('expire', 'DESC')
            ->execute();
        $suggestedSlugs = [];
        while ($row = $statement->fetch()) {
            // rawurldecode ensures that non-ASCII arguments are also migrated
            $pagePath = rawurldecode($row['pagepath']);
            if (!isset($suggestedSlugs[(int)$row['page_id']][(int)$row['language_id']])) { // keep only first result
                $suggestedSlugs[(int)$row['page_id']][(int)$row['language_id']] = '/' . trim($pagePath, '/');
            }
        }
        return $suggestedSlugs;
    }


Files


Related issues 2 (0 open2 closed)

Related to TYPO3 Core - Task #89194: Upgrade wizard for slugs optimizationsClosed2019-09-18

Actions
Related to TYPO3 Core - Bug #92568: PopulatePageSlugs upgrade wizard migrates wrong RealURL path data entryClosedMathias Brodala2020-10-15

Actions
Actions

Also available in: Atom PDF