bshaffer/csDoctrineActAsSortablePlugin — Issue #14: Conflicts with SoftDelete
Author: haxpanel
Created: 2012-01-15 14:52:38+00:00
State: open

When using Sortable with SoftDelete it can't reorder the positions because the position of the deleted row is still exists and throws an sql error (position is a unique field).
So i added a new line to the beginning of postDelete():

public function postDelete(Doctrine_Event $event)
{
$fieldName = $this->_options['name'];
$object = $event->getInvoker();
$position = $object->$fieldName;
$conn = $object->getTable()->getConnection();

// Create query to update other positions
$q = $object->getTable()->createQuery()
->where($fieldName . ' > ?', $position)
->orderBy($fieldName);

// quick FIX for softdelete + sortable conflict by janoist1@gmail.com
$conn->execute("UPDATE ". $object->getTable()->getTableName() ." SET ". $fieldName ." = NULL WHERE id = ". $object->getId() ."");

...