forumone / wp-cfm

Manage and deploy WordPress configuration changes
http://wordpress.org/plugins/wp-cfm/
195 stars 38 forks source link

`wp config diff` fails when diff is set to display as YAML and differences exist #139

Open thunderdw opened 1 year ago

thunderdw commented 1 year ago

The command is running fine when the file and database are identical. The below pertains to when they aren't.

What's happening

Command wp config diff all

Expectation Output that details the differences in my bundles.

What happens No output.

Why

By default, WP-CFM displays diffs as YAML (assuming a modern PHP version) on both the WordPress admin and the CLI. This works great on the frontend.

The function used to convert the config to YAML (WPCFM_Readwrite->compare_bundle()) returns the bundles as YAML strings instead of arrays when YAML mode is enabled. But the WP-CLI command is expecting the bundles to be arrays, not strings, so none of the conditionals in the command are met and no output occurs. https://github.com/forumone/wp-cfm/blob/e6fd2c7e14041a9c0d79d850f31d25d593cafae4/includes/class-wp-cli.php#L81-L111