? Success

User tests: Successful: Unsuccessful:

avatar mgilkes
mgilkes
4 Apr 2015

$model is undefined at line 140 for $this->postDeleteHook($model, $cid);, because $model was instantiated within the scope of the else block. If you try to delete an item from an admin list, you will get a PHP Notice and a PHP Catchable Fatal Error. So, it is better to declare/instantiate the model outside of the else block, within the same scope of the call to postDeleteHook().

avatar mgilkes mgilkes - open - 4 Apr 2015
avatar joomla-cms-bot joomla-cms-bot - change - 4 Apr 2015
Labels Added: ?
avatar wilsonge
wilsonge - comment - 5 Apr 2015

Is there a reason we should call the post delete hook if there aren't any items deleted? i.e. should we move the hook inside the else?

avatar mgilkes
mgilkes - comment - 5 Apr 2015

That's a good question. Logically, I concur that it would make more sense to move the hook, if we assume that the hook should only be called if the delete was successful. If that is the intended purpose of the hook call, then it should be placed in the if($model->delete($cid)) block, and the $model instantiation placed back in the else block.

avatar zero-24 zero-24 - change - 6 Apr 2015
Category Libraries
avatar izharaazmi
izharaazmi - comment - 29 Jun 2016

This was resolved with #7097. But the approach is little different. Please see if what suits best – close this or accept this approach.

In case it is needed, my test result for this is:

Tested successfully.

avatar brianteeman
brianteeman - comment - 29 Jun 2016

As it was resolved in another PR I am going to close this for now. It can always be re-opened if this approach is to be used instead

avatar brianteeman brianteeman - change - 29 Jun 2016
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2016-06-29 10:00:44
Closed_By brianteeman
avatar brianteeman brianteeman - close - 29 Jun 2016

Add a Comment

Login with GitHub to post a comment