diff --git a/CHANGELOG.md b/CHANGELOG.md index 55e30da..4b10933 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,14 +1,13 @@ # Yii2 Active Record Save Relations Behavior Change Log ## [1.3.0] -- Unreleased version - ### Added -- Ability to define validation scenario for related records +- Enh #3: Ability to define validation scenario for related records +- Enh #7: Exception logging during `beforeValidate` and `afterSave` events. - More test cases ### Fixed -- False positive testLoadRelationsShouldSucceed test case +- False positive `testLoadRelationsShouldSucceed` test case ### Changed - afterSave throw exception if a related record fail to be saved. In that case, a database rollback is triggered (when relevant) and an error is attached to the according relation attribute diff --git a/src/SaveRelationsBehavior.php b/src/SaveRelationsBehavior.php index fc22106..37b4676 100644 --- a/src/SaveRelationsBehavior.php +++ b/src/SaveRelationsBehavior.php @@ -286,7 +286,7 @@ class SaveRelationsBehavior extends Behavior throw new Exception("One of the related model could not be validated"); } } catch (Exception $e) { - Yii::warning(get_class($e) . " was thrown during the saving of related records : " . $e->getMessage(), __METHOD__); + Yii::warning(get_class($e) . " was thrown while saving related records during beforeValidate event: " . $e->getMessage(), __METHOD__); $this->_rollback(); $event->isValid = false; // Stop saving, something went wrong return false; @@ -411,6 +411,7 @@ class SaveRelationsBehavior extends Behavior } } } catch (Exception $e) { + Yii::warning(get_class($e) . " was thrown while saving related records during afterSave event: " . $e->getMessage(), __METHOD__); $this->_rollback(); /*** * Sadly mandatory because the error occurred during afterSave event