Sylius: Customer Addresses cascade delete?

Created on 12 Jun 2016  路  8Comments  路  Source: Sylius/Sylius

This association between Addresses and Customers currently orphans and Address if the Customer is deleted:

https://github.com/Sylius/Sylius/blob/master/src/Sylius/Bundle/CoreBundle/Resources/config/doctrine/model/Address.orm.xml#L18

I'm probably going to change this in our project - unless anyone can thing of a good reason for it? I don't see the value in a customer address without it's customer?

Potential Bug

Most helpful comment

Another one that should cascade:

https://github.com/Sylius/Sylius/blob/f5d1b5f7fe845adfcc2fac485d6e19cd1708e03b/src/Sylius/Bundle/OrderBundle/Resources/config/doctrine/model/Comment.orm.xml#L39

Apologies I'm crazy busy to do a PR, just pointing these out then it's up to you...

All 8 comments

The customer addresses should be removed together with customer. However the customer address is cloned to Order and the relation to customer probably stays. It is probably also the cause of duplicating the addresses after checkout and the reason we set null on delete. Of course it is a bug and should be resolved.

Hey @michalmarcinkowski,

I just checked in our app and customer relation is not cloned for order addresses, although not sure if this is something we changed.

On master it is in AddressingStepType :)

Cascade deleting will reveal the bug which will result in deleting address of all orders of this customer, so here after cloning we should setCustomer(null).

hmm it does though on the very next line?

You're right! Don't know how I missed that 馃槥 Then I don't see any reason we shouldn't cascade delete addresses.

Another one that should cascade:

https://github.com/Sylius/Sylius/blob/f5d1b5f7fe845adfcc2fac485d6e19cd1708e03b/src/Sylius/Bundle/OrderBundle/Resources/config/doctrine/model/Comment.orm.xml#L39

Apologies I'm crazy busy to do a PR, just pointing these out then it's up to you...

@peteward No worries, we will take care of that, thanks for the pointers! :)

Already fixed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

igormukhingmailcom picture igormukhingmailcom  路  3Comments

inssein picture inssein  路  3Comments

reyostallenberg picture reyostallenberg  路  3Comments

loic425 picture loic425  路  3Comments

crbelaus picture crbelaus  路  3Comments