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

This commit is contained in:
octicon-git-branch(16/)
octicon-tag(16/)
lynicidn
2015-02-19 02:04:59 +03:00
committed by Alexander Makarov
gitea-unlock(16/)
parent 6e2e929f7a
commit a71423cf2a
octicon-diff(16/tw-mr-1) 2 changed files with 6 additions and 2 deletions

5
framework/console/controllers/BaseMigrateController.php
View File

@@ -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;