Ensure WP_DEBUG is cast to a boolean value

[MAILPOET-5608]
This commit is contained in:
David Remer
2023-09-26 13:42:22 +03:00
committed by Aschepikov
parent ad56797328
commit a464df2831

View File

@@ -42,7 +42,7 @@ class StepRunLogger {
string $stepId,
string $stepType,
int $runNumber,
bool $isWpDebug = WP_DEBUG
bool $isWpDebug = null
) {
$this->automationRunLogStorage = $automationRunLogStorage;
$this->hooks = $hooks;
@@ -50,7 +50,17 @@ class StepRunLogger {
$this->stepId = $stepId;
$this->stepType = $stepType;
$this->runNumber = $runNumber;
$this->isWpDebug = $isWpDebug;
$this->isWpDebug = $isWpDebug !== null ? $isWpDebug : $this->getWpDebug();
}
private function getWpDebug(): bool {
if (!defined('WP_DEBUG')) {
return false;
}
if (!is_bool(WP_DEBUG)) {
return in_array(strtolower((string)WP_DEBUG), ['true', '1'], true);
}
return WP_DEBUG;
}
public function logStart(): void {