Development

#8993 (doctrine post/pre-delete nt working on n:m relation objects)

You must first sign up to be able to contribute.

Ticket #8993 (new defect)

Opened 3 years ago

Last modified 1 year ago

doctrine post/pre-delete nt working on n:m relation objects

Reported by: tkoomzaaskz Assigned to: Jonathan.Wage
Priority: major Milestone: plugins
Component: sfDoctrinePlugin Version: 1.4.15
Keywords: doctrine event postdelete predelete Cc:
Qualification: Unreviewed

Description

The doctrine mechanism of post/pre-delete is not working when deleting objects stored in a n:m relation tables. But pre/post-insert does work (so it has to be a bug).

For example, we've got two tables: product and category and product_category linking them in an n:m relation. In an admin module, there's category_list widget for each product. Inside BaseProductForm?, there is a public function saveCategoriesList($con = null) method with the following code:

    $unlink = array_diff($existing, $values);
    if (count($unlink))
    {
      $this->object->unlink('Categories', array_values($unlink));
    }

    $link = array_diff($values, $existing);
    if (count($link))
    {
      $this->object->link('Categories', array_values($link));
    }

CategoryProduct? has both postInsert defined, it is called,as it should be. It has also postDelete defined (and preDelete, just to test) and none of them is calles, when CategoryProduct? objects is deleted.

To sum up - $this->object->link seems to work fine and call postInsert on n:m relation objects, but $this->object->unlink seems to be buggy and doesn't call neither postDelete nor preDelete.

Change History

09/12/11 14:15:31 changed by axelat

Same Problem for me: pre/postDelete function not called for m:n relation with symfony 1.4.6 doctrine

11/24/11 15:06:04 changed by virtualize

  • version changed from 1.4.6 to 1.4.15.

this is unfortunately still a defect in symfony 1.4.15 / doctrine 1.2.4 post/preDelete hooks are not called on unlink

12/13/11 09:46:29 changed by godbout

same here. i'm not working with the link/unlink methods, but the pre/post delete method is not called for the m:n relations.