File tree 2 files changed +10
-1
lines changed
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)
72
72
73
73
$ walker = function (&$ item ) use (&$ walker ) {
74
74
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
+ }
76
81
} elseif ($ item instanceof Closure ||
77
82
$ item instanceof PDO ||
78
83
$ item instanceof SimpleXmlElement
Original file line number Diff line number Diff line change @@ -58,10 +58,13 @@ public function testShutdown()
58
58
$ requests = TableRegistry::get ('Requests ' );
59
59
$ query = $ requests ->find ('all ' );
60
60
$ result = $ requests ->find ()->all ();
61
+ $ unbufferedQuery = $ requests ->find ('all ' )->bufferResults (false );
62
+ $ unbufferedQuery ->toArray (); //toArray call would normally happen somewhere in View, usually implicitly
61
63
62
64
$ controller = new \StdClass ();
63
65
$ controller ->viewVars = [
64
66
'query ' => $ query ,
67
+ 'unbufferedQuery ' => $ unbufferedQuery ,
65
68
'result set ' => $ result ,
66
69
'string ' => 'yes ' ,
67
70
'array ' => ['some ' => 'key ' ]
@@ -76,6 +79,7 @@ public function testShutdown()
76
79
'Original value should not be mutated '
77
80
);
78
81
$ this ->assertInternalType ('array ' , $ output ['content ' ]['query ' ]);
82
+ $ this ->assertInternalType ('array ' , $ output ['content ' ]['unbufferedQuery ' ]);
79
83
$ this ->assertInternalType ('array ' , $ output ['content ' ]['result set ' ]);
80
84
$ this ->assertEquals ($ controller ->viewVars ['string ' ], $ output ['content ' ]['string ' ]);
81
85
$ this ->assertEquals ($ controller ->viewVars ['array ' ], $ output ['content ' ]['array ' ]);
You can’t perform that action at this time.
0 commit comments