From 171773b7078c47324590dd821a66f03e52844c75 Mon Sep 17 00:00:00 2001 From: Kirsa Denis Date: Thu, 24 Dec 2015 14:09:56 +0300 Subject: [PATCH] Don't crush application if newrelic ext is missing --- Newrelic.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Newrelic.php b/Newrelic.php index fefa453..91e9f6d 100644 --- a/Newrelic.php +++ b/Newrelic.php @@ -70,10 +70,15 @@ public function init() { parent::init(); - if ($this->enabled && Agent::isLoaded()) { - $this->name = $this->name ? $this->name : \Yii::$app->name; - $this->agent = new Agent(); - $this->agent->setAppname($this->name, $this->licence); + if ($this->enabled) { + if (Agent::isLoaded()) { + $this->name = $this->name ? $this->name : \Yii::$app->name; + $this->agent = new Agent(); + $this->agent->setAppname($this->name, $this->licence); + } else { + $this->enabled = false; + \Yii::$app->getLog()->getLogger()->log('Newrelic extension is not loaded', \yii\log\Logger::LEVEL_ERROR); + } } } }