entity-command icon indicating copy to clipboard operation
entity-command copied to clipboard

Missing argument with `option patch update` should throw error

Open Diego-Schmidt opened this issue 3 years ago • 2 comments

Hello, I'm having problems using this commands to disable and enable the maintenance mode of a subsite. If the maintenance mode is enabled and i send the command to disable it the result is: wp --url=subsite.multisite.com --allow-root option patch update seedprod_settings '{"enable_maintenance_mode":"false"}' --format=json Success: Updated 'seedprod_settings' option.

If i send the command to enable the maintenance mode again the result is: wp --url=subsite.multisite.com --allow-root option patch update seedprod_settings '{"enable_maintenance_mode":"true"}' --format=json PHP Warning: json_decode() expects parameter 1 to be string, array given in /home/multisite.com/public_html/wp-content/plugins/coming-soon/app/render-csp-mm.php on line 36 array ( 'enable_maintenance_mode' => 'true', )

And the seedprod_settings object settings dissapear from the subsite options. Any idea what can be happening here? Thanks in advance for the support.

Diego-Schmidt avatar Jan 29 '22 03:01 Diego-Schmidt

Should be moved to the entity-command. A candidate for good-first-issue ?

janw-me avatar May 29 '22 19:05 janw-me

@Diego-Schmidt This seems to be a misuse of the option patch command.

When using option patch update, you need to provide a key (the option to patch), a key-path (which sub-option to actually update), and finally the value to use for patching the key-path in the key option.

You're passing the value as the key-path, so the command is not expected to work like that.

However, there seems to be a bug here that the command even accepts this bad input without throwing an immediate error telling you that there is one argument missing. This needs to be fixed.

schlessera avatar May 30 '22 11:05 schlessera

Any example with the correct command format ?

Diego-Schmidt avatar Sep 17 '22 01:09 Diego-Schmidt

@Diego-Schmidt It would be something like this:

wp option patch update <key> <key-path>... [<value>]

Feel free to drop by #cli on WordPress.org Slack if you'd like help with your particular use case.

danielbachhuber avatar Sep 19 '22 11:09 danielbachhuber