Browse Source

Fixes #4571: ignore non-string attribute names for AttributeBehavior.

tags/2.0.0-rc
Qiang Xue 10 years ago
parent
commit
378b765e48
  1. 3
      framework/behaviors/AttributeBehavior.php
  2. 2
      framework/behaviors/BlameableBehavior.php
  3. 4
      framework/behaviors/TimestampBehavior.php

3
framework/behaviors/AttributeBehavior.php

@ -93,10 +93,13 @@ class AttributeBehavior extends Behavior
$attributes = (array) $this->attributes[$event->name];
$value = $this->getValue($event);
foreach ($attributes as $attribute) {
// ignore attribute names which are not string (e.g. when set by TimestampBehavior::updatedAtAttribute)
if (is_string($attribute)) {
$this->owner->$attribute = $value;
}
}
}
}
/**
* Returns the value of the current attributes.

2
framework/behaviors/BlameableBehavior.php

@ -54,10 +54,12 @@ class BlameableBehavior extends AttributeBehavior
{
/**
* @var string the attribute that will receive current user ID value
* Set this property to be null if you do not want to record the creator ID.
*/
public $createdByAttribute = 'created_by';
/**
* @var string the attribute that will receive current user ID value
* Set this property to be null if you do not want to record the updater ID.
*/
public $updatedByAttribute = 'updated_by';
/**

4
framework/behaviors/TimestampBehavior.php

@ -64,10 +64,12 @@ class TimestampBehavior extends AttributeBehavior
{
/**
* @var string the attribute that will receive timestamp value
* Set this property to be null if you do not want to record the creation time.
*/
public $createdAtAttribute = 'created_at';
/**
* @var string the attribute that will receive timestamp value
* @var string the attribute that will receive timestamp value.
* Set this property to be null if you do not want to record the update time.
*/
public $updatedAtAttribute = 'updated_at';
/**

Loading…
Cancel
Save