Skip to content

fix: Use valid code to trick WP-CLI 2.12+#141

Merged
gmazzap merged 1 commit intowecodemore:devfrom
nlemoine:fix-wp-cli-2-12
May 12, 2025
Merged

fix: Use valid code to trick WP-CLI 2.12+#141
gmazzap merged 1 commit intowecodemore:devfrom
nlemoine:fix-wp-cli-2-12

Conversation

@nlemoine
Copy link
Copy Markdown
Contributor

@nlemoine nlemoine commented May 12, 2025

Description

The latest WP-CLI version isn't tricked so easily anymore by singing "ob-la-di, ob-la-da life goes on, brah" 🙂

/*
WP CLI uses regexp to parse the expected wp-config.php, then it eval the code in it, skipping
one line that requires WP settings file.
We are going to cheat WP CLI while singing "ob-la-di, ob-la-da life goes on, brah".
Desmond takes a trolley to the jeweler's store
Buys a 20-carat golden ring (ring)
Takes it back to Molly waiting at the door
And as he gives it to her, she begins to sing (sing)
Ob-la-di, ob-la-da (la, la, la, la, la, la)
Life goes on, brah (la, la, la, la, la, la)
La, la, how the life goes on.
require wp-settings.php
*/

It now triggers an error:

Error: Strange wp-config.php file: wp-settings.php is not loaded directly.

See the relevant PR:s

The checks against require wp-settings.php have been enforced so its now needs to actual valid code.

How has this been tested?

Locally using WP-CLI 2.12.

Types of changes

A tiny change in wp-config PHP comment.

Bug fixes (non-breaking change which fixes an issue)

  • Fixes WP-CLI 2.12 compatibility

Checklist:

  • My code is tested
  • My code follows the project code style
  • My code has documentation (for new features or changed behavior)

From 2.12, WP-CLI uses a more accurate regex to check that `wp-settings.php` has been required.

See:
- wp-cli/wp-cli#6039
- wp-cli/wp-cli#6042
nlemoine added a commit to Humanoidfr/wpstarter that referenced this pull request May 12, 2025
@gmazzap
Copy link
Copy Markdown
Member

gmazzap commented May 12, 2025

Thanks!

@gmazzap gmazzap merged commit 803c35f into wecodemore:dev May 12, 2025
@nlemoine nlemoine deleted the fix-wp-cli-2-12 branch May 12, 2025 13:59
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.

2 participants