Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

7269-Fix wrong create empty folder in migrate controller where action is not create #7344

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion framework/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ Yii Framework 2 Change Log
- Enh #6896: Added `yii\log\FileTarget::$enableRotation` to allow disabling log rotation when external tools are configured for this (cebe)
- Enh #7008: Removed extra white space in GridView filter cell (uran1980)
- Enh #7051: Added support for preventing swapping values between different cookies (pavimus, qiangxue)
- Enh #7255: Added support to allow widgets that use text input to specify input types (qiangxue)
- Enh #7255: Added support to allow widgets that use text input to specify input types (qiangxue)
- Enh #7269: Fixed wrong create empty folder in `yii\console\controllers\BaseMigrateController` if action is not `create` (lynicidn, samdark)
- Chg #5690: adjusted paths in message config generated by `yii message/config` to reflect directory structure better (mikehaertl, samdark)
- Chg #6661: Hyperlinks that are enclosed within an exist form will use the same form for submission if they specify both of the `href` and `data-method` attributes (qiangxue)
- Chg #7094: Console confirmation must be answered correctly. To return `true`: `y` or `yes`. To return `false`: `n` or `no`. Any other input the question will be asked again (thiagotalma)
Expand Down
5 changes: 4 additions & 1 deletion framework/console/controllers/BaseMigrateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,17 @@ public function options($actionID)
* This method is invoked right before an action is to be executed (after all possible filters.)
* It checks the existence of the [[migrationPath]].
* @param \yii\base\Action $action the action to be executed.
* @throws Exception if db component isn't configured
* @throws Exception if migrationPath is not directory and action not create.
* @return boolean whether the action should continue to be executed.
*/
public function beforeAction($action)
{
if (parent::beforeAction($action)) {
$path = Yii::getAlias($this->migrationPath);
if (!is_dir($path)) {
if ($action->id !== 'create') {
throw new Exception("\nMigration failed. Invalid config param: migrationPath is not directory.\n");
}
FileHelper::createDirectory($path);
}
$this->migrationPath = $path;
Expand Down
8 changes: 2 additions & 6 deletions framework/console/controllers/MigrateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use yii\console\Exception;
use yii\db\Connection;
use yii\db\Query;
use yii\di\Instance;
use yii\helpers\ArrayHelper;
use yii\helpers\Console;

Expand Down Expand Up @@ -92,12 +93,7 @@ public function beforeAction($action)
{
if (parent::beforeAction($action)) {
if ($action->id !== 'create') {
if (is_string($this->db)) {
$this->db = Yii::$app->get($this->db);
}
if (!$this->db instanceof Connection) {
throw new Exception("The 'db' option must refer to the application component ID of a DB connection.");
}
$this->db = Instance::ensure($this->db, Connection::className());
}
return true;
} else {
Expand Down