You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This pull request addresses the bug where using wp config delete to remove a constant from wp-config.php that includes concatenated functions or complex strings results in the incorrect deletion of more than just the targeted constant.
Current Behavior
Currently, when deleting a constant that includes concatenated functions or special characters, the regex used in the deletion function does not properly isolate the constant. This results in deleting additional lines or even other constants. For example:
Running wp config delete USER_PATH would improperly affect adjacent lines.
Steps to Replicate
Have a wp-config.php file with a constant definition concatenating a function.
Run wp config delete USER_PATH.
Expected Outcome
Only the line defining USER_PATH should be removed, leaving all other settings and definitions intact.
Issue Details
The issue stemmed from the regex pattern used in the removal function, which failed to correctly identify the boundaries of the constant definition when it involved concatenated functions or complex string values.
Proposed Solution
This PR introduces a revised regex pattern that more accurately matches and isolates define statements, even when they contain complex string values or are among multiple statements on a single line. The new regex handles variations in whitespace and formatting, ensuring that only the specific constant is removed.
@ernilambar I've implemented a new test to ensure the safe removal of constants that have concatenated strings as their values. This test specifically checks that only the targeted constant is removed, and that no additional lines or constants are inadvertently affected during the process.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #50
Fixes wp-cli/config-command#101
This pull request addresses the bug where using
wp config delete
to remove a constant fromwp-config.php
that includes concatenated functions or complex strings results in the incorrect deletion of more than just the targeted constant.Current Behavior
Currently, when deleting a constant that includes concatenated functions or special characters, the regex used in the deletion function does not properly isolate the constant. This results in deleting additional lines or even other constants. For example:
Running
wp config delete USER_PATH
would improperly affect adjacent lines.Steps to Replicate
wp-config.php
file with a constant definition concatenating a function.wp config delete USER_PATH
.Expected Outcome
Only the line defining
USER_PATH
should be removed, leaving all other settings and definitions intact.Issue Details
The issue stemmed from the regex pattern used in the removal function, which failed to correctly identify the boundaries of the constant definition when it involved concatenated functions or complex string values.
Proposed Solution
This PR introduces a revised regex pattern that more accurately matches and isolates
define
statements, even when they contain complex string values or are among multiple statements on a single line. The new regex handles variations in whitespace and formatting, ensuring that only the specific constant is removed.