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

Can't use ambiguous arguments over SSH to set command-specific variables. #4206

Closed
paulgibbs opened this issue Jul 8, 2017 · 1 comment · Fixed by #4207
Closed

Can't use ambiguous arguments over SSH to set command-specific variables. #4206

paulgibbs opened this issue Jul 8, 2017 · 1 comment · Fixed by #4207

Comments

@paulgibbs
Copy link

While using CLI-over-SSH, it is not possible to use ambiguous arguments to set local, command-specific values, even when using WP_CLI_STRICT_ARGS_MODE=1.

For example, I want to add a RSS widget to a sidebar. In this case, the ambiguous --url parameter relates to the url property of the widget (i.e. the feed URL).

Steps to reproduce

  1. Have a VM, with a working WordPress site and WP-CLI.
  2. Outside the VM, in a project directory, have a wp-cli.yml containing this: https://gist.github.com/paulgibbs/028279cf5c1dbb5882c27a36f2e80598 (You will need to change the details to match your VM). Verify you can run WP-CLI commands within the VM via wp @vagrant ... (etc).
  3. Outside the VM, run: wp @vagrant widget add rss sidebar-1 --title='My feedx' --url='https://wordpress.org/news/feed/' --items='3'. Check the website and confirm that a new widget was added. Note the URL property on the widget will be empty.
  4. Manually remove the widget to tidy-up.
  5. Outside the VM, to (try to) resolve the command ambiguity, run: WP_CLI_STRICT_ARGS_MODE=1 wp @vagrant widget add rss sidebar-1 --title='My feedx' --url='https://wordpress.org/news/feed/' --items='3'. Check the website and confirm that a new widget was added. Note the URL property on the widget will still be empty.

Expected Results

Running this command over SSH with WP_CLI_STRICT_ARGS_MODE=1 set should create the widget with its URL property correctly populated.

Actual Results

The widget is created but its URL property is empty.

Workaround

None known. This issue is reported using the RSS widget, but I suspect the same issue will occur with other commands that rely on ambiguous arguments.

My suspicion is that when CLI makes the SSH connection to the specified server, it is not passing the value of WP_CLI_STRICT_ARGS_MODE if set, but I have not investigated this.

I have included other information that may be useful to debug, here: https://gist.github.com/paulgibbs/a90e68501cd7e735aef08a5a32945c76

@gitlost gitlost added the bug label Jul 8, 2017
@gitlost
Copy link
Contributor

gitlost commented Jul 8, 2017

Thanks @paulgibbs, your suspicion

it is not passing the value of WP_CLI_STRICT_ARGS_MODE if set

is correct! You could try as a workaround

WP_CLI_SSH_PRE_CMD='export WP_CLI_STRICT_ARGS_MODE=1' wp...

@danielbachhuber danielbachhuber added this to the 1.3.0 milestone Jul 10, 2017
paulgibbs added a commit to paulgibbs/behat-wordpress-extension that referenced this issue Aug 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants