Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

before handler soft delete error #209

Closed
BarryDam opened this issue Mar 16, 2017 · 2 comments
Closed

before handler soft delete error #209

BarryDam opened this issue Mar 16, 2017 · 2 comments
Assignees
Labels

Comments

@BarryDam
Copy link
Contributor

Hi there,

yesterdays updated raised an error working with softdeletes like the example:

'before'=>function(&$cmd, &$db, &$tab, &$id, &$in) { 
	if ($cmd == 'delete') {
		$cmd = 'update'; // change command to update
		foreach($in as $k => $o) {
			$in[$k]->deleted = date('Y-m-d H:i:s', time());
		}				
	}
			
},
'column_authorizer'=>function($cmd, $db ,$tab, $col) { 
	return ( ! in_array($col, array('deleted')));
},
'record_filter'=>function($cmd,$db,$tab) { 
	return array('deleted,is,null');
}

in the before we change the $cmd delete to update... updating the "deleted" column to a current date value.... in the column_authorizer we filter out the "deleted" column, so we don't show it in our results

But because the applyBeforeHandler is called before the applyColumnAuthorizer
the "deleted" column gets filtered out... Now the row column deleted will never be set to the current_date.. and so it will never be softdeleted neither will it be harddeleted.

A solution would be is to call the applyBeforeHandler after the applyColumnAuthorizer..

@mevdschee mevdschee self-assigned this Mar 16, 2017
@mevdschee mevdschee added the bug label Mar 16, 2017
@mevdschee
Copy link
Owner

Fixed in 753c0c0

@BarryDam
Copy link
Contributor Author

BarryDam commented Mar 16, 2017

Wow you're superfast, I was still typing this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants