File tree 4 files changed +38
-5
lines changed
4 files changed +38
-5
lines changed Original file line number Diff line number Diff line change 35
35
"require-dev" : {
36
36
"cakephp/authorization" : " ^3.0" ,
37
37
"cakephp/cakephp-codesniffer" : " ^5.0" ,
38
- "phpunit/phpunit" : " ^10.1.0"
38
+ "phpunit/phpunit" : " ^10.1.0 <=10.5.3 "
39
39
},
40
40
"suggest" : {
41
41
"ext-pdo_sqlite" : " DebugKit needs to store panel data in a database. SQLite is simple and easy to use."
Original file line number Diff line number Diff line change 1
1
<?xml version =" 1.0" encoding =" UTF-8" ?>
2
- <files psalm-version =" 5.10.0@a5effd2d2dddd1a7ea7a0f6a051ce63ff979e356" >
2
+ <files psalm-version =" 5.13.1@086b94371304750d1c673315321a55d15fc59015" >
3
+ <file src =" src/Database/Log/DebugLog.php" >
4
+ <InternalMethod >
5
+ <code >jsonSerialize</code >
6
+ </InternalMethod >
7
+ </file >
3
8
<file src =" src/DebugInclude.php" >
4
9
<PossiblyNullArrayOffset >
5
10
<code ><![CDATA[ $this->_composerPaths]]> </code >
Original file line number Diff line number Diff line change @@ -127,13 +127,33 @@ public function totalTime(): float
127
127
*/
128
128
public function log ($ level , string |Stringable $ message , array $ context = []): void
129
129
{
130
- $ query = $ context ['query ' ];
130
+ $ query = $ context ['query ' ] ?? null ;
131
131
132
132
if ($ this ->_logger ) {
133
133
$ this ->_logger ->log ($ level , $ message , $ context );
134
134
}
135
135
136
- if ($ this ->_includeSchema === false && $ this ->isSchemaQuery ($ query )) {
136
+ // This specific to Elastic Search
137
+ if (!$ query instanceof LoggedQuery && isset ($ context ['request ' ]) && isset ($ context ['response ' ])) {
138
+ $ this ->_totalTime += $ context ['response ' ]['took ' ];
139
+
140
+ $ this ->_queries [] = [
141
+ 'query ' => json_encode ([
142
+ 'method ' => $ context ['request ' ]['method ' ],
143
+ 'path ' => $ context ['request ' ]['path ' ],
144
+ 'data ' => $ context ['request ' ]['data ' ],
145
+ ], JSON_PRETTY_PRINT ),
146
+ 'took ' => $ context ['response ' ]['took ' ] ?: 0 ,
147
+ 'rows ' => $ context ['response ' ]['hits ' ]['total ' ]['value ' ] ?? $ context ['response ' ]['hits ' ]['total ' ] ?? 0 ,
148
+ ];
149
+
150
+ return ;
151
+ }
152
+
153
+ if (
154
+ !$ query instanceof LoggedQuery ||
155
+ ($ this ->_includeSchema === false && $ this ->isSchemaQuery ($ query ))
156
+ ) {
137
157
return ;
138
158
}
139
159
Original file line number Diff line number Diff line change 15
15
namespace DebugKit \Panel ;
16
16
17
17
use Cake \Core \Configure ;
18
+ use Cake \Database \Driver ;
18
19
use Cake \Datasource \ConnectionInterface ;
19
20
use Cake \Datasource \ConnectionManager ;
20
21
use Cake \ORM \Locator \LocatorAwareTrait ;
@@ -57,7 +58,14 @@ public function initialize(): void
57
58
) {
58
59
continue ;
59
60
}
60
- $ logger = $ connection ->getDriver ()->getLogger ();
61
+ $ driver = $ connection ->getDriver ();
62
+ $ logger = null ;
63
+ if ($ driver instanceof Driver) {
64
+ $ logger = $ driver ->getLogger ();
65
+ } elseif (method_exists ($ connection , 'getLogger ' )) {
66
+ // ElasticSearch connection holds the logger, not the Elastica Driver
67
+ $ logger = $ connection ->getLogger ();
68
+ }
61
69
62
70
if ($ logger instanceof DebugLog) {
63
71
$ logger ->setIncludeSchema ($ includeSchemaReflection );
You can’t perform that action at this time.
0 commit comments