Commit 132c950
committed
[TASK] Streamline DataHandler permission checks
The DataHandler permission check related methods - mainly
those related to recordInfoWithPermissionCheck() are very
hard to call correctly and contain lots of complex details.
They are the source of many database queries when changing
records in the Backend. Earlier attempts to improve the
situation added various caches, even though caching db state
in DataHandler is not a great solution since it can easily
lead to side effects when records are changed multiple times
in one process.
The patch streamlines this area within the DataHandler
significantly: The main strategy is to move the "getting
record facts" (usually using BackendUtility::getRecord())
code up into the calling method and hand these records down
to the permission check methods so they don't need to fetch
the record in question over and over again. This aligns well
with the general strategy of having the record fetching code
in the top level "entry" methods (like moveRecord(),
deleteRecord(), ...) and handing them around. This makes
everything much more deterministic, quicker and maintainable.
The permission check methods typically look at page record
details and check for CONTENT_EDIT flag, ownerships and similar.
The calling code thus has to fetch the page row a record is
attached to. This is relatively straight, even though the code
has to deal with records on pid 0 (zero) correctly.
This refactoring drops four cache properties. The patch saves
quite a few queries. Depending on what is measured, it seems
the number of queries shrink by up to 1/3, especially with
non-admin users.
The v13 backport keeps the old public methods with their
signature as-is to not risk breaking hooks.
Resolves: #106382
Related: #106285
Releases: main, 13.4
Change-Id: I28eaf7cbf43c679bb0cad8f72be01f02d8bdd8bf
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/88445
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Stefan Bürk <stefan@buerk.tech>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: core-ci <typo3@b13.com>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: Benni Mack <benni@typo3.org>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>1 parent 38e5588 commit 132c950
File tree
5 files changed
+456
-588
lines changed- Build/phpstan
- typo3/sysext
- core/Classes
- Authentication
- DataHandling
- redirects/Classes/Hooks
- workspaces/Classes/Hook
5 files changed
+456
-588
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
768 | 768 | | |
769 | 769 | | |
770 | 770 | | |
771 | | - | |
772 | | - | |
773 | | - | |
774 | | - | |
775 | | - | |
776 | | - | |
777 | 771 | | |
778 | 772 | | |
779 | 773 | | |
| |||
Lines changed: 3 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
341 | 341 | | |
342 | 342 | | |
343 | 343 | | |
344 | | - | |
345 | | - | |
346 | | - | |
| 344 | + | |
347 | 345 | | |
348 | 346 | | |
349 | 347 | | |
| |||
642 | 640 | | |
643 | 641 | | |
644 | 642 | | |
645 | | - | |
646 | | - | |
| 643 | + | |
| 644 | + | |
647 | 645 | | |
648 | 646 | | |
649 | 647 | | |
| |||
0 commit comments