Skip to content

Conversation

@ernilambar
Copy link
Member

@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.

@ernilambar ernilambar mentioned this pull request Jun 14, 2024
@swissspidy swissspidy reopened this Dec 2, 2025
@swissspidy swissspidy added this to the 3.0.0 milestone Dec 2, 2025
@codecov
Copy link

codecov bot commented Dec 2, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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