Fixes #6678: yii\behaviors\SluggableBehavior will generate a new slug only when the slug attribute is empty or the source attribute is changed

This commit is contained in:
Qiang Xue
2014-12-28 11:31:18 -05:00
parent b5e5b02985
commit 654dbbb29e
2 changed files with 2 additions and 1 deletions

View File

@ -16,6 +16,7 @@ Yii Framework 2 Change Log
- Enh #6618: Added Model::addErrors() (slavcodev, pana1990)
- Chg #6427: In case of invalid route web application now throws exception with "Page not found" instead of "Invalid Route" (cebe, samdark)
- Chg #6641: removed zero padding from ETag strings (DaSourcerer)
- Chg #6678: `yii\behaviors\SluggableBehavior` will generate a new slug only when the slug attribute is empty or the source attribute is changed (qiangxue)
2.0.1 December 07, 2014
-----------------------

View File

@ -137,7 +137,7 @@ class SluggableBehavior extends AttributeBehavior
$attributes = (array) $this->attribute;
/* @var $owner BaseActiveRecord */
$owner = $this->owner;
if (!$owner->getIsNewRecord() && !empty($owner->{$this->slugAttribute})) {
if (!empty($owner->{$this->slugAttribute})) {
$isNewSlug = false;
if (!$this->immutable) {
foreach ($attributes as $attribute) {