Skip to content

wp ability list --format=ids prints "Array" for each ability #15

Open

Description

@softglazee

Bug Report

Describe the current, buggy behavior

wp ability list lists ids as an accepted value for --format. With --format=ids the command prints Array once per ability, and one PHP warning per ability on STDERR. The exit code is 0.

This happens on any WordPress 6.9+ site with only the core abilities registered:

$ wp ability list --format=ids
Array Array Array Array Array Array

STDERR of the same command:

Warning: Array to string conversion in phar:///tmp/wp.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Formatter.php on line 384
Warning: Array to string conversion in phar:///tmp/wp.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Formatter.php on line 384
Warning: Array to string conversion in phar:///tmp/wp.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Formatter.php on line 384
Warning: Array to string conversion in phar:///tmp/wp.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Formatter.php on line 384
Warning: Array to string conversion in phar:///tmp/wp.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Formatter.php on line 384
Warning: Array to string conversion in phar:///tmp/wp.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Formatter.php on line 384

The ids format of the formatter runs implode( ' ', $items ), so it expects plain values. list_() passes the full ability rows.

Describe how other contributors can replicate this bug

  • Use WordPress 6.9 or later (I used 7.2-beta1-64691).
  • wp ability list --field=name shows the six core abilities.
  • wp ability list --format=ids prints Array Array Array Array Array Array and six "Array to string conversion" warnings.

Describe what you would expect as the correct outcome

The ability names, separated by spaces, and nothing on STDERR. This is what wp cron event list --format=ids does with the hook names:

$ wp ability list --format=ids
core/get-site-info core/get-user-info core/get-environment-info core/settings-get core/users-query core/content-query

Let us know what environment you are running this on

OS:	Linux 6.18.33.2-microsoft-standard-WSL2 #1 SMP PREEMPT_DYNAMIC Thu Jun 18 21:54:43 UTC 2026 x86_64
Shell:	
PHP binary:	/usr/local/bin/php
PHP version:	8.5.9
PHP memory limit:	-1
php.ini used:	/usr/local/etc/php/php-cli.ini
MySQL binary:	/usr/bin/mariadb
MySQL version:	mariadb from 11.8.9-MariaDB, client 15.2 for Linux (x86_64) using readline 5.1
SQL modes:	
WP-CLI root dir:	phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir:	phar://wp-cli.phar/vendor
WP_CLI phar path:	phar:///tmp/wp.phar
WP-CLI packages dir:	/tmp/.wp-cli/packages/
WP-CLI cache dir:	/tmp/.wp-cli/cache
WP-CLI global config:	
WP-CLI project config:	
WP-CLI version:	3.0.0-alpha-836ccac

WordPress 7.2-beta1-64691 (nightly), WP_DEBUG true. The only active plugin is WordPress Importer 0.9.7, which registers no abilities. I also reproduced it with a Behat step on the ability-command main branch (7a6437b).

Provide a possible solution

When the format is ids, pass wp_list_pluck( $items, 'name' ) to the formatter. wp cron event list and wp cron schedule list do the same with the hook and schedule names. I have a pull request with this change and a Behat step ready.

Provide additional context/Screenshots

  • wp ability category list does not offer ids, so it is not affected.
  • The current Behat tests do not use --format=ids for wp ability list.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcommand:ability-listRelated to 'ability list' commandstatus:unconfirmedIssue was could not be confirmed yet

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions