diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 9a79054948..20e13db12b 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -46,6 +46,7 @@ Yii Framework 2 Change Log - Bug #13277: Fixed invalid parsing of `--` ("End of Options" special argument) in CLI (rugabarbo) - Bug #13309: Fixes incorrect console width/height detecting with using Stty on Mac (nowm) - Bug #13326: Fixed wrong background color generation in `BaseConsole::renderColoredString()` (nowm, silverfire) +- Bug #12133: Fixed `getDbTargets()` function in `yii\log\migrations\m141106_185632_log_init` that would create a log table correctly (bumstik) - Enh #475: Added Bash and Zsh completion support for the `./yii` command (cebe, silverfire) - Enh #6242: Access to validator in inline validation (arogachev) - Enh #6373: Introduce `yii\db\Query::emulateExecution()` to force returning an empty result for a query (klimov-paul) diff --git a/framework/log/migrations/m141106_185632_log_init.php b/framework/log/migrations/m141106_185632_log_init.php index 3cef167df2..899176d41b 100644 --- a/framework/log/migrations/m141106_185632_log_init.php +++ b/framework/log/migrations/m141106_185632_log_init.php @@ -22,7 +22,7 @@ use yii\log\DbTarget; class m141106_185632_log_init extends Migration { /** - * @var DbTarget[] + * @var DbTarget[] Targets to create log table for */ private $dbTargets = []; @@ -35,9 +35,18 @@ class m141106_185632_log_init extends Migration if ($this->dbTargets === []) { $log = Yii::$app->getLog(); + $usedTargets = []; foreach ($log->targets as $target) { if ($target instanceof DbTarget) { - $this->dbTargets[] = $target; + $currentTarget = [ + $target->db, + $target->logTable, + ]; + if (!in_array($currentTarget, $usedTargets, true)) { + // do not create same table twice + $usedTargets[] = $currentTarget; + $this->dbTargets[] = $target; + } } }