From ae576bf740b53f1a1b7f298fbd1b9ac7e3da2005 Mon Sep 17 00:00:00 2001 From: Brad Bell Date: Thu, 23 May 2019 14:21:50 -0700 Subject: [PATCH] Fix 255 exit code from codeception --- src/base/LogTargetTrait.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/base/LogTargetTrait.php b/src/base/LogTargetTrait.php index f00615ef70b..41b8e4832da 100644 --- a/src/base/LogTargetTrait.php +++ b/src/base/LogTargetTrait.php @@ -85,11 +85,17 @@ protected function getContextMessage(): string { $context = ArrayHelper::filter($GLOBALS, $this->logVars); $result = []; - $security = Craft::$app->getSecurity(); - foreach ($context as $key => $value) { - $value = $security->redactIfSensitive($key, $value); - $result[] = "\${$key} = " . VarDumper::dumpAsString($value); + // Workaround for codeception testing until these gets addressed: + // https://github.com/yiisoft/yii-core/issues/49 + // https://github.com/yiisoft/yii2/issues/15847 + if (Craft::$app) { + $security = Craft::$app->getSecurity(); + + foreach ($context as $key => $value) { + $value = $security->redactIfSensitive($key, $value); + $result[] = "\${$key} = " . VarDumper::dumpAsString($value); + } } return implode("\n\n", $result);