Skip to content

Commit 5ebd299

Browse files
authored
Fix query logger (#712)
Removed string cast when logging LoggedQuery Fixed errors reported by static analyzers
1 parent 440be3b commit 5ebd299

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/Controller/Component/CrudComponent.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ public function execute(?string $controllerAction = null, array $args = []): Res
233233
{
234234
$this->_loadListeners();
235235

236-
$this->_action = $controllerAction ?: $this->_action;
236+
$this->_action = $controllerAction ?? $this->_action;
237237

238238
$action = $this->_action;
239239
if (empty($args)) {
@@ -275,7 +275,7 @@ public function execute(?string $controllerAction = null, array $args = []): Res
275275
*/
276276
public function action(?string $name = null): BaseAction
277277
{
278-
if (empty($name)) {
278+
if ($name === null) {
279279
$name = $this->_action;
280280
}
281281

@@ -425,7 +425,7 @@ public function mapAction(string $action, array|string $config = [], bool $enabl
425425
*/
426426
public function isActionMapped(?string $action = null): bool
427427
{
428-
if (empty($action)) {
428+
if ($action === null) {
429429
$action = $this->_action;
430430
}
431431

@@ -448,7 +448,7 @@ public function isActionMapped(?string $action = null): bool
448448
public function on(array|string $events, callable $callback, array $options = []): void
449449
{
450450
foreach ((array)$events as $event) {
451-
if (!strpos($event, '.')) {
451+
if (!str_contains($event, '.')) {
452452
$event = $this->_config['eventPrefix'] . '.' . $event;
453453
}
454454

src/Log/QueryLogger.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function getLogs(): array
3030
*/
3131
public function log($level, string|Stringable $message, array $context = []): void
3232
{
33-
$this->_logs[] = (string)$context['query'];
33+
$this->_logs[] = $context['query'];
3434

3535
parent::log($level, $message, $context);
3636
}

0 commit comments

Comments
 (0)