What is _oldAttributes in AR object

When I execute findOne() query I get User object with _oldAttributes property.

What is _oldAttributes and why it is there ?

Can I remove it somehow from response ( I do not want it there at all ) ?

_oldAttributes stores the attribute values at the time of reading the object from the database. Can be used to determine whether an attribute has changed since it was retrieved from the database, e.g with http://www.yiiframework.com/doc-2.0/yii-db-baseactiverecord.html#isAttributeChanged()-detail

Thanks Patrick.

Can I remove it from object ? I want cleaner object structure, and since I am in command of data, I do not see any point of having _oldAttributes, because my object will contain data that I want it to have.

Take a look at the source code of yii\db\BaseActiveRecord.

Removing _oldAttributes from ActiveRecord is not that easy. It will be a fairly time consuming task, just like creating your own ActiveRecord class from scratch. And the reward that you would get doesn’t worth your effort at all. I strongly recommend you not to try that.

Yeah, I won’t do it. Thanks :)