Bug #72613

Extbase does not delete 1:1 related objects with @cascade remove

Added by Simon Schaufelberger over 5 years ago. Updated about 5 years ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
Extbase
Target version:
-
Start date:
2016-01-09
Due date:
% Done:

0%

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

Description

given following model (simplified) with @cascade annotation:

class Model {

    /**
     * Address
     *
     * @var Address
     * @lazy
     * @cascade remove
     */
    protected $address;

    /**
     * Deletes the address
     */
    public function unsetAddress() {
        $this->address = null;
    }
}

when I call in my controller:

$this->model->unsetAddress();
$this->modelRepository->update($this->model);

I would expect that the related Address will also get deleted but instead just the address property of Model will bet set NULL in database.

As a manual workaround I currently have to add the following code:

if ($model->getAddress()) {
    $this->addressRepository->remove($model->getAddress());
}

It seeams like the @cascade remove annotation is only considered for ObjectStorage:

https://docs.typo3.org/typo3cms/ExtbaseFluidBook/5-Domain/2-implementing-the-domain-model.html#implementing-relationships-between-domain-objects

Also available in: Atom PDF