From 815ca6b4441809438ab83722fff3d6dd9c5bac92 Mon Sep 17 00:00:00 2001 From: Thiago Talma Date: Fri, 24 Apr 2015 12:45:15 -0300 Subject: [PATCH 1/4] Compare it equals --- framework/db/BaseActiveRecord.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/db/BaseActiveRecord.php b/framework/db/BaseActiveRecord.php index cf08433..0642926 100644 --- a/framework/db/BaseActiveRecord.php +++ b/framework/db/BaseActiveRecord.php @@ -519,7 +519,7 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface public function isAttributeChanged($name) { if (isset($this->_attributes[$name], $this->_oldAttributes[$name])) { - return $this->_attributes[$name] !== $this->_oldAttributes[$name]; + return $this->_attributes[$name] != $this->_oldAttributes[$name]; } else { return isset($this->_attributes[$name]) || isset($this->_oldAttributes[$name]); } From 4bb9ec8906f7b0cfa9831ff74b942bc867392f36 Mon Sep 17 00:00:00 2001 From: Thiago Talma Date: Fri, 24 Apr 2015 14:32:09 -0300 Subject: [PATCH 2/4] new param --- framework/db/BaseActiveRecord.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/framework/db/BaseActiveRecord.php b/framework/db/BaseActiveRecord.php index 0642926..860866d 100644 --- a/framework/db/BaseActiveRecord.php +++ b/framework/db/BaseActiveRecord.php @@ -514,12 +514,13 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface /** * Returns a value indicating whether the named attribute has been changed. * @param string $name the name of the attribute - * @return boolean whether the attribute has been changed + * @param bool $identical if the comparison is made as identical + * @return bool whether the attribute has been changed */ - public function isAttributeChanged($name) + public function isAttributeChanged($name, $identical = true) { if (isset($this->_attributes[$name], $this->_oldAttributes[$name])) { - return $this->_attributes[$name] != $this->_oldAttributes[$name]; + return $identical ? $this->_attributes[$name] !== $this->_oldAttributes[$name] : $this->_attributes[$name] != $this->_oldAttributes[$name]; } else { return isset($this->_attributes[$name]) || isset($this->_oldAttributes[$name]); } From 4970fb1e95ad98d967db4b9e165133239d2affd6 Mon Sep 17 00:00:00 2001 From: Thiago Talma Date: Sat, 25 Apr 2015 22:36:40 -0300 Subject: [PATCH 3/4] if...else --- framework/db/BaseActiveRecord.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/framework/db/BaseActiveRecord.php b/framework/db/BaseActiveRecord.php index 860866d..88d2b3e 100644 --- a/framework/db/BaseActiveRecord.php +++ b/framework/db/BaseActiveRecord.php @@ -520,7 +520,12 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface public function isAttributeChanged($name, $identical = true) { if (isset($this->_attributes[$name], $this->_oldAttributes[$name])) { - return $identical ? $this->_attributes[$name] !== $this->_oldAttributes[$name] : $this->_attributes[$name] != $this->_oldAttributes[$name]; + if ($identical) { + $changed = $this->_attributes[$name] !== $this->_oldAttributes[$name]; + } else { + $changed = $this->_attributes[$name] != $this->_oldAttributes[$name]; + } + return $changed; } else { return isset($this->_attributes[$name]) || isset($this->_oldAttributes[$name]); } From b13d47f52ddee0314fb19f30d3b83a3f48ef9842 Mon Sep 17 00:00:00 2001 From: Thiago Talma Date: Sat, 25 Apr 2015 23:01:12 -0300 Subject: [PATCH 4/4] changelog --- framework/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 027829a..1628495 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -65,6 +65,7 @@ Yii Framework 2 Change Log - Enh: `yii\widgets\LinkPager::$firstPageLabel` and `yii\widgets\LinkPager::$lastPageLabel` now could be set to true in order to use page number as label (samdark) - Chg #7924: Migrations in history are now ordered by time applied allowing to roll back in reverse order no matter how these were applied (samdark) - Chg: Updated dependency to `cebe/markdown` to version `1.1.x` (cebe) +- Chg #8179: Added parameter to define whether the comparison of `yii\db\BaseActiveRecord::isAttributeChanged()` method will be made as identical (thiagotalma) 2.0.3 March 01, 2015