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

Fix baking snapshots #89

Merged
merged 5 commits into from
May 29, 2015
Merged

Conversation

HavokInspiration
Copy link
Member

After a snapshot was baked, the connection and the plugin options should be propagated to the mark_migrated dispatched Shell.
Not doing so resulted in the mark_migrated call to be executed with the default connection which was unexpected and caused problems.

I know the tests and the mark_migrated shell dispatching seems weird but I actually can put anything in place of the $dispatchCommand and it would work. What matters is the content of the $_SERVER['argv'] variable (if anyone knows why and would care to explain, I'll be glad).
But I still need to build a correct string for the tests.

Should fix #88


if (!empty($this->params['plugin'])) {
$_SERVER['argv'][] = '-p';
$_SERVER['argv'][] = $this->params['plugin'];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really wish phinx had a less gross way of integrating sub commands.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah me too.
I looked it up a bit and it is currently the only way I found.
I'll give it another shot just in case.

Edit : on second thoughts, we are in a "bake context". phinx might not be the problem here. Anyway, I'll investigate this.

@HavokInspiration
Copy link
Member Author

@markstory I found a way to prevent the dirty stuff when dispatching the Shell.

I think that in a more general way, dispatching a migrations shell currently does not work.
I found out that the way the Symfony console package is built, it uses the original command as input arguments. Which means that when doing bin/cake bake migration_snapshot initial, the dispatched command is not the one the component auto-parses ; instead it is bake migration_snapshot initial that is used.
This is why I have to manually built it and pass it to the MigrationsDispatcher::run() method on each call.

$app->run();

$input = new ArgvInput($this->argv);
$app->run($input);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need to modify $_SERVER['argv'] now that you're passing ArgvInput?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, probably not.
I'll remove it and see.

@markstory
Copy link
Member

Looks great 👍

@HavokInspiration
Copy link
Member Author

@markstory You were right :)

markstory added a commit that referenced this pull request May 29, 2015
@markstory markstory merged commit b5758f5 into cakephp:master May 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bake migration_snapshot not working with --connection option anymore?
2 participants