1 unresolved comment

The owner has to answer or resolve it. Show the first one

Review main Ready for review

98274[TASK] Find inherited page restrictions in one place

Matthias Vogel CR 0 V 0 Hard +577 −75 updated 12/02/26, 08:55

Commit message

PreviewUriBuilder adds parameters to the preview link of a page. These
parameters simulate the frontend user groups and the access time that
the page needs. A page also gets the restriction of each ancestor with
"extendToSubpages". PreviewUriBuilder has its own copy of this rule
and reads the fields by their names. In the frontend,
RecordAccessVoter has the same rule and gets the field names from the
TCA schema capabilities.

The backend cannot use the voter for the preview link. The voter tells
only if a record grants access. The backend needs the values of the
restriction, because it simulates them in the preview link.

The new internal value object RecordAccessRestriction contains the
values of one restriction. The new internal method
RecordAccessVoter::getRestriction() reads these values through the TCA
schema capabilities. The new internal PageAccessRestrictionResolver
returns the restriction of the page and of each ancestor that extends
its restriction to subpages. It gets this rule from the new internal
method RecordAccessVoter::extendsRestrictionToSubpages(), which the
voter also uses.

The new internal service AccessRestrictionSimulator makes the
parameters of the preview link. It contains the code of
PreviewUriBuilder, but it gets the restrictions from the resolver. It
also asks RecordAccessVoter::extendsRestrictionToSubpages() if the page
itself extends its restriction. Thus the rule and the name of the
field "extendToSubpages" exist only once. All other field names come
from the TCA schema capabilities. PreviewUriBuilder keeps its static
method and only calls this service.

The behaviour does not change.

New tests cover the preview link parameters, the resolver and the new
voter methods.
Show more Show less
Resolves: #111700
Related: #110664
Releases: main, 14.3
Change-Id: I9c56ce3253db44239084f729fe731d1116b24bc5

Test this change

Run a command in your clone of the TYPO3 Core. Then try what the change does and vote on Verified in Gerrit. How to review a patch

Check out patch set 1
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/74/98274/1 && git checkout FETCH_HEAD
Cherry-pick onto main
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/74/98274/1 && git cherry-pick FETCH_HEAD

Review

  • Code review CR 0 Needs a vote
  • Verified V 0 Needs a vote
    • core-ci +1 CI

Relation chain 2

  1. 98275[BUGFIX] Simulate restricted ancestors in preview Based on this change Matthias Vogel → main, 14.3 Hard +538 −83 CR 0 V 0 Merge conflict
  2. 98274 [TASK] Find inherited page restrictions in one place This change

Merge conflicts 4

Issues 2

Files 10

Review log 34

  1. Matthias Vogel uploaded patch set 1 12/02/26, 08:40

  2. Benni Mack commented on patch set 1 12/02/26, 08:47

    RecordAccessRestriction.php:21

    I wonder if we should move this "logic" to the Record API in general, as I can see a benefit in my places...
  3. core-ci voted on patch set 1 V +1 12/02/26, 08:47 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/116161

  4. Matthias Vogel commented on patch set 1 12/02/26, 08:55

    RecordAccessRestriction.php:21 Reply Unresolved

    Good point, I agree that this belongs into the Record API in the long run. SystemProperties already has the disabled flag, the publish dates and the user groups. PageAncestry would be a good place for the inherited restrictions. I would still keep this patch as it is. It is internal and does not change behaviour, and it must go to 14.3, where the Record API is internal and PageAncestry does not exist. The voter, its public accessGranted() and RecordAccessGrantedEvent work on raw arrays. The root line in the preview comes from BeforePagePreviewUriGeneratedEvent, where listeners can set partial rows. RecordFactory throws an IncompleteRecordException for such rows. I suggest a separate main-only feature patch that exposes the restriction through the Record API, for example built from a Record and offered by PageAncestry. Which places do you have in mind? Then I can design it for them.