Feature #93789

Provide a reliable method to determine page id in the Backend mode

Added by Dmitry Dulepov 6 months ago. Updated 19 days ago.

Status:
Under Review
Priority:
Should have
Assignee:
-
Category:
Backend API
Target version:
Start date:
2021-03-21
Due date:
% Done:

0%

Estimated time:
PHP Version:
Tags:
Complexity:
medium
Sprint Focus:

Description

Currently there is no public API to get the current page id in the Backend mode. Such API can be useful for hooks that behave differently depending on where they are executed in the page tree. For example, we have a part of the tree where certain operations are restricted additionally to the TYPO3 permissions and we have other parts of the tree where only certain records are allowed, or yet other parts of the tree where we automatically move records to proper places if the editor accidentally creates them in a wrong folder.

Unfortunately the only current solution provided by TYPO3 is a condition that we could use in Page TSConfig but that condition does not work reliably because the implementation there is incomplete. Also we really need to get current page id there, not just whether we are in some part of tree or not. TYPO3 does not provide such public API, so we had to develop our own.

The current TYPO3 code for determining page id is located at EXT:backend/Classes/Configuration/TypoScript/ConditionMatching/ConditionMatcher.php but it is private and does not cover all possible cases.

The idea is to implement a new method in the BackendUtility with the following signature:

/**
 * Determines the current page id while in the Backend context. Behavior
 * in the Frontend context is undefined.
 *
 * @return int Page id or zero if it cannot be determined
 */
public static function getCurrentPageId(): int
{
}
#1

Updated by Gerrit Code Review 6 months 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/+/68525

#2

Updated by Gerrit Code Review 6 months 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/+/68525

#3

Updated by Gerrit Code Review 6 months ago

Patch set 3 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/+/68525

#4

Updated by Gerrit Code Review 6 months ago

Patch set 4 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/+/68525

#5

Updated by Gerrit Code Review 6 months ago

Patch set 5 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/+/68525

#6

Updated by Gerrit Code Review 6 months ago

Patch set 6 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/+/68525

#7

Updated by Dmitry Dulepov 6 months ago

Code is abandoned:

  • Got a comment: "We do not want this"
  • phpstan gives false failures

Not worth spending more time in this case. If anybody needs the code, you can find it there.

#8

Updated by Martin Kutschker 6 months ago

There was only one commentor that was unhappy with the implementation not the feature.

#9

Updated by Benni Mack 5 months ago

  • Target version changed from 11.2 to 11.3
#10

Updated by Benni Mack 3 months ago

  • Target version changed from 11.3 to 11.4
#11

Updated by Benni Mack 19 days ago

  • Target version changed from 11.4 to 12 LTS

Also available in: Atom PDF