File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed
Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -72,7 +72,12 @@ public function shutdown(Event $event)
7272
7373 $ walker = function (&$ item ) use (&$ walker ) {
7474 if ($ item instanceof Query || $ item instanceof ResultSet) {
75- $ item = $ item ->toArray ();
75+ try {
76+ $ item = $ item ->toArray ();
77+ } catch (\Cake \Database \Exception $ e ) {
78+ //Likely issue is unbuffered query; fall back to __debugInfo
79+ $ item = array_map ($ walker , $ item ->__debugInfo ());
80+ }
7681 } elseif ($ item instanceof Closure ||
7782 $ item instanceof PDO ||
7883 $ item instanceof SimpleXmlElement
Original file line number Diff line number Diff line change @@ -58,10 +58,13 @@ public function testShutdown()
5858 $ requests = TableRegistry::get ('Requests ' );
5959 $ query = $ requests ->find ('all ' );
6060 $ result = $ requests ->find ()->all ();
61+ $ unbufferedQuery = $ requests ->find ('all ' )->bufferResults (false );
62+ $ unbufferedQuery ->toArray (); //toArray call would normally happen somewhere in View, usually implicitly
6163
6264 $ controller = new \StdClass ();
6365 $ controller ->viewVars = [
6466 'query ' => $ query ,
67+ 'unbufferedQuery ' => $ unbufferedQuery ,
6568 'result set ' => $ result ,
6669 'string ' => 'yes ' ,
6770 'array ' => ['some ' => 'key ' ]
@@ -76,6 +79,7 @@ public function testShutdown()
7679 'Original value should not be mutated '
7780 );
7881 $ this ->assertInternalType ('array ' , $ output ['content ' ]['query ' ]);
82+ $ this ->assertInternalType ('array ' , $ output ['content ' ]['unbufferedQuery ' ]);
7983 $ this ->assertInternalType ('array ' , $ output ['content ' ]['result set ' ]);
8084 $ this ->assertEquals ($ controller ->viewVars ['string ' ], $ output ['content ' ]['string ' ]);
8185 $ this ->assertEquals ($ controller ->viewVars ['array ' ], $ output ['content ' ]['array ' ]);
You can’t perform that action at this time.
0 commit comments