Skip to content

Conversation

tfirdaus
Copy link
Contributor

This Pull Request aims to fix issue #4958, where the inherited config using the inherit option is not properly merged when a command is run in nested directories. Currently, when running WP-CLI under sub-directories, like ./site/web/app/themes/mytheme/, it only reads configuration from the wp-cli.yml file and fails to merge the configs from ../wp-cli.local.yml.

For example, with the given directory structure:

.
├── wp-cli.local.yml
├── site
│   ├── wp-cli.yml
│   └── web
│       ├── app
│       │   ├── themes
│       │   ├── upgrade
│       │   └── uploads
│       └── wp
│           ├── wp-admin
│           ├── wp-content
│           └── wp-includes
└── trellis

And the configurations:

# wp-cli.local.yml
@dev:
  ssh: vagrant@example.test/srv/www/example.com/current
  path: web/wp
# wp-cli.yml
path: web/wp

_:
  inherit: ../wp-cli.local.yml
@otherdev:
  ssh: vagrant@otherexample.test/srv/www/otherexample.com/current

After applying the updates in this Pull Request, we expect the configuration from ../wp-cli.local.yml to be merged as well. So, when running WP-CLI under sub-directories, the same command would return:

@all: Run command against every registered alias.
@dev:
  path: web/wp
  ssh: vagrant@example.test/srv/www/example.com/current
@otherdev:
  ssh: vagrant@otherexample.test/srv/www/otherexample.com/current

@tfirdaus tfirdaus requested a review from a team as a code owner April 12, 2024 06:45
@tfirdaus tfirdaus marked this pull request as draft April 12, 2024 06:49
@tfirdaus tfirdaus marked this pull request as ready for review April 12, 2024 06:54
@tfirdaus
Copy link
Contributor Author

All "Functional - WP trunk on PHP 7.0 " tests are failed, due to WordPress 6.6 has just raised minimum support to PHP7.2.

@swissspidy
Copy link
Member

All "Functional - WP trunk on PHP 7.0 " tests are failed, due to WordPress 6.6 has just raised minimum support to PHP7.2.

Will be addressed by wp-cli/.github#99.

Have to defer reviewing this PR to others who know this code better than me.

Copy link
Member

@danielbachhuber danielbachhuber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your fix, @tfirdaus !

Merging this on Hack Day :) #5935

@swissspidy swissspidy merged commit bba57a7 into wp-cli:main Apr 26, 2024
@tfirdaus tfirdaus deleted the fix/4958-config-inheritance branch April 27, 2024 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants