This is extending off the idea of having update*/delete* AR methods respect scopes. Currently, only select respects the scopes while there is no way to enable them on update/delete.
There was a PR for this issue a year ago which was not accepted: https://github.com/yiisoft/yii/pull/1660
Main reasons was this is against the original design and it is not backwards compatible. Issues with this (even if it was BC) was that defaultScope would interfere with proper selecting if this was meant for updates/deletes, or vice versa.
This CAN be accomplished in a backwards compatible manner: if CDbCriteria had an ‘operations’ property where we could specify which operations the scope applied to:
public function defaultScope()
{
return array(
'condition'=>'locked=0',
'operations'=>array('update','delete'),
);
}
This would apply the scope to only the update and delete DB operations. Omitting this parameter would result in default behavior of only applying it to select.
Simple, elegant, and extremely useful!