[BUG]: Model events manager on beforeDelete with softdelete
Open
@niden is already working on this.
Since May 4, 2026.
7.0
bug
discussion
- Dominant language
- PHP
- Stars
- 10.8k
- Forks
- 1.9k
- Avg merge
- 7h 2m
- Merged PRs (30d)
- 47
Description
Describe the bug
If softDelete is enabled and there is event model:beforeDelete, it executes DELETE (in that case UPDATE) even if attached anonymous function returns false.
To Reproduce
Steps to reproduce the behavior:
<?php
use Phalcon\Events\Event;
use Phalcon\Events\Manager;
use Phalcon\Mvc\Model\Behavior\SoftDelete;
class User extends \Phalcon\Mvc\Model
{
public function initialize()
{
/** @var Manager $eventsManager */
$eventsManager = $this->getDI()->getShared('eventsManager');
$eventsManager->attach('model:beforeDelete', function (Event $event, $model) {
return false;
});
$this->addBehavior(new SoftDelete([
'field' => 'deleted_at',
'value' => date('Y-m-d H:i:s'),
]));
}
}
Expected behavior
It does not mark deleted_at with current date time if event returns false.
Details
- Phalcon version: 4.0.5
- PHP Version: 7.4.3
- Operating System: Ubuntu
- Installation type: Compiling from source
- Zephir version (if any):
- Server: Nginx
- Other related info (Database, table schema): MySQL
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.