Browse Source

Fixes #7269: `yii\console\controllers\BaseMigrateController` now throws exception if directory specified doesn't exist and action isn't `create`

tags/2.0.3
lynicidn 10 years ago committed by Alexander Makarov
parent
commit
a71423cf2a
  1. 1
      framework/CHANGELOG.md
  2. 5
      framework/console/controllers/BaseMigrateController.php

1
framework/CHANGELOG.md

@ -29,6 +29,7 @@ Yii Framework 2 Change Log
- 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 #7269: `yii\console\controllers\BaseMigrateController` now throws exception if directory specified doesn't exist and action isn't `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)

5
framework/console/controllers/BaseMigrateController.php

@ -59,7 +59,7 @@ abstract class BaseMigrateController extends Controller
* 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 directory specified in migrationPath doesn't exist and action isn't "create".
* @return boolean whether the action should continue to be executed.
*/
public function beforeAction($action)
@ -67,6 +67,9 @@ abstract class BaseMigrateController extends Controller
if (parent::beforeAction($action)) {
$path = Yii::getAlias($this->migrationPath);
if (!is_dir($path)) {
if ($action->id !== 'create') {
throw new Exception('Migration failed. Directory specified in migrationPath doesn\'t exist.');
}
FileHelper::createDirectory($path);
}
$this->migrationPath = $path;

Loading…
Cancel
Save