entity-command
entity-command copied to clipboard
Missing argument with `option patch update` should throw error
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.
Should be moved to the entity-command. A candidate for good-first-issue ?
@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.
Any example with the correct command format ?
@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.