Browse Source

Prepare for 1.3.0 release.

tags/1.3.0 1.3.0
Alban Jubert 7 years ago
parent
commit
8f82fab375
  1. 7
      CHANGELOG.md
  2. 3
      src/SaveRelationsBehavior.php

7
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

3
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

Loading…
Cancel
Save