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

Correcting the vm command invocation. #2979

Merged
merged 2 commits into from
Aug 3, 2018
Merged

Correcting the vm command invocation. #2979

merged 2 commits into from
Aug 3, 2018

Conversation

ba66e77
Copy link
Contributor

@ba66e77 ba66e77 commented Jul 29, 2018

Changes proposed:

  • Change the invocation of vm command to pass array of associative array items.

When building the VM through the wizard command, I was seeing the following warning returned:

PHP Warning: Illegal string offset 'no-boot' in /Users/barrett.smith/Desktop/blt/src/Robo/Commands/Vm/VmCommand.php on line 81

The invocation of the vm command by the wizard is using invokeCommand and passing a single array of ['--yes'] rather than a an array containing an array of options like the vm command expects.

@ba66e77 ba66e77 added Bug Something isn't working 9.1.x labels Jul 29, 2018
$this->invokeCommand('vm', ['--yes']);
$this->invokeCommand('vm', [
[
'no-boot' => '--yes',
Copy link
Contributor

Choose a reason for hiding this comment

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

I've never passed arguments to invokeCommand before, but it seems like you would want to do it like this, no?

$this->invokeCommand('vm', [
  [
    'no-boot',
    'yes',
  ],
]);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That would end up with the vm method getting an array with two numerically indexed values, but it expects an associative array with one value where the key is 'no-boot'.

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess that makes sense as such. But if no-boot requires a value, wouldn't it be TRUE or something? Why --yes?

I get why you'd want no-boot and --yes as separate options, I guess I just don't understand how there's a key->value relationship between them.

Copy link
Contributor Author

@ba66e77 ba66e77 Jul 31, 2018

Choose a reason for hiding this comment

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

/shrug I made the change that allowed minimal modification to make the thing work as expected. I can't speak to the initial rational for why it was written as it is.

But what we have is a method that expects a $options parameter and checks the value of the 'no-boot' key within that $options array

public function vm($options = ['no-boot' => FALSE]) {
    ...blah, blah, blah...
    if (!$options['no-boot'] && !$this->getInspector()->isDrupalVmBooted()) {
      return $this->boot();
    }
  }

I'm not averse to refactoring it to take inputs differently but it isn't currently so janky that it offends, so I'm inclined to put refactoring it in the 'someday' column and deal with bigger issues first.

@ba66e77 ba66e77 merged commit a1fd885 into acquia:9.x Aug 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants