Skip to content

Commit

Permalink
Fixed _doLowUpdate warning
Browse files Browse the repository at this point in the history
  • Loading branch information
Jurigag committed Mar 23, 2017
1 parent a3e22a9 commit 61f7fee
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# [3.1.1](https://github.com/phalcon/cphalcon/releases/tag/v3.1.1) (2017-XX-XX)
- Fixed undefined index warning on existing cached resultsets
- Fixed `Phalcon\Mvc\Model::_dowLowUpdate` warning first argument is not an array

# [3.1.0](https://github.com/phalcon/cphalcon/releases/tag/v3.1.0) (2017-03-22)
- Added `Phalcon\Validation\Validator\Callback`, `Phalcon\Validation::getData`
Expand Down
8 changes: 6 additions & 2 deletions phalcon/mvc/model.zep
Original file line number Diff line number Diff line change
Expand Up @@ -2650,8 +2650,12 @@ abstract class Model implements EntityInterface, ModelInterface, ResultInterface
], bindTypes);

if success && manager->isKeepingSnapshots(this) {
let this->_snapshot = array_merge(this->_snapshot, newSnapshot);
}
if typeof this->_snapshot == "array" {
let this->_snapshot = array_merge(this->_snapshot, newSnapshot);
} else {
let this->_snapshot = newSnapshot;
}
}

return success;
}
Expand Down
17 changes: 17 additions & 0 deletions tests/unit/Mvc/Model/SnapshotTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,4 +299,21 @@ function () {
}
);
}

/**
* @author Wojciech Ślawski <jurigag@gmail.com>
* @since 2017-03-23
*/
public function testNewInstanceUpdate()
{
$this->specify(
'When updating model from new instance there is some problem',
function () {
$this->setUpModelsManager();
$robots = Robots::findFirst();
$robots = new Robots($robots->toArray());
expect($robots->save())->true();
}
);
}
}

0 comments on commit 61f7fee

Please sign in to comment.