Actions
Bug #89964
closedPopulatePageSlugs.php should use order in query of getSuggestedSlugs
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
Actions