bedezign/yii2-audit

AuditTrailBehavior - reload oldAttributes after refresh

cornernote opened this issue · 2 comments

class AuditTrailBehavior extends \bedezign\yii2\audit\AuditTrailBehavior
{
    public function events()
    {
        return [
            ActiveRecord::EVENT_AFTER_FIND => 'afterFind',
            ActiveRecord::EVENT_AFTER_REFRESH => 'afterRefresh', // <-- need to reload oldAttributes here
            ActiveRecord::EVENT_AFTER_INSERT => 'afterInsert',
            ActiveRecord::EVENT_AFTER_UPDATE => 'afterUpdate',
            ActiveRecord::EVENT_AFTER_DELETE => 'afterDelete',
        ];
    }
    public function afterRefresh()
    {
        $this->setOldAttributes($this->owner->getAttributes());
    }
}

@Blizzke I haven't touched this code for a while so I didn't want to cowboy-commit this.

Let me know your thoughts.

PHP hasn't been my main programming language anymore for almost 3 years.
Been going to some serious personal things so audit hasn't received much attention. I'm actually not sure if I want to return working on this at all, I haven't followed Yii2 developments at all either. Besides that, it's literally the only PHP project I have that is still active.
So I'd say your judgement is much better about this at this moment.