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

AuditTrailBehavior - reload oldAttributes after refresh #279

Open
cornernote opened this issue Oct 25, 2020 · 2 comments
Open

AuditTrailBehavior - reload oldAttributes after refresh #279

cornernote opened this issue Oct 25, 2020 · 2 comments

Comments

@cornernote
Copy link
Contributor

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());
    }
}
@cornernote
Copy link
Contributor Author

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

Let me know your thoughts.

@Blizzke
Copy link
Member

Blizzke commented Nov 17, 2020

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.

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

No branches or pull requests

2 participants