From ae42d7b2818b83c919c7a868ebdd77afe44f2e6f Mon Sep 17 00:00:00 2001 From: Daniel Gomez Pan Date: Sun, 11 Sep 2016 18:03:09 +0200 Subject: [PATCH] Fix #12423 Fix bug migration tool when creating fields with brackets in comment --- framework/CHANGELOG.md | 1 + framework/console/controllers/MigrateController.php | 2 +- tests/data/console/migrate_create/create_fields.php | 1 + .../console/controllers/MigrateControllerTestTrait.php | 3 ++- 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index a48d932a29..220db52ed0 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -16,6 +16,7 @@ Yii Framework 2 Change Log - Enh #10583: Do not silence session errors in debug mode (samdark) - Enh #12048: Improved message extraction command performance (samdark) - Enh #12038: Introduced `yii\base\ViewNotFoundException` which is thrown when views file doesn't exists, used it in `ViewAction` (samdark) +- Bug #12423: Fixed bug migration tool when creating fields with brackets in comment 2.0.9 July 11, 2016 ------------------- diff --git a/framework/console/controllers/MigrateController.php b/framework/console/controllers/MigrateController.php index 487af24817..6ea19c4b3c 100644 --- a/framework/console/controllers/MigrateController.php +++ b/framework/console/controllers/MigrateController.php @@ -351,7 +351,7 @@ class MigrateController extends BaseMigrateController continue; } - if (!preg_match('/^(.+?)\(([^)]+)\)$/', $chunk)) { + if (!preg_match('/^(.+?)\(([^(]+)\)$/', $chunk)) { $chunk .= '()'; } } diff --git a/tests/data/console/migrate_create/create_fields.php b/tests/data/console/migrate_create/create_fields.php index b18a5dded4..1a412eb2a5 100644 --- a/tests/data/console/migrate_create/create_fields.php +++ b/tests/data/console/migrate_create/create_fields.php @@ -20,6 +20,7 @@ class {$class} extends Migration 'title' => \$this->string(10)->notNull()->unique()->defaultValue("test"), 'body' => \$this->text()->notNull(), 'price' => \$this->money(11,2)->notNull(), + 'parenthesis_in_comment' => \$this->string(255)->notNull()->comment('Name of set (RU)'), ]); } diff --git a/tests/framework/console/controllers/MigrateControllerTestTrait.php b/tests/framework/console/controllers/MigrateControllerTestTrait.php index dbd73acfa6..0fcacf2e91 100644 --- a/tests/framework/console/controllers/MigrateControllerTestTrait.php +++ b/tests/framework/console/controllers/MigrateControllerTestTrait.php @@ -203,7 +203,8 @@ CODE; $this->assertCommandCreatedFile('create_fields', $migrationName, [ 'fields' => 'title:string(10):notNull:unique:defaultValue("test"), body:text:notNull, - price:money(11,2):notNull' + price:money(11,2):notNull, + parenthesis_in_comment:string(255):notNull:comment(\'Name of set (RU)\')' ]); $this->assertCommandCreatedFile('create_title_pk', $migrationName, [