From b1d94e5c95e8607d87287c4bc5334301279800f0 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Wed, 7 May 2014 04:04:44 +0400 Subject: [PATCH] Removed unnecessary instance check, fixed Sphinx schema --- extensions/sphinx/Schema.php | 6 ++++++ framework/db/Command.php | 10 ++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/extensions/sphinx/Schema.php b/extensions/sphinx/Schema.php index 7b1bb6f..27a6df7 100644 --- a/extensions/sphinx/Schema.php +++ b/extensions/sphinx/Schema.php @@ -60,6 +60,12 @@ class Schema extends Object private $_builder; /** + * @var array map of DB errors and corresponding exceptions + * If left part is found in DB error message exception class from the right part is used. + */ + public $exceptionMap = []; + + /** * @var array mapping from physical column types (keys) to abstract column types (values) */ public $typeMap = [ diff --git a/framework/db/Command.php b/framework/db/Command.php index f81e9e7..e3f2c49 100644 --- a/framework/db/Command.php +++ b/framework/db/Command.php @@ -782,12 +782,10 @@ class Command extends \yii\base\Component } else { $exceptionClass = '\yii\db\Exception'; $schema = $this->db->getSchema(); - if ($schema instanceof Schema) { - $exceptionMap = $schema->exceptionMap; - foreach ($exceptionMap as $error => $class) { - if (strpos($e->getMessage(), $error) !== false) { - $exceptionClass = $class; - } + $exceptionMap = $schema->exceptionMap; + foreach ($exceptionMap as $error => $class) { + if (strpos($e->getMessage(), $error) !== false) { + $exceptionClass = $class; } }