File tree Expand file tree Collapse file tree 4 files changed +38
-5
lines changed
Expand file tree Collapse file tree 4 files changed +38
-5
lines changed Original file line number Diff line number Diff line change 3535 "require-dev" : {
3636 "cakephp/authorization" : " ^3.0" ,
3737 "cakephp/cakephp-codesniffer" : " ^5.0" ,
38- "phpunit/phpunit" : " ^10.1.0"
38+ "phpunit/phpunit" : " ^10.1.0 <=10.5.3 "
3939 },
4040 "suggest" : {
4141 "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 11<?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 >
38 <file src =" src/DebugInclude.php" >
49 <PossiblyNullArrayOffset >
510 <code ><![CDATA[ $this->_composerPaths]]> </code >
Original file line number Diff line number Diff line change @@ -127,13 +127,33 @@ public function totalTime(): float
127127 */
128128 public function log ($ level , string |Stringable $ message , array $ context = []): void
129129 {
130- $ query = $ context ['query ' ];
130+ $ query = $ context ['query ' ] ?? null ;
131131
132132 if ($ this ->_logger ) {
133133 $ this ->_logger ->log ($ level , $ message , $ context );
134134 }
135135
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+ ) {
137157 return ;
138158 }
139159
Original file line number Diff line number Diff line change 1515namespace DebugKit \Panel ;
1616
1717use Cake \Core \Configure ;
18+ use Cake \Database \Driver ;
1819use Cake \Datasource \ConnectionInterface ;
1920use Cake \Datasource \ConnectionManager ;
2021use Cake \ORM \Locator \LocatorAwareTrait ;
@@ -57,7 +58,14 @@ public function initialize(): void
5758 ) {
5859 continue ;
5960 }
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+ }
6169
6270 if ($ logger instanceof DebugLog) {
6371 $ logger ->setIncludeSchema ($ includeSchemaReflection );
You can’t perform that action at this time.
0 commit comments