Project

General

Profile

Actions

Bug #79014

open

DataHandler not deleting inline and MM references if base table does not have a "delete"-field leads to DatabaseRecordException⁠⁠⁠⁠

Added by Stephan Großberndt over 7 years ago. Updated 12 months ago.

Status:
Under Review
Priority:
Must have
Category:
DataHandler aka TCEmain
Target version:
-
Start date:
2016-12-16
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
7
PHP Version:
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

Description

DataHandler calls deleteRecord_procFields() to check and delete inline and MM references only if the base table has a "delete"-field:

        if ($deleteField && !$forceHardDelete) {
            ...

            // before (un-)deleting this record, check for child records or references
            $this->deleteRecord_procFields($table, $uid, $undeleteRecord);
            $this->databaseConnection->exec_UPDATEquery($table, 'uid=' . (int)$uid, $updateFields);
            // Delete all l10n records as well, impossible during undelete because it might bring too many records back to life
            if (!$undeleteRecord) {
                $this->deleteL10nOverlayRecords($table, $uid);
            }
        } else {
            ...

            // Delete the hard way...:
            $this->databaseConnection->exec_DELETEquery($table, 'uid=' . (int)$uid);
            $this->deleteL10nOverlayRecords($table, $uid);
        }

This is wrong. If a table does not contain a defined "delete"-field in TCA and has inline or MM-relations and a record from this table is deleted, the related and mm records stay in the database.

If you try to open the record on the other side of the mm-relation you get a ⁠⁠⁠⁠DatabaseRecordException⁠⁠⁠⁠ with ⁠⁠⁠⁠#1437656081: Record with uid XXX from table tx_extension_mytable not found⁠⁠⁠⁠ because the relation in the mm table is still there but the record is not.


Related issues 2 (1 open1 closed)

Related to TYPO3 Core - Bug #76138: Inline Relations - Delete Behaviour with mixed Usage of the Deleted FlagNew2016-05-11

Actions
Has duplicate TYPO3 Core - Bug #22535: Deleting the parent record leaves orphan child recordsClosed2010-04-28

Actions
Actions #1

Updated by Stephan Großberndt over 7 years ago

  • Status changed from New to In Progress
  • Assignee set to Stephan Großberndt
Actions #2

Updated by Gerrit Code Review over 7 years ago

  • Status changed from In Progress 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/50987

Actions #3

Updated by Gerrit Code Review over 7 years 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/50987

Actions #4

Updated by Stephan Großberndt about 6 years ago

Configuration/TCA/tx_blogexample_domain_model_blog.php

<?php
return [
    'ctrl' => [
        'title' => 'blog',
        'label' => 'title'
    ],
    'interface' => [
        'showRecordFieldList' => 'title, posts'
    ],
    'columns' => [
        'title' => [
            'label' => 'title',
            'config' => [
                'type' => 'input'
            ]
        ],
        'posts' => [
            'label' => 'posts',
            'config' => [
                'type' => 'inline',
                'foreign_table' => 'tx_blogexample_domain_model_post',
                'foreign_field' => 'blog'
            ]
        ],
    ],
    'types' => [
        '1' => ['showitem' => 'title, posts']
    ]
];

Configuration/TCA/tx_blogexample_domain_model_post.php

<?php
return [
    'ctrl' => [
        'title' => 'post',
        'label' => 'title'
    ],
    'interface' => [
        'showRecordFieldList' => 'title, blog'
    ],
    'columns' => [
        'title' => [
            'label' => 'title',
            'config' => [
                'type' => 'input'
            ]
        ],
        'blog' => [
            'label' => 'blog',
            'config' => [
                'type' => 'select',
                'renderType' => 'selectSingle',
                'foreign_table' => 'tx_blogexample_domain_model_blog',
                'maxitems' => 1
            ]
        ],
    ],
    'types' => [
        '1' => ['showitem' => 'title, blog']
    ]
];

ext_tables.sql

CREATE TABLE tx_blogexample_domain_model_blog (
    uid int(11) unsigned DEFAULT '0' NOT NULL auto_increment,
    pid int(11) DEFAULT '0' NOT NULL,
    deleted tinyint(4) unsigned DEFAULT '0' NOT NULL,
    title varchar(255) DEFAULT '' NOT NULL,
    posts varchar(255) DEFAULT '' NOT NULL,
    PRIMARY KEY (uid),
    KEY parent (pid)
);

CREATE TABLE tx_blogexample_domain_model_post (
    uid int(11) unsigned DEFAULT '0' NOT NULL auto_increment,
    pid int(11) DEFAULT '0' NOT NULL,
    deleted tinyint(4) unsigned DEFAULT '0' NOT NULL,
    blog int(11) DEFAULT '0' NOT NULL,
    title varchar(255) DEFAULT '' NOT NULL,
    PRIMARY KEY (uid),
    KEY parent (pid)
);

If 'delete' => 'deleted', is defined in Configuration/TCA/tx_blogexample_domain_model_post.php:$TCA['ctrl'] and you delete the blog the related posts will get deleted=1, if its not defined, nothing happens to them. (I typed this up from memory without re-testing..)

Actions #5

Updated by Gerrit Code Review over 5 years 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/50987

Actions #6

Updated by Gerrit Code Review about 5 years 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/+/50987

Actions #7

Updated by Gerrit Code Review about 5 years 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/+/50987

Actions #8

Updated by Gerrit Code Review about 5 years 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/+/50987

Actions #9

Updated by Gerrit Code Review about 5 years ago

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

Actions #10

Updated by Gerrit Code Review about 5 years ago

Patch set 8 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/+/50987

Actions #11

Updated by Markus Klein over 4 years ago

  • Has duplicate Bug #22535: Deleting the parent record leaves orphan child records added
Actions #12

Updated by Markus Klein over 4 years ago

  • Related to Bug #76138: Inline Relations - Delete Behaviour with mixed Usage of the Deleted Flag added
Actions #13

Updated by Gerrit Code Review over 4 years ago

Patch set 9 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/+/50987

Actions #14

Updated by Gerrit Code Review over 4 years ago

Patch set 10 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/+/50987

Actions #15

Updated by Gerrit Code Review almost 4 years ago

Patch set 11 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/+/50987

Actions #16

Updated by Gerrit Code Review over 2 years ago

Patch set 13 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/+/50987

Actions #17

Updated by Gerrit Code Review over 2 years ago

Patch set 14 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/50987

Actions #18

Updated by Gerrit Code Review 12 months ago

Patch set 15 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/50987

Actions

Also available in: Atom PDF