Project

General

Profile

Actions

Bug #91609

closed

DataHandler::copyRecord_raw can lead to recursion

Added by B. Kausch over 4 years ago. Updated about 4 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
DataHandler aka TCEmain
Target version:
-
Start date:
2020-06-08
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
9
PHP Version:
7.3
Tags:
pending-close
Complexity:
medium
Is Regression:
Sprint Focus:

Description

Example: You have a game table/record, which you can add to a page. The page columns are extended in following way.

'game' => [
    'config' => [
        'type' => 'inline',
        'foreign_table' => 'tx_example_domain_model_game',
        'foreign_field' => 'page',
        'minitems' => 0,
        'maxitems' => 1,
    ],
],

Now let us say, this game record has a relation to pages, maybe like this:

'detail_page' => [
    'config' => [
        'type' => 'inline',
        'foreign_table' => 'pages',
        'minitems' => 0,
        'maxitems' => 1,
    ],
],

So, we have a page with the uid 99. We add a game record with the uid 2. And the we edit the detail_page field and select the page 99. When you now try to copy the page 99 and insert it somewhere in the page tree the recursion begins. You can follow the methods in DataHandler:

(1) ::copySpecificPage(99, ...)
(2) ::copyRecord('pages', 99, ...)
.
. iterate over fields to copy until game
.
(3) ::copyRecord_procBasedOnFieldType('pages', 99, 'game', ...)
(4) ::copyRecord_processInline('pages', 99, 'game', ...)
(5) ::copyRecord_raw('tx_example_domain_model_game', ...)
.
. iterate over fields to copy until detail_page
.
(6) ::copyRecord_procBasedOnFieldType('tx_example_domain_model_game', 2, 'detail_page', ...)
(7) ::copyRecord_processInline('tx_example_domain_model_game', 2, 'detail_page', ...)
(8) ::copyRecord_raw('pages', ...)

Go back to (3). And so on and on and on...

Actions #1

Updated by Oliver Hader over 4 years ago

Based on the given configuration this is not possible to reference a given page as inline... I guess this is assigned individually (or the provided configuration is just not complete).

Anyway, this model has the recursion already - pages:99 → tx_example_domain_model_game:2 → "detail_page" → pages:99

Type "inline" is a composite relationship... means, once the aggregate root (probably "game" here) is removed, related child entities are removed as well. Please, try to use a simple association here (types "select" or "group").

Actions #2

Updated by Oliver Hader over 4 years ago

  • Tags set to pending-close
Actions #3

Updated by B. Kausch over 4 years ago

Well, I have used the ExtensionBuilder for it and referenced an own page entity based on the pages table. So, the config is possible and it can lead to recursion.

I think the problem lies deeper. DataHandler::copyRecord_raw can always lead to recursion if there are circurlar inline references in the data to be copied. It can happen and should be addressed

Actions #4

Updated by Oliver Hader about 4 years ago

Table pages has a special meaning in TYPO3 - all records are organized on pages, creating 1:n pages dynamically has implications. Type "inline" 1:n is a composition pattern, which also means that all children belong to one aggregate root - deleting the parent deletes all child records.

I guess your scenario is more like using associations to pages - just point to them, without actually have them nested. This can be done by using types "group" or "select" in field detail_page.

In case you think it's a problem with extension builder, please report it at https://github.com/FriendsOfTYPO3/extension_builder/issues

Actions #5

Updated by Oliver Hader about 4 years ago

  • Status changed from New to Closed
  • Target version deleted (Candidate for patchlevel)
Actions

Also available in: Atom PDF