From 25d62db7deaf8144389df9ebbfa8fb78f332b0a0 Mon Sep 17 00:00:00 2001 From: Grzegorz Ziolkowski Date: Mon, 11 Mar 2019 13:15:33 +0100 Subject: [PATCH 1/6] Add an option to configure site constants --- .travis.yml | 2 +- CONTRIBUTING.md | 5 +++++ bin/install-wordpress.sh | 18 ++++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 7b87e251a25258..1c08c709434090 100644 --- a/.travis.yml +++ b/.travis.yml @@ -65,7 +65,7 @@ jobs: - ./bin/run-wp-unit-tests.sh - name: E2E tests (Admin with plugins) (1/2) - env: WP_VERSION=latest POPULAR_PLUGINS=true + env: WP_VERSION=latest POPULAR_PLUGINS=true WP_DEBUG=true WP_DEBUG_DISPLAY=true SCRIPT_DEBUG=true install: - ./bin/setup-local-env.sh script: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 576e78b27a3eeb..b9a9b5b39ec815 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -79,6 +79,11 @@ Alternatively, you can use your own local WordPress environment and clone this r Next, open a terminal (or if on Windows, a command prompt) and navigate to the repository you cloned. Now type `npm install` to get the dependencies all set up. Then you can type `npm run dev` in your terminal or command prompt to keep the plugin building in the background as you work on it. +WordPress comes with specific [debug systems](https://codex.wordpress.org/Debugging_in_WordPress) designed to simplify the process as well as standardize code across the core, plugins and themes. It is possible to use environment variables (`WP_DEBUG`, `WP_DEBUG_DISPLAY` and `SCRIPT_DEBUG`) to update site's config constants located in `wp-config.php` file. They can be updated at any time by running the following command: +``` +SCRIPT_DEBUG=true WP_DEBUG=true WP_DEBUG_DISPLAY=true ./bin/setup-local-env.sh +``` + ### On A Remote Server Open a terminal (or if on Windows, a command prompt) and navigate to the repository you cloned. Now type `npm install` to get the dependencies all set up. Once that finishes, you can type `npm run build`. You can now upload the entire repository to your `wp-content/plugins` directory on your web server and activate the plugin from the WordPress admin. diff --git a/bin/install-wordpress.sh b/bin/install-wordpress.sh index 92cee6f514e90c..77c2591fdb4337 100755 --- a/bin/install-wordpress.sh +++ b/bin/install-wordpress.sh @@ -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...") +if [ ! -z "$WP_DEBUG" ]; 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 +if [ ! -z "$WP_DEBUG_DISPLAY" ]; then + docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm -u 33 $CLI config set WP_DEBUG_DISPLAY $WP_DEBUG_DISPLAY --raw --type=constant --quiet + WP_DEBUG_DISPLAY_RESULT=$(docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run -T --rm -u 33 $CLI config get --type=constant --format=json WP_DEBUG_DISPLAY) + echo -e $(status_message "WP_DEBUG_DISPLAY: $WP_DEBUG_DISPLAY_RESULT...") +fi +if [ ! -z "$SCRIPT_DEBUG" ]; 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 From f1678beb1800c57965bc225d891c3cb52116d2e1 Mon Sep 17 00:00:00 2001 From: Grzegorz Ziolkowski Date: Mon, 11 Mar 2019 15:19:26 +0100 Subject: [PATCH 2/6] Remove temporary override for one of the Travis jobs added for debugging purpose --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1c08c709434090..7b87e251a25258 100644 --- a/.travis.yml +++ b/.travis.yml @@ -65,7 +65,7 @@ jobs: - ./bin/run-wp-unit-tests.sh - name: E2E tests (Admin with plugins) (1/2) - env: WP_VERSION=latest POPULAR_PLUGINS=true WP_DEBUG=true WP_DEBUG_DISPLAY=true SCRIPT_DEBUG=true + env: WP_VERSION=latest POPULAR_PLUGINS=true install: - ./bin/setup-local-env.sh script: From 4e8f1141e136544015253e14dd20a986f0517014 Mon Sep 17 00:00:00 2001 From: Miguel Fonseca Date: Wed, 13 Mar 2019 15:43:02 +0000 Subject: [PATCH 3/6] Update CONTRIBUTING.md --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b9a9b5b39ec815..da1c2c8e655dd3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -79,7 +79,7 @@ Alternatively, you can use your own local WordPress environment and clone this r Next, open a terminal (or if on Windows, a command prompt) and navigate to the repository you cloned. Now type `npm install` to get the dependencies all set up. Then you can type `npm run dev` in your terminal or command prompt to keep the plugin building in the background as you work on it. -WordPress comes with specific [debug systems](https://codex.wordpress.org/Debugging_in_WordPress) designed to simplify the process as well as standardize code across the core, plugins and themes. It is possible to use environment variables (`WP_DEBUG`, `WP_DEBUG_DISPLAY` and `SCRIPT_DEBUG`) to update site's config constants located in `wp-config.php` file. They can be updated at any time by running the following command: +WordPress comes with specific [debug systems](https://codex.wordpress.org/Debugging_in_WordPress) designed to simplify the process as well as standardize code across core, plugins and themes. It is possible to use environment variables (`WP_DEBUG`, `WP_DEBUG_DISPLAY` and `SCRIPT_DEBUG`) to update a site's configuration constants located in `wp-config.php` file. They can be updated at any time by running the following command: ``` SCRIPT_DEBUG=true WP_DEBUG=true WP_DEBUG_DISPLAY=true ./bin/setup-local-env.sh ``` From 7ecc2ba7c95af5a2931061e75309071c92b90ccc Mon Sep 17 00:00:00 2001 From: Grzegorz Ziolkowski Date: Thu, 14 Mar 2019 16:18:04 +0100 Subject: [PATCH 4/6] Set all flags to true by default, disable on demand --- .travis.yml | 4 ++-- CONTRIBUTING.md | 5 +++-- bin/bootstrap-env.sh | 3 +++ bin/install-wordpress.sh | 9 ++++++--- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7b87e251a25258..0365f5855e8937 100644 --- a/.travis.yml +++ b/.travis.yml @@ -65,7 +65,7 @@ jobs: - ./bin/run-wp-unit-tests.sh - name: E2E tests (Admin with plugins) (1/2) - env: WP_VERSION=latest POPULAR_PLUGINS=true + env: WP_VERSION=latest SCRIPT_DEBUG=false POPULAR_PLUGINS=true install: - ./bin/setup-local-env.sh script: @@ -74,7 +74,7 @@ jobs: - npm run test-e2e -- --ci --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 2 == 0' < ~/.jest-e2e-tests ) - name: E2E tests (Admin with plugins) (2/2) - env: WP_VERSION=latest POPULAR_PLUGINS=true + env: WP_VERSION=latest SCRIPT_DEBUG=false POPULAR_PLUGINS=true install: - ./bin/setup-local-env.sh script: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index da1c2c8e655dd3..5cd10599b8087e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -79,10 +79,11 @@ Alternatively, you can use your own local WordPress environment and clone this r Next, open a terminal (or if on Windows, a command prompt) and navigate to the repository you cloned. Now type `npm install` to get the dependencies all set up. Then you can type `npm run dev` in your terminal or command prompt to keep the plugin building in the background as you work on it. -WordPress comes with specific [debug systems](https://codex.wordpress.org/Debugging_in_WordPress) designed to simplify the process as well as standardize code across core, plugins and themes. It is possible to use environment variables (`WP_DEBUG`, `WP_DEBUG_DISPLAY` and `SCRIPT_DEBUG`) to update a site's configuration constants located in `wp-config.php` file. They can be updated at any time by running the following command: +WordPress comes with specific [debug systems](https://codex.wordpress.org/Debugging_in_WordPress) designed to simplify the process as well as standardize code across core, plugins and themes. It is possible to use environment variables (`WP_DEBUG`, `WP_DEBUG_DISPLAY` and `SCRIPT_DEBUG`) to update a site's configuration constants located in `wp-config.php` file. Any of the flags can be disabled at any time by running the following command: ``` -SCRIPT_DEBUG=true WP_DEBUG=true WP_DEBUG_DISPLAY=true ./bin/setup-local-env.sh +SCRIPT_DEBUG=false WP_DEBUG=false WP_DEBUG_DISPLAY=false ./bin/setup-local-env.sh ``` +By default, all 3 flags will be set to `true`. ### On A Remote Server diff --git a/bin/bootstrap-env.sh b/bin/bootstrap-env.sh index 6b3b1c9d29aeeb..733b78557fe0eb 100755 --- a/bin/bootstrap-env.sh +++ b/bin/bootstrap-env.sh @@ -1,6 +1,9 @@ #!/usr/bin/env bash WP_VERSION=${WP_VERSION-latest} +WP_DEBUG=${WP_DEBUG-true} +WP_DEBUG_DISPLAY=${WP_DEBUG_DISPLAY-true} +SCRIPT_DEBUG=${SCRIPT_DEBUG-true} DOCKER=${DOCKER-false} DOCKER_ENV=${DOCKER_ENV-ci} DOCKER_COMPOSE_FILE_OPTIONS="-f docker-compose.yml" diff --git a/bin/install-wordpress.sh b/bin/install-wordpress.sh index 77c2591fdb4337..eaaf60672f0692 100755 --- a/bin/install-wordpress.sh +++ b/bin/install-wordpress.sh @@ -92,17 +92,20 @@ fi # Configure site constants. echo -e $(status_message "Configuring site constants...") -if [ ! -z "$WP_DEBUG" ]; then +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 -if [ ! -z "$WP_DEBUG_DISPLAY" ]; then +WP_DEBUG_DISPLAY_CURRENT=$(docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run -T --rm -u 33 $CLI config get --type=constant --format=json WP_DEBUG_DISPLAY) +if [ $WP_DEBUG_DISPLAY != $WP_DEBUG_DISPLAY_CURRENT ]; then docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm -u 33 $CLI config set WP_DEBUG_DISPLAY $WP_DEBUG_DISPLAY --raw --type=constant --quiet WP_DEBUG_DISPLAY_RESULT=$(docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run -T --rm -u 33 $CLI config get --type=constant --format=json WP_DEBUG_DISPLAY) echo -e $(status_message "WP_DEBUG_DISPLAY: $WP_DEBUG_DISPLAY_RESULT...") fi -if [ ! -z "$SCRIPT_DEBUG" ]; then +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...") From 5e4b14d10b3dfe43816e2daf312f000516aac3ee Mon Sep 17 00:00:00 2001 From: Grzegorz Ziolkowski Date: Thu, 14 Mar 2019 16:40:54 +0100 Subject: [PATCH 5/6] Remove WP_DEBUG_DISPLAY override --- CONTRIBUTING.md | 6 +++--- bin/bootstrap-env.sh | 1 - bin/install-wordpress.sh | 6 ------ 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5cd10599b8087e..d3f58b4c9e9b5b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -79,11 +79,11 @@ Alternatively, you can use your own local WordPress environment and clone this r Next, open a terminal (or if on Windows, a command prompt) and navigate to the repository you cloned. Now type `npm install` to get the dependencies all set up. Then you can type `npm run dev` in your terminal or command prompt to keep the plugin building in the background as you work on it. -WordPress comes with specific [debug systems](https://codex.wordpress.org/Debugging_in_WordPress) designed to simplify the process as well as standardize code across core, plugins and themes. It is possible to use environment variables (`WP_DEBUG`, `WP_DEBUG_DISPLAY` and `SCRIPT_DEBUG`) to update a site's configuration constants located in `wp-config.php` file. Any of the flags can be disabled at any time by running the following command: +WordPress comes with specific [debug systems](https://codex.wordpress.org/Debugging_in_WordPress) designed to simplify the process as well as standardize code across core, plugins and themes. It is possible to use environment variables (`WP_DEBUG` and `SCRIPT_DEBUG`) to update a site's configuration constants located in `wp-config.php` file. Both flags can be disabled at any time by running the following command: ``` -SCRIPT_DEBUG=false WP_DEBUG=false WP_DEBUG_DISPLAY=false ./bin/setup-local-env.sh +SCRIPT_DEBUG=false WP_DEBUG=false ./bin/setup-local-env.sh ``` -By default, all 3 flags will be set to `true`. +By default, both flags will be set to `true`. ### On A Remote Server diff --git a/bin/bootstrap-env.sh b/bin/bootstrap-env.sh index 733b78557fe0eb..3055a49b5138ec 100755 --- a/bin/bootstrap-env.sh +++ b/bin/bootstrap-env.sh @@ -2,7 +2,6 @@ WP_VERSION=${WP_VERSION-latest} WP_DEBUG=${WP_DEBUG-true} -WP_DEBUG_DISPLAY=${WP_DEBUG_DISPLAY-true} SCRIPT_DEBUG=${SCRIPT_DEBUG-true} DOCKER=${DOCKER-false} DOCKER_ENV=${DOCKER_ENV-ci} diff --git a/bin/install-wordpress.sh b/bin/install-wordpress.sh index eaaf60672f0692..1c7f19e4c2f7fd 100755 --- a/bin/install-wordpress.sh +++ b/bin/install-wordpress.sh @@ -98,12 +98,6 @@ if [ $WP_DEBUG != $WP_DEBUG_CURRENT ]; then 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 -WP_DEBUG_DISPLAY_CURRENT=$(docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run -T --rm -u 33 $CLI config get --type=constant --format=json WP_DEBUG_DISPLAY) -if [ $WP_DEBUG_DISPLAY != $WP_DEBUG_DISPLAY_CURRENT ]; then - docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm -u 33 $CLI config set WP_DEBUG_DISPLAY $WP_DEBUG_DISPLAY --raw --type=constant --quiet - WP_DEBUG_DISPLAY_RESULT=$(docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run -T --rm -u 33 $CLI config get --type=constant --format=json WP_DEBUG_DISPLAY) - echo -e $(status_message "WP_DEBUG_DISPLAY: $WP_DEBUG_DISPLAY_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 From c34d3c027aea9ddd06639bb5a4b7e9b38cc5ce7f Mon Sep 17 00:00:00 2001 From: Grzegorz Ziolkowski Date: Tue, 19 Mar 2019 09:20:01 +0100 Subject: [PATCH 6/6] Enable WP_DEBUG and SCRIPT_DEBUG --- .travis.yml | 4 ++-- docker-compose.yml | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0365f5855e8937..26b72a571f723d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -83,7 +83,7 @@ jobs: - npm run test-e2e -- --ci --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 2 == 1' < ~/.jest-e2e-tests ) - name: E2E tests (Author without plugins) (1/2) - env: WP_VERSION=latest E2E_ROLE=author + env: WP_VERSION=latest SCRIPT_DEBUG=false E2E_ROLE=author install: - ./bin/setup-local-env.sh script: @@ -92,7 +92,7 @@ jobs: - npm run test-e2e -- --ci --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 2 == 0' < ~/.jest-e2e-tests ) - name: E2E tests (Author without plugins) (2/2) - env: WP_VERSION=latest E2E_ROLE=author + env: WP_VERSION=latest SCRIPT_DEBUG=false E2E_ROLE=author install: - ./bin/setup-local-env.sh script: diff --git a/docker-compose.yml b/docker-compose.yml index 9a42742d389df5..7093c39a828237 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,6 +9,9 @@ services: environment: WORDPRESS_DB_PASSWORD: example ABSPATH: /usr/src/wordpress/ + WORDPRESS_DEBUG: 1 + WORDPRESS_CONFIG_EXTRA: | + define('SCRIPT_DEBUG', true ); volumes: - wordpress:/var/www/html - .:/var/www/html/wp-content/plugins/gutenberg @@ -56,6 +59,9 @@ services: WORDPRESS_DB_NAME: wordpress_e2e_tests WORDPRESS_DB_PASSWORD: example ABSPATH: /usr/src/wordpress/ + WORDPRESS_DEBUG: 1 + WORDPRESS_CONFIG_EXTRA: | + define('SCRIPT_DEBUG', true ); volumes: - wordpress_e2e_tests:/var/www/html - .:/var/www/html/wp-content/plugins/gutenberg