Skip to content

Commit

Permalink
add clearing for stashed attributes before saving
Browse files Browse the repository at this point in the history
  • Loading branch information
klimov-paul committed Dec 22, 2023
1 parent 1e58be5 commit ce254d8
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/TypecastBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,16 @@ private function applyStashedAttributes(): void
}
}

/**
* Clears all stashed attributes.
*
* @return void
*/
private function clearStashedAttributes(): void
{
$this->_stashedAttributes = [];
}

/**
* Performs typecast for attributes values in the way they are suitable for the saving in database.
* E.g. convert objects and arrays to scalars.
Expand All @@ -459,6 +469,8 @@ private function applyStashedAttributes(): void
*/
protected function typecastAttributesForSaving(): void
{
$this->clearStashedAttributes();

foreach ($this->owner->getAttributes() as $name => $value) {
if ($value === null || is_scalar($value)) {
continue;
Expand Down

0 comments on commit ce254d8

Please sign in to comment.