Skip to content
Snippets Groups Projects
Commit ee579670 authored by Christoph Lehmann's avatar Christoph Lehmann Committed by Benni Mack
Browse files

[BUGFIX] Re-introduce SQL query per page during menu generation

With the Bugfix #100188 an integer is compared type-safe with a string:

$page['uid'] ?? false) !== $linkDetails['pageuid']

This makes sure

* $linkDetails['pageuid'] is an integer if possible
* The tests use assertSame instead assertEqual for type safe comparison

Resolves: #100329
Releases: main
Change-Id: I26cfc56cf1d028e8794f659c8016ae6f860a56d3
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/78282


Tested-by: default avatarcore-ci <typo3@b13.com>
Tested-by: default avatarBenni Mack <benni@typo3.org>
Reviewed-by: default avatarBenni Mack <benni@typo3.org>
Tested-by: default avatarGeorg Ringer <georg.ringer@gmail.com>
Reviewed-by: default avatarGeorg Ringer <georg.ringer@gmail.com>
parent e2116489
Branches
Tags
No related merge requests found
......@@ -90,11 +90,11 @@ class LegacyLinkNotationConverter
$tableAndUid = explode(':', $tableAndUid);
if (count($tableAndUid) > 1) {
$a['table'] = $tableAndUid[0];
$a['uid'] = $tableAndUid[1];
$a['uid'] = (int)$tableAndUid[1];
} else {
// this case can happen if there is the very old linkhandler syntax, which was only record:<table>:<uid>
$a['table'] = $a['identifier'];
$a['uid'] = $tableAndUid[0];
$a['uid'] = (int)$tableAndUid[0];
}
$result = array_merge($result, $a);
}
......@@ -189,6 +189,9 @@ class LegacyLinkNotationConverter
} else {
$result['pageuid'] = $data;
}
if (MathUtility::canBeInterpretedAsInteger($result['pageuid'])) {
$result['pageuid'] = (int)$result['pageuid'];
}
return $result;
}
......
......@@ -17,6 +17,8 @@ declare(strict_types=1);
namespace TYPO3\CMS\Core\LinkHandling;
use TYPO3\CMS\Core\Utility\MathUtility;
/**
* Resolves links to pages and the parameters given
*/
......@@ -56,7 +58,7 @@ class PageLinkHandler implements LinkHandlingInterface
{
$result = [];
if (isset($data['uid'])) {
$result['pageuid'] = $data['uid'];
$result['pageuid'] = MathUtility::canBeInterpretedAsInteger($data['uid']) ? (int)$data['uid'] : $data['uid'];
unset($data['uid']);
}
if (isset($data['type'])) {
......
......@@ -61,7 +61,7 @@ final class LegacyLinkNotationConverterTest extends UnitTestCase
[
'type' => LinkService::TYPE_PAGE,
'pageuid' => 13,
'pagetype' => 31,
'pagetype' => '31',
],
't3://page?uid=13&type=31',
],
......@@ -69,7 +69,7 @@ final class LegacyLinkNotationConverterTest extends UnitTestCase
'13,31#uncool',
[
'type' => LinkService::TYPE_PAGE,
'pageuid' => '13',
'pageuid' => 13,
'pagetype' => '31',
'fragment' => 'uncool',
],
......@@ -79,7 +79,7 @@ final class LegacyLinkNotationConverterTest extends UnitTestCase
'13,31?unbel=ievable#uncool',
[
'type' => LinkService::TYPE_PAGE,
'pageuid' => '13',
'pageuid' => 13,
'pagetype' => '31',
'parameters' => 'unbel=ievable',
'fragment' => 'uncool',
......@@ -90,7 +90,7 @@ final class LegacyLinkNotationConverterTest extends UnitTestCase
'13,31,&unbel=ievable&but=possibly#uncool',
[
'type' => LinkService::TYPE_PAGE,
'pageuid' => '13',
'pageuid' => 13,
'pagetype' => '31',
'parameters' => 'unbel=ievable&but=possibly',
'fragment' => 'uncool',
......@@ -101,7 +101,7 @@ final class LegacyLinkNotationConverterTest extends UnitTestCase
'1,0,&param=2',
[
'type' => LinkService::TYPE_PAGE,
'pageuid' => '1',
'pageuid' => 1,
'pagetype' => '0',
'parameters' => 'param=2',
],
......@@ -143,7 +143,11 @@ final class LegacyLinkNotationConverterTest extends UnitTestCase
public function resolveReturnsSplitParameters(string $input, array $expected): void
{
$subject = new LegacyLinkNotationConverter();
self::assertEquals($expected, $subject->resolve($input));
ksort($expected);
$result = $subject->resolve($input);
ksort($result);
self::assertSame($expected, $result);
}
/**
......
......@@ -48,7 +48,7 @@ final class PageLinkHandlerTest extends UnitTestCase
],
'simple page - cool style' => [
[
'uid' => 13,
'uid' => '13',
],
[
'pageuid' => 13,
......@@ -69,7 +69,7 @@ final class PageLinkHandlerTest extends UnitTestCase
if (isset($expected['fragment'])) {
unset($expected['fragment']);
}
self::assertEquals($expected, $subject->resolveHandlerData($input));
self::assertSame($expected, $subject->resolveHandlerData($input));
}
/**
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment