Skip to content

Commit 8c6bd6c

Browse files
committed
Merge branch '5.x' into 5.next
2 parents 4b2c788 + 9353638 commit 8c6bd6c

24 files changed

+80
-42
lines changed

.phive/phars.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phive xmlns="https://phar.io/phive">
3-
<phar name="phpstan" version="2.0.1" installed="2.0.1" location="./tools/phpstan" copy="false"/>
3+
<phar name="phpstan" version="2.1.0" installed="2.1.0" location="./tools/phpstan" copy="false"/>
44
<phar name="psalm" version="5.26.1" installed="5.26.1" location="./tools/psalm" copy="false"/>
55
</phive>

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,9 @@ php composer.phar require --dev cakephp/debug_kit:"^5.0"
2828
```
2929

3030
* [Load the plugin](https://book.cakephp.org/5/en/plugins.html#loading-a-plugin)
31-
```php
32-
// src/Application.php
33-
$this->addPlugin('DebugKit');
3431
```
35-
* Set `'debug' => true,` in `config/app.php`.
32+
bin/cake plugin load DebugKit --only-debug
33+
```
3634

3735
## Is DebugKit not working?
3836

@@ -69,3 +67,4 @@ Documentation for DebugKit can be found in the
6967
## Panels
7068
Panels by other plugins:
7169
- `L10n` by [Setup plugin](https://github.com/dereuromark/cakephp-setup) to show current localization for Date, DateTime, Time objects/values.
70+
- `Twig` by [Twig plugin](https://github.com/cakephp/twig-view/) to list all templates.

phpstan.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ includes:
22
- phpstan-baseline.neon
33

44
parameters:
5-
level: 6
5+
level: 8
66
treatPhpDocTypesAsCertain: false
77
bootstrapFiles:
88
- tests/bootstrap.php

psalm-baseline.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<files psalm-version="5.26.1@d747f6500b38ac4f7dfc5edbcae6e4b637d7add0">
33
<file src="src/Database/Log/DebugLog.php">
44
<InternalMethod>
5+
<code><![CDATA[getContext]]></code>
56
<code><![CDATA[jsonSerialize]]></code>
67
</InternalMethod>
78
</file>

src/Command/BenchmarkCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ protected function buildOptionParser(ConsoleOptionParser $parser): ConsoleOption
169169
{
170170
$parser->setDescription(
171171
'Allows you to obtain some rough benchmarking statistics' .
172-
'about a fully qualified URL.'
172+
'about a fully qualified URL.',
173173
)
174174
->addArgument('url', [
175175
'help' => 'The URL to request.',
@@ -187,7 +187,7 @@ protected function buildOptionParser(ConsoleOptionParser $parser): ConsoleOption
187187
])
188188
->setEpilog(
189189
'Example Use: `cake benchmark --n 10 --t 100 http://localhost/testsite`. ' .
190-
'<info>Note:</info> this benchmark does not include browser render times.'
190+
'<info>Note:</info> this benchmark does not include browser render times.',
191191
);
192192

193193
return $parser;

src/Controller/DebugKitController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function beforeFilter(EventInterface $event): void
4949
Log::info(
5050
'Cake Authorization plugin is enabled. If you would like ' .
5151
'to force DebugKit to ignore it, set `DebugKit.ignoreAuthorization` ' .
52-
' Configure option to true.'
52+
' Configure option to true.',
5353
);
5454
}
5555
}

src/Controller/MailPreviewController.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,7 @@ protected function findPreferredPart(AbstractResult $email, ?string $partType):
254254
}
255255
}
256256

257-
/** @psalm-suppress PossiblyNullArgument */
258-
return $this->findPart($email, $partType) ?: null;
257+
return $this->findPart($email, (string)$partType) ?: null;
259258
}
260259

261260
/**
@@ -285,7 +284,7 @@ protected function findPreview(string $previewName, string $emailName, string $p
285284
throw new NotFoundException(sprintf(
286285
'Mailer preview `%s::%s` not found',
287286
$previewName,
288-
$emailName
287+
$emailName,
289288
));
290289
}
291290

src/Database/Log/DebugLog.php

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ class DebugLog extends AbstractLogger
6565
*/
6666
protected bool $_includeSchema = false;
6767

68+
/**
69+
* Whether a transaction is currently open or not.
70+
*
71+
* @var bool
72+
*/
73+
protected bool $inTransaction = false;
74+
6875
/**
6976
* Constructor
7077
*
@@ -127,6 +134,7 @@ public function totalTime(): float
127134
*/
128135
public function log($level, string|Stringable $message, array $context = []): void
129136
{
137+
/** @var \Cake\Database\Log\LoggedQuery|object|null $query */
130138
$query = $context['query'] ?? null;
131139

132140
if ($this->_logger) {
@@ -146,6 +154,9 @@ public function log($level, string|Stringable $message, array $context = []): vo
146154
], JSON_PRETTY_PRINT),
147155
'took' => $took,
148156
'rows' => $context['response']['hits']['total']['value'] ?? $context['response']['hits']['total'] ?? 0,
157+
'inTransaction' => $this->inTransaction,
158+
'isCommitOrRollback' => false,
159+
'role' => '',
149160
];
150161

151162
return;
@@ -162,11 +173,26 @@ public function log($level, string|Stringable $message, array $context = []): vo
162173

163174
$this->_totalTime += $data['took'];
164175

176+
$sql = (string)$query;
177+
$isBegin = $sql === 'BEGIN';
178+
$isCommitOrRollback = $sql === 'COMMIT' || $sql === 'ROLLBACK';
179+
180+
if ($isBegin) {
181+
$this->inTransaction = true;
182+
}
183+
165184
$this->_queries[] = [
166-
'query' => (string)$query,
185+
'query' => $sql,
167186
'took' => $data['took'],
168187
'rows' => $data['numRows'],
188+
'inTransaction' => $this->inTransaction,
189+
'isCommitOrRollback' => $isCommitOrRollback,
190+
'role' => $query->getContext()['role'],
169191
];
192+
193+
if ($isCommitOrRollback) {
194+
$this->inTransaction = false;
195+
}
170196
}
171197

172198
/**

src/DebugSql.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public static function sql(
7272
Query $query,
7373
bool $showValues = true,
7474
?bool $showHtml = null,
75-
int $stackDepth = 0
75+
int $stackDepth = 0,
7676
): Query {
7777
if (!Configure::read('debug')) {
7878
return $query;
@@ -126,7 +126,7 @@ public static function sql(
126126
HtmlHighlighter::HIGHLIGHT_WORD => 'style="color: #9c27b0;"',
127127
HtmlHighlighter::HIGHLIGHT_PRE => 'style="color: #222; background-color: transparent;"',
128128
],
129-
false
129+
false,
130130
);
131131
} else {
132132
$highlighter = new NullHighlighter();
@@ -164,7 +164,7 @@ public static function sqld(
164164
Query $query,
165165
bool $showValues = true,
166166
?bool $showHtml = null,
167-
int $stackDepth = 1
167+
int $stackDepth = 1,
168168
): void {
169169
static::sql($query, $showValues, $showHtml, $stackDepth);
170170
die(1);
@@ -221,6 +221,6 @@ private static function interpolate(string $sql, array $bindings): string
221221
$keys[] = is_string($key) ? "/$key\b/" : '/[?]/';
222222
}
223223

224-
return preg_replace($keys, $params, $sql, $limit);
224+
return (string)preg_replace($keys, $params, $sql, $limit);
225225
}
226226
}

src/Mailer/Transport/DebugKitTransport.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function __construct(array $config = [], ?AbstractTransport $originalTran
5151
$className = App::className(
5252
$config['originalClassName'],
5353
'Mailer/Transport',
54-
'Transport'
54+
'Transport',
5555
);
5656
}
5757

0 commit comments

Comments
 (0)