You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[ wp core check-update ] - format options parameter #250
Steps to reproduce:
Run command ‘wp core check-update --format=json’
` /**
* Checks for WordPress updates via Version Check API.
*
* Lists the most recent versions when there are updates available,
* or success message when up to date.
*
* ## OPTIONS
*
* [--minor]
* : Compare only the first two parts of the version number.
*
* [--major]
* : Compare only the first part of the version number.
*
* [--force-check]
* : Bypass the transient cache and force a fresh update check.
*
* [--field=]
* : Prints the value of a single field for each update.
*
* [--fields=]
* : Limit the output to specific object fields. Defaults to version,update_type,package_url.
*
* [--format=]
* : Render output in a particular format.
* ---
* default: table
* options:
* - table
* - csv
* - count
* - json
* - yaml
* ---
*
* ## EXAMPLES
*
* $ wp core check-update
* +---------+-------------+-------------------------------------------------------------+
* | version | update_type | package_url |
* +---------+-------------+-------------------------------------------------------------+
* | 4.5.2 | major | https://downloads.wordpress.org/release/wordpress-4.5.2.zip |
* +---------+-------------+-------------------------------------------------------------+
*
* @subcommand check-update
*/
public function check_update( $_, $assoc_args ) {
Yes, my suggestion was definitely to return the message via json. In any case, the empty array is still sufficient to verify that we have received the response.
I am currently writing a set of tests and update routines via ssh using the cli.
Ok, makes sense. I think I'd be fine to change wp core check-update --format=json to return an empty array, and consider this a bug in the original implementation.
Activity
danielbachhuber commentedon Feb 25, 2024
Thanks for the report, @riccardodicurti
I believe
wp core check-update --format=jsonreturns an empty result because there are no updates available.What is your expected behavior?
riccardodicurti commentedon Feb 25, 2024
Ciao @danielbachhuber
I would at least expect an empty json or a message telling me that no updates are available.
danielbachhuber commentedon Feb 25, 2024
I'm not sure a message would make sense. If you're passing the data into JSON parser, a string would break the parser.
wp post list --format=jsonproduces an empty array:Would an empty array work for your purposes?
Also, for posterity, could you share a bit more detail about your use case?
riccardodicurti commentedon Feb 26, 2024
Yes, my suggestion was definitely to return the message via json. In any case, the empty array is still sufficient to verify that we have received the response.
I am currently writing a set of tests and update routines via ssh using the cli.
danielbachhuber commentedon Feb 26, 2024
Ok, makes sense. I think I'd be fine to change
wp core check-update --format=jsonto return an empty array, and consider this a bug in the original implementation.