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

Respect fields order in formatter output #5932

Closed
wants to merge 2 commits into from

Conversation

ernilambar
Copy link
Contributor

@ernilambar ernilambar commented Apr 15, 2024

Fixes #5941

Fields order like [ 'version', 'author', 'name' ] is respected in the output.

Example file.php:

<?php
      $custom_obj = [
        'name'    => 'Custom Name',
        'author'  => 'John Doe',
        'version' => '1.0'
      ];

      $assoc_args = [
        'format' => 'csv',
        'fields' => [ 'version', 'author', 'name' ],
      ];

      $formatter = new WP_CLI\Formatter( $assoc_args );
      $formatter->display_item( $custom_obj );

Command: wp eval-file file.php --skip-wordpress

Output:

version,1.0
author,"John Doe"
name,"Custom Name"

@ernilambar ernilambar marked this pull request as ready for review April 15, 2024 09:16
@ernilambar ernilambar requested a review from a team as a code owner April 15, 2024 09:16
@swissspidy
Copy link
Member

This is a potentially breaking change where e.g. tests need to be updated, so maybe similar to #5542 we should wait for 3.0.0 to merge this. WDYT?

@danielbachhuber
Copy link
Member

This is a potentially breaking change where e.g. tests need to be updated

To be more specific, a script reading the output of a command could have an implicit dependency on the current behavior (e.g. CSV columns in a particular order).

we should wait for 3.0.0 to merge this.

Let's do this. I moved #5941 to this repo and filed it against the 3.0 milestone for consideration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Order of fields is not respected in the output of plugin get command
3 participants