From 654dbbb29e7cd37851a06cd7d8ce71ab6972ad45 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Sun, 28 Dec 2014 11:31:18 -0500 Subject: [PATCH] Fixes #6678: `yii\behaviors\SluggableBehavior` will generate a new slug only when the slug attribute is empty or the source attribute is changed --- framework/CHANGELOG.md | 1 + framework/behaviors/SluggableBehavior.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 635aa6fbd9..6c6025ef92 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -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 ----------------------- diff --git a/framework/behaviors/SluggableBehavior.php b/framework/behaviors/SluggableBehavior.php index 8b49eaa4b4..79d38cf893 100644 --- a/framework/behaviors/SluggableBehavior.php +++ b/framework/behaviors/SluggableBehavior.php @@ -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) {