-
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
Conversation
Yay, it works https://travis-ci.com/WordPress/gutenberg/jobs/183804711#L978-L978. Thanks @aduth and @pento for inspiration how to tackle it :) I will polish PR real quick and add missing description and docs. |
aae4823
to
55bf396
Compare
@@ -90,6 +90,24 @@ 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 comment
The 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 comment
The 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
Why don't we just enable them by default? |
e2e tests will fail, there are still React warnings coming from class methods which are marked as deprecated in the strict mode :( |
Maybe we can add an alternative command that includes these, in package.json? |
Just saying that when I'm setting up Gutenberg locally, I use it for development purposes. Sounds like we'd benefit from a less verbose setup command. |
Feel free to add some changes to this PR if you have some ideas. I just wanted to be able to use |
Is it reasonable to just override those temporarily for the end-to-end tests, to disable the script debug? |
I think it makes a lot of sense. It didn't occur to me before :) |
7a1992c
to
45b7fdf
Compare
I'm seeing the following on Travis:
I added a commit which removed the change for |
Hmmm, it's also being reported for
I plan to investigate whether we can set those constants inside Docker as explained in docker-library/wordpress#142. |
@@ -1,6 +1,8 @@ | |||
#!/usr/bin/env bash | |||
|
|||
WP_VERSION=${WP_VERSION-latest} | |||
WP_DEBUG=${WP_DEBUG-true} |
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:
Omitting the colon results in a test only for a parameter that is unset. Put another way, if the colon is included, the operator tests for both parameter’s existence and that its value is not null; if the colon is omitted, the operator tests only for existence.
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.
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.
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.
cb9b766
to
c34d3c0
Compare
It works with the latest changes applied. I think this is an improvement over what we had before so I would be happy if we could land it after some testing. |
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.
This all looks reasonable, but I'm struggling with the previously-noted error in my own environment.
Stopping / removing all existing containers, then running ./bin/setup-local-env.sh
, I see:
⇒ docker-compose down
⇒ ./bin/setup-local-env.sh
# ...
Error: The constant 'SCRIPT_DEBUG' is not defined in the 'wp-config.php' file.
Am I missing something, or can you think of some reason why the new environment values specified in docker-compose.yml
might not take effect in my environment (would others expect to encounter similar)?
@@ -1,6 +1,8 @@ | |||
#!/usr/bin/env bash | |||
|
|||
WP_VERSION=${WP_VERSION-latest} | |||
WP_DEBUG=${WP_DEBUG-true} |
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:
Omitting the colon results in a test only for a parameter that is unset. Put another way, if the colon is included, the operator tests for both parameter’s existence and that its value is not null; if the colon is omitted, the operator tests only for existence.
I expect it should be fine.
@@ -1,6 +1,8 @@ | |||
#!/usr/bin/env bash | |||
|
|||
WP_VERSION=${WP_VERSION-latest} | |||
WP_DEBUG=${WP_DEBUG-true} |
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.
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.
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)?
No idea to be honest. It looks similar to the error we had on Travis before c34d3c0 was added. I personally restarted Docker to test it locally. |
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.
While I'm not able to test it, I strongly suspect my issues are local, and I'd not want to be the reason for this being blocked. Otherwise, everything appears in good order here. I might offer it that another person test it, though am comfortable with it being merged if you're confident about it.
I will restart Docker and try locally again before I merge tomorrow, thanks for your review 💯 |
I tested locally after system restarted. Everything works as expected. |
I created a follow-up task at #14845 |
Thanks @aduth! |
Description
Replaces #12457 where it was expected to be able to update
SCRIPT_DEBUG
constant:Takes out part of #13452 where it is necessary to be able to set
WP_DEBUG
constant.This PR enables an option to make debugging WordPress easier with the existing Docker setup by providing env variables which reflect the same PHP constants used in WordPress:
WP_DEBUG
SCRIPT_DEBUG
See more at https://codex.wordpress.org/Debugging_in_WordPress.
Testing
To enable all available site constant variables run the following:
To disable all available site constant variables run the following: