Bug #89964
closedPopulatePageSlugs.php should use order in query of getSuggestedSlugs
100%
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
Updated by Herman Kremer almost 5 years ago
Updated by Guido Schmechel almost 5 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/
Updated by Gerrit Code Review almost 5 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
Updated by Gerrit Code Review almost 5 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
Updated by Gerrit Code Review almost 5 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
Updated by Herman Kremer almost 5 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset a28c475e7bb371a58c2637c47de7609a3546871d.
Updated by Benni Mack almost 5 years ago
- Related to Task #89194: Upgrade wizard for slugs optimizations added
Updated by Sybille Peters about 4 years ago
- Related to Bug #92568: PopulatePageSlugs upgrade wizard migrates wrong RealURL path data entry added