Skip to content

The child-references of a record are not marked as deleted if enableCascadingDelete is TRUE #25

@Moongazer

Description

@Moongazer

Lets say we have the following record relation: a book (parent) has multiple chapters (children), defined like this:

TCA configuration:

//book.php
      'ctrl' => [
        'delete' => 'deleted',
      ],
      'columns' => [
        'chapters' => [
            'config' => [
                'type' => 'inline',
                'foreign_table' => 'chapter',
                'foreign_field' => 'book_uid',
                'maxitems' => 9999,
                'behaviour' => [
                    'enableCascadingDelete' => TRUE,
                ],
            ],
        ],
      ],

//chapter.php
      'ctrl' => [
        'delete' => 'deleted',
      ],

Model: Book.php

/**
 * @T3api\ApiResource(
 *     itemOperations={
 *          "delete"={
 *              "method"="DELETE",
 *              "path"="/book/{id}",
 *          },
 *     },
 * )
 */
class Book extends AbstractEntity {
    /**
     * @var ObjectStorage<Chapter>
     * @T3api\Serializer\Groups({
     *     "api_book_post_collection",
     * })
     * @T3api\ORM\Cascade("persist")
     */
    protected $chapters;
}

The request DELETE /api/book/123 will set deleted=1 for parent record 123, but not for the child-records.
Instead, if the record 123 is deleted in the TYPO3 backend list view, also the child-records are marked as deleted.

I tried it also with the replaced annotation @T3api\ORM\Cascade("delete") but with the same result.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions