From 39e89f3a39b280f83bd5a10bb2f6344be1a013bc Mon Sep 17 00:00:00 2001 From: Joep Roebroek Date: Thu, 31 May 2018 08:25:11 +0200 Subject: [PATCH] Fix #12163 --- src/ORM/Table.php | 6 +++--- tests/TestCase/ORM/TableTest.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ORM/Table.php b/src/ORM/Table.php index a4979a8cc03..856850d0738 100644 --- a/src/ORM/Table.php +++ b/src/ORM/Table.php @@ -1675,13 +1675,13 @@ protected function _transactionCommitted($atomic, $primary) */ public function findOrCreate($search, callable $callback = null, $options = []) { - $options += [ + $options = new ArrayObject($options + [ 'atomic' => true, 'defaults' => true, - ]; + ]); $entity = $this->_executeTransaction(function () use ($search, $callback, $options) { - return $this->_processFindOrCreate($search, $callback, $options); + return $this->_processFindOrCreate($search, $callback, $options->getArrayCopy()); }, $options['atomic']); if ($entity && $this->_transactionCommitted($options['atomic'], true)) { diff --git a/tests/TestCase/ORM/TableTest.php b/tests/TestCase/ORM/TableTest.php index cb64a03de53..feaf45e35d1 100644 --- a/tests/TestCase/ORM/TableTest.php +++ b/tests/TestCase/ORM/TableTest.php @@ -6150,7 +6150,7 @@ public function testFindOrCreateNoDefaults() public function testFindOrCreateTransactions() { $articles = $this->getTableLocator()->get('Articles'); - $articles->getEventManager()->on('Model.afterSaveCommit', function ($event, $entity) { + $articles->getEventManager()->on('Model.afterSaveCommit', function (Event $event, EntityInterface $entity, ArrayObject $options) { $entity->afterSaveCommit = true; });