<SUGGESTION> Update TimestampBehavior and BlameableBehavior

hi all…

in yii2.

TimestampBehavior, if we create new record, it automatically fill to update time too. in reality, if we just create new record then the date should go to crate datetime only and not to update time. we do not want our article listed as recent update time when we never do update to that article. so, i purpose a new change to TimestampBehavior.php line 90 as follow:

if (empty($this->attributes)) {

   $this->attributes = [

      - BaseActiveRecord::EVENT_BEFORE_INSERT => [$this->createdAtAttribute, $this->updatedAtAttribute],

      + BaseActiveRecord::EVENT_BEFORE_INSERT => [$this->createdAtAttribute],

      BaseActiveRecord::EVENT_BEFORE_UPDATE => $this->updatedAtAttribute,



BlameableBehavior, same with TimestampBehavior, if we just create a article then our name must just registered as author in create by only, not to update by.

if (empty($this->attributes)) {

   $this->attributes = [

      - BaseActiveRecord::EVENT_BEFORE_INSERT => [$this->createdByAttribute, $this->updatedByAttribute],

      + BaseActiveRecord::EVENT_BEFORE_INSERT => [$this->createdByAttribute],

      BaseActiveRecord::EVENT_BEFORE_UPDATE => $this->updatedByAttribute,



thank you for all developers to this amazing framework :)

It’s common that update date is filled immediately. Anyway, it’s just a default so you can easily change it when attaching behavior.

hi samdark, thank you for your reply.

i appreciate if it keeps filled immediately.

i think it is not common if we directly filled it.

the common is "update time" and "update by" is not set automatically.

common is different with the truth.

the truth is, after we created an article,

then "update time" and "update by" should not be touched.

in the future, our users may want create "Latest Update Article",

and "Latest Authored By", if we consistent use from truth the start,

then we will not face problem in the future.

any one want to responsible because his name marked as updater when he never do?

any one want to responsible the his article marked as updated when the article never updated?

i recommend by default, TimestampBehavior never touch "update time",

and BlameableBehavior never touch "updated by".

thank you for all developers that brings yii as the best framework on earth :)

Well, you’re describing your case. There are different requirements in different projects.