Browse Source

Merge pull request #12164 from JoepRoebroek/patch-12163

Fix #12163
Mark Story 7 years ago
parent
commit
28fe5ff171
2 changed files with 4 additions and 4 deletions
  1. 3 3
      src/ORM/Table.php
  2. 1 1
      tests/TestCase/ORM/TableTest.php

+ 3 - 3
src/ORM/Table.php

@@ -1675,13 +1675,13 @@ class Table implements RepositoryInterface, EventListenerInterface, EventDispatc
      */
      */
     public function findOrCreate($search, callable $callback = null, $options = [])
     public function findOrCreate($search, callable $callback = null, $options = [])
     {
     {
-        $options += [
+        $options = new ArrayObject($options + [
             'atomic' => true,
             'atomic' => true,
             'defaults' => true,
             'defaults' => true,
-        ];
+        ]);
 
 
         $entity = $this->_executeTransaction(function () use ($search, $callback, $options) {
         $entity = $this->_executeTransaction(function () use ($search, $callback, $options) {
-            return $this->_processFindOrCreate($search, $callback, $options);
+            return $this->_processFindOrCreate($search, $callback, $options->getArrayCopy());
         }, $options['atomic']);
         }, $options['atomic']);
 
 
         if ($entity && $this->_transactionCommitted($options['atomic'], true)) {
         if ($entity && $this->_transactionCommitted($options['atomic'], true)) {

+ 1 - 1
tests/TestCase/ORM/TableTest.php

@@ -6150,7 +6150,7 @@ class TableTest extends TestCase
     public function testFindOrCreateTransactions()
     public function testFindOrCreateTransactions()
     {
     {
         $articles = $this->getTableLocator()->get('Articles');
         $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;
             $entity->afterSaveCommit = true;
         });
         });