Skip to content

Commit 171773b

Browse files
committed
Don't crush application if newrelic ext is missing
1 parent d35d140 commit 171773b

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

Newrelic.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,15 @@ public function init()
7070
{
7171
parent::init();
7272

73-
if ($this->enabled && Agent::isLoaded()) {
74-
$this->name = $this->name ? $this->name : \Yii::$app->name;
75-
$this->agent = new Agent();
76-
$this->agent->setAppname($this->name, $this->licence);
73+
if ($this->enabled) {
74+
if (Agent::isLoaded()) {
75+
$this->name = $this->name ? $this->name : \Yii::$app->name;
76+
$this->agent = new Agent();
77+
$this->agent->setAppname($this->name, $this->licence);
78+
} else {
79+
$this->enabled = false;
80+
\Yii::$app->getLog()->getLogger()->log('Newrelic extension is not loaded', \yii\log\Logger::LEVEL_ERROR);
81+
}
7782
}
7883
}
7984
}

0 commit comments

Comments
 (0)