-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add an option to configure site constants #14371
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
25d62db
Add an option to configure site constants
gziolo f1678be
Remove temporary override for one of the Travis jobs added for debugg…
gziolo 4e8f114
Update CONTRIBUTING.md
mcsf 7ecc2ba
Set all flags to true by default, disable on demand
gziolo 5e4b14d
Remove WP_DEBUG_DISPLAY override
gziolo c34d3c0
Enable WP_DEBUG and SCRIPT_DEBUG
gziolo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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 file contains 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 file contains 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 file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,6 +90,21 @@ if [ "$CURRENT_URL" != "http://localhost:$HOST_PORT" ]; then | |
docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm -u 33 $CLI option update siteurl "http://localhost:$HOST_PORT" --quiet | ||
fi | ||
|
||
# Configure site constants. | ||
echo -e $(status_message "Configuring site constants...") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a lot of code duplication here. Commits which simplify it are warmly welcomed :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could use macro-like behaviour with the following: $ A=hello; B=salut
$ VAR=A; eval echo \$$VAR
hello
$ VAR=B; eval echo \$$VAR
salut |
||
WP_DEBUG_CURRENT=$(docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run -T --rm -u 33 $CLI config get --type=constant --format=json WP_DEBUG) | ||
if [ $WP_DEBUG != $WP_DEBUG_CURRENT ]; then | ||
docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm -u 33 $CLI config set WP_DEBUG $WP_DEBUG --raw --type=constant --quiet | ||
WP_DEBUG_RESULT=$(docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run -T --rm -u 33 $CLI config get --type=constant --format=json WP_DEBUG) | ||
echo -e $(status_message "WP_DEBUG: $WP_DEBUG_RESULT...") | ||
fi | ||
SCRIPT_DEBUG_CURRENT=$(docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run -T --rm -u 33 $CLI config get --type=constant --format=json SCRIPT_DEBUG) | ||
if [ $SCRIPT_DEBUG != $SCRIPT_DEBUG_CURRENT ]; then | ||
docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm -u 33 $CLI config set SCRIPT_DEBUG $SCRIPT_DEBUG --raw --type=constant --quiet | ||
SCRIPT_DEBUG_RESULT=$(docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run -T --rm -u 33 $CLI config get --type=constant --format=json SCRIPT_DEBUG) | ||
echo -e $(status_message "SCRIPT_DEBUG: $SCRIPT_DEBUG_RESULT...") | ||
fi | ||
|
||
# Activate Gutenberg. | ||
echo -e $(status_message "Activating Gutenberg...") | ||
docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm -u 33 $CLI plugin activate gutenberg --quiet | ||
|
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possible thought on the error: Is this the correct syntax for assigning the default? Is the colon
:
not required?See:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also a bit curious why we don't use a
.env
file: https://docs.docker.com/compose/env-file/There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I followed other occurrences in the file. I think it works correctly, although I personally don't know which syntax would be preferred.
The issue was caused by the fact that PHP didn't have those constants defined and WP CLI's implementation is limited to updating existing constants ... c34d3c0 fixes it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, re-reading the above document, the colon behavior is explained:
I expect it should be fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, to clarify, despite the fact that in c34d3c0 you're hard-coding the constants,
bin/install-wordpress.sh
will subsequently update them according to the value of the environment variable? And it has to be hard-coded because otherwise WP-CLI will refuse to update them (as they don't otherwise exist in the file)?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is complex to explain but correct. Each constant needs to be defined in
wp-config.php
if we want to be able to update it with WP-CLI.