Project

General

Profile

Actions

Bug #89964

closed

PopulatePageSlugs.php should use order in query of getSuggestedSlugs

Added by Herman Kremer about 4 years ago. Updated almost 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 #2

Updated by Guido Schmechel about 4 years ago

Hello Herman, maybe you want to contribute this change? You find further information at https://docs.typo3.org/m/typo3/guide-contributionworkflow/master/en-us/

Actions #3

Updated by Gerrit Code Review about 4 years ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/62754

Actions #4

Updated by Gerrit Code Review about 4 years ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/62754

Actions #5

Updated by Gerrit Code Review about 4 years ago

Patch set 1 for branch 9.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/62795

Actions #6

Updated by Herman Kremer about 4 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #7

Updated by Benni Mack about 4 years ago

  • Related to Task #89194: Upgrade wizard for slugs optimizations added
Actions #8

Updated by Benni Mack almost 4 years ago

  • Status changed from Resolved to Closed
Actions #9

Updated by Sybille Peters over 3 years ago

  • Related to Bug #92568: PopulatePageSlugs upgrade wizard migrates wrong RealURL path data entry added
Actions

Also available in: Atom PDF