Skip to content

Commit 6e361da

Browse files
Merge pull request #77 from eliashaeussler/fix/multi-language-access
[BUGFIX] Properly handle multi-language records in AccessUtility
2 parents bee40da + f152093 commit 6e361da

File tree

4 files changed

+95
-3
lines changed

4 files changed

+95
-3
lines changed

Classes/Utility/AccessUtility.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,18 @@ protected static function checkPagePermissions(int $pageId, int $languageId = nu
6868
$record = BackendUtility::getRecordLocalization('pages', $pageId, $languageId, 'hidden = 0');
6969
}
7070

71-
return !empty($record) && $backendUser->doesUserHaveAccess($record, $permissions);
71+
// Early return if record is inaccessible
72+
if (!\is_array($record) || $record === []) {
73+
return false;
74+
}
75+
76+
// Select first record inside list of records which is potentially returned by
77+
// BackendUtility::getRecordLocalization()
78+
if (array_is_list($record)) {
79+
$record = reset($record);
80+
}
81+
82+
return $backendUser->doesUserHaveAccess($record, $permissions);
7283
}
7384

7485
protected static function isPageAccessible(int $pageId): bool

Resources/Private/Libs/Build/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"require": {
1414
"php": "~7.4.0",
1515
"eliashaeussler/cache-warmup": ">= 0.4.0 < 0.9.0",
16-
"symfony/polyfill-php80": "^1.23"
16+
"symfony/polyfill-php80": "^1.23",
17+
"symfony/polyfill-php81": "^1.26"
1718
}
1819
}

Resources/Private/Libs/Build/composer.lock

Lines changed: 80 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"psr/log": "^1.0",
2222
"symfony/console": ">= 4.0 < 6.0",
2323
"symfony/polyfill-php80": "^1.23",
24+
"symfony/polyfill-php81": "^1.26",
2425
"symfony/serializer": ">= 4.0 < 6.0",
2526
"typo3/cms-backend": "~10.4.0 || ~11.5.0",
2627
"typo3/cms-core": "~10.4.0 || ~11.5.0",

0 commit comments

Comments
 (0)