Replies: 2 comments
-
That's weird - the $ docker run --rm php -r 'var_dump(!!"");'
bool(false) vs: $ docker run --rm php -r 'var_dump(!!"false");'
bool(true) (we don't actually support setting that variable to the string "false" - the valid values are empty or non-empty) In other words, something weirder is going on here, and your database connection is somehow not working unless debug is enabled? 🤔 Are you sure you didn't make any other changes between the non-working deploy and the working one? Is it possible the database wasn't fully initialized yet? |
Beta Was this translation helpful? Give feedback.
-
As this first happened a few days ago and I got it working I have moved on and don't have the exact files I used anymore. I wrote a new minimal example to try to reproduce the error again but was not able to. Now everything works just as I expect both with compose and swarm on the same docker-compose file without defining WORDPRESS_DEBUG. This is what I did the first time and what led me to WORDPRESS_DEBUG. I ended up trying with something very similar to the docker-compose file below. After my tests today I have no idea what happened but at least I'm confident that it has nothing to do with WORDPRESS_DEBUG. You can close this case.
|
Beta Was this translation helpful? Give feedback.
-
In wp-config-docker.php WP_DEBUG is defined with:
define( 'WP_DEBUG', !!getenv_docker('WORDPRESS_DEBUG', '') );
if WORDPRESS_DEBUG is not defined in docker-compose.yml WP_DEBUG is set to the empty default value.
This is not a problem when using docker compose but when using docker stack deploy the result is the rather unhelpful message "Error establishing a database connection".
Explicitly setting WORDPRESS_DEBUG=false in docker-compose.yml solves this and both methods work as expected.
My suggestion is to change the definition of WP_DEBUG to explicitly set the default to false instead of empty:
define( 'WP_DEBUG', !!getenv_docker('WORDPRESS_DEBUG', false) );
or something similar should work.
Beta Was this translation helpful? Give feedback.
All reactions