Skip to content

Commit

Permalink
Fixed #6220
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Jun 18, 2020
1 parent e9e642b commit c608d49
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 26 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-v3.md
Expand Up @@ -10,6 +10,7 @@
- Fixed a bug where new user groups weren’t getting set on user accounts in time for activation email templates to reference them. ([#6225](https://github.com/craftcms/cms/issues/6225))
- Fixed an error that occurred when adding multiple tags that began with the word “not”.
- Fixed a bug where it was possible to create two tags with the same title, but different casing. ([#6229](https://github.com/craftcms/cms/issues/6229))
- Fixed a bug where the `migrate/all` command would create a `migrations/` folder for no good reason. ([#6220](https://github.com/craftcms/cms/issues/6220))

## 3.4.24 - 2020-06-16

Expand Down
53 changes: 27 additions & 26 deletions src/console/controllers/MigrateController.php
Expand Up @@ -107,13 +107,12 @@ public function options($actionID)
ArrayHelper::removeValue($options, 'migrationNamespaces');
ArrayHelper::removeValue($options, 'compact');

// Global options
$options[] = 'type';
$options[] = 'plugin';

if ($actionID === 'all') {
$options[] = 'noBackup';
$options[] = 'noContent';
} else {
$options[] = 'type';
$options[] = 'plugin';
}

return $options;
Expand All @@ -137,33 +136,35 @@ public function optionAliases()
*/
public function beforeAction($action)
{
// Validate $type
if ($this->plugin) {
$this->type = MigrationManager::TYPE_PLUGIN;
}
if (!in_array($this->type, [MigrationManager::TYPE_APP, MigrationManager::TYPE_PLUGIN, MigrationManager::TYPE_CONTENT], true)) {
throw new Exception('Invalid migration type: ' . $this->type);
}
if ($this->type === MigrationManager::TYPE_PLUGIN) {
// Make sure $this->plugin in set to a valid plugin handle
if (empty($this->plugin)) {
$this->stderr('You must specify the plugin handle using the --plugin option.' . PHP_EOL, Console::FG_RED);
return false;
if ($action->id !== 'all') {
// Validate $type
if ($this->plugin) {
$this->type = MigrationManager::TYPE_PLUGIN;
}
$pluginsService = Craft::$app->getPlugins();
if (($plugin = $pluginsService->getPlugin($this->plugin)) === null) {
try {
$plugin = $pluginsService->createPlugin($this->plugin);
} catch (InvalidPluginException $e) {
$this->stderr('Invalid plugin handle: ' . $this->plugin . PHP_EOL, Console::FG_RED);
if (!in_array($this->type, [MigrationManager::TYPE_APP, MigrationManager::TYPE_PLUGIN, MigrationManager::TYPE_CONTENT], true)) {
throw new Exception('Invalid migration type: ' . $this->type);
}
if ($this->type === MigrationManager::TYPE_PLUGIN) {
// Make sure $this->plugin in set to a valid plugin handle
if (empty($this->plugin)) {
$this->stderr('You must specify the plugin handle using the --plugin option.' . PHP_EOL, Console::FG_RED);
return false;
}
$pluginsService = Craft::$app->getPlugins();
if (($plugin = $pluginsService->getPlugin($this->plugin)) === null) {
try {
$plugin = $pluginsService->createPlugin($this->plugin);
} catch (InvalidPluginException $e) {
$this->stderr('Invalid plugin handle: ' . $this->plugin . PHP_EOL, Console::FG_RED);
return false;
}
}
$this->plugin = $plugin;
}
$this->plugin = $plugin;
}

$this->migrationPath = $this->getMigrator()->migrationPath;
FileHelper::createDirectory($this->migrationPath);
$this->migrationPath = $this->getMigrator()->migrationPath;
FileHelper::createDirectory($this->migrationPath);
}

if (!parent::beforeAction($action)) {
return false;
Expand Down

0 comments on commit c608d49

Please sign in to comment.