Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

SoftDeleteHelper's delete() returns false, yet SoftDelete occurs successfully #19

ajibarra opened this Issue Oct 4, 2011 · 5 comments


None yet
5 participants

ajibarra commented Oct 4, 2011

I have a Photos model with MySQL table "photos" with columns "deleted" (INT(1), default 0) and "deleted_date" (DATETIME, default NULL). The save() function at the end of the SoftDeleteHelper's delete() function is returning false; however, the "deleted" field is set to 1, and the "deleted_date" is set to the current DATETIME. The SQL query is also valid:

UPDATE photos SET deleted = '1', deleted_date = '2010-10-24 18:08:56', modified = '2010-10-24 18:08:56' WHERE photos.id = 3

Why does the save() (and hence delete()) function return false?


ajibarra commented Oct 4, 2011

sibljon commented on October 25th, 2010 @ 11:39 PM

Some more info:

I've traced the code execution all the way through and it seems to be failing at this line in cake.lib.Model's save() function:

$db =& ConnectionManager::getDataSource($this->useDbConfig);

where $this->useDbConfig is equal to "default". The error handler then goes to Cake's debugger.php:

function handleError($code, $description, $file = null, $line = null, $context = null) {
    if (error_reporting() == 0 || $code === 2048 || $code === 8192) {

And $code is equal to 2048. Does this refer to mysql code 2048? I looked that up and found it to be "Invalid connection handle".

Thanks in advance for any help anyone can provide!



ajibarra commented Oct 4, 2011

Predominant commented on October 28th, 2010 @ 09:02 PM

The operation of the soft delete behavior in terms of returning false in this case is correct.
While this doesn't represent the success of the "soft deletion" process, it is a correct representation of the success of data having been deleted from the model in the traditional sense.

Returning a false from SoftDeleteBehavior::beforeDelete is required to ensure that the Model::delete does not continue and actually process the deletion of data.

I'm leaving this open for the moment, and we'll discuss potentially overriding the delete() functionality rather than hooking into beforeDelete for this behavior. This may achieve a more acceptable response, and enable the behavior to return true for delete options that are soft deleted.

@skie skie closed this Oct 11, 2011

you might be interested that I started a discussion on this topic at https://groups.google.com/forum/?fromgroups#!topic/cakephp-core/2vIZN8Sq8RE a few days ago with some ideas for improvement. unfortunately without much response so far...


davidyell commented Mar 13, 2013

Just hit this issue in my project.

@burzum burzum reopened this Jun 11, 2013


burzum commented Aug 26, 2013

Resolved by a3e07fb

@burzum burzum closed this Aug 26, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment