pegasus
Well-known member
- Affected version
- 2.2.15
In entity::save, it is possible to extend _saveToSource in order to do some last minute tasks before saving an entity, compared to _postSave etc, which takes place afterwards.
However, there is no corresponding reverse method in entity::delete. $db->update is called directly, where one would expect a _deleteFromSource method. Such a method would allow us to perform last minute tasks before the entity is removed from the database, which is important in case some tasks require that the entity still exists there. Currently, the only options are:
Please add _deleteFromSource as follows:
Replacing the line:
With:
However, there is no corresponding reverse method in entity::delete. $db->update is called directly, where one would expect a _deleteFromSource method. Such a method would allow us to perform last minute tasks before the entity is removed from the database, which is important in case some tasks require that the entity still exists there. Currently, the only options are:
- performing such tasks during _preDelete (which is both non-semantic and outside the transaction)
- by extending _getUpdateCondition (which is potentially dangerous given its wider usage)
- by writing a ::customDelete function and using it in place of the "final" ::delete (which creates potential conflicts if another add-on expects to use ::delete)
Please add _deleteFromSource as follows:
Code:
protected function _deleteFromSource()
{
return $db->delete($this->_structure->table, $this->_getUpdateCondition());
}
Code:
$rowAffected = $db->delete($this->_structure->table, $this->_getUpdateCondition());
Code:
$rowAffected = $this->_deleteFromSource();