Skip to content

Commit 668fe24

Browse files
authored
Merge pull request #342 from infosiftr/WORDPRESS_CONFIG_EXTRA-warning
Add a warning for cases where WORDPRESS_CONFIG_EXTRA will not take effect
2 parents f716ece + 913115b commit 668fe24

13 files changed

+91
-0
lines changed

docker-entrypoint.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,13 @@ if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROT
152152
153153
EOPHP
154154
chown "$user:$group" wp-config.php
155+
elif [ -e wp-config.php ] && [ -n "$WORDPRESS_CONFIG_EXTRA" ] && [[ "$(< wp-config.php)" != *"$WORDPRESS_CONFIG_EXTRA"* ]]; then
156+
# (if the config file already contains the requested PHP code, don't print a warning)
157+
echo >&2
158+
echo >&2 'WARNING: environment variable "WORDPRESS_CONFIG_EXTRA" is set, but "wp-config.php" already exists'
159+
echo >&2 ' The contents of this variable will _not_ be inserted into the existing "wp-config.php" file.'
160+
echo >&2 ' (see https://github.com/docker-library/wordpress/issues/333 for more details)'
161+
echo >&2
155162
fi
156163

157164
# see http://stackoverflow.com/a/2705678/433558

php5.6/apache/docker-entrypoint.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,13 @@ if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROT
152152
153153
EOPHP
154154
chown "$user:$group" wp-config.php
155+
elif [ -e wp-config.php ] && [ -n "$WORDPRESS_CONFIG_EXTRA" ] && [[ "$(< wp-config.php)" != *"$WORDPRESS_CONFIG_EXTRA"* ]]; then
156+
# (if the config file already contains the requested PHP code, don't print a warning)
157+
echo >&2
158+
echo >&2 'WARNING: environment variable "WORDPRESS_CONFIG_EXTRA" is set, but "wp-config.php" already exists'
159+
echo >&2 ' The contents of this variable will _not_ be inserted into the existing "wp-config.php" file.'
160+
echo >&2 ' (see https://github.com/docker-library/wordpress/issues/333 for more details)'
161+
echo >&2
155162
fi
156163

157164
# see http://stackoverflow.com/a/2705678/433558

php5.6/fpm-alpine/docker-entrypoint.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,13 @@ if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROT
152152
153153
EOPHP
154154
chown "$user:$group" wp-config.php
155+
elif [ -e wp-config.php ] && [ -n "$WORDPRESS_CONFIG_EXTRA" ] && [[ "$(< wp-config.php)" != *"$WORDPRESS_CONFIG_EXTRA"* ]]; then
156+
# (if the config file already contains the requested PHP code, don't print a warning)
157+
echo >&2
158+
echo >&2 'WARNING: environment variable "WORDPRESS_CONFIG_EXTRA" is set, but "wp-config.php" already exists'
159+
echo >&2 ' The contents of this variable will _not_ be inserted into the existing "wp-config.php" file.'
160+
echo >&2 ' (see https://github.com/docker-library/wordpress/issues/333 for more details)'
161+
echo >&2
155162
fi
156163

157164
# see http://stackoverflow.com/a/2705678/433558

php5.6/fpm/docker-entrypoint.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,13 @@ if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROT
152152
153153
EOPHP
154154
chown "$user:$group" wp-config.php
155+
elif [ -e wp-config.php ] && [ -n "$WORDPRESS_CONFIG_EXTRA" ] && [[ "$(< wp-config.php)" != *"$WORDPRESS_CONFIG_EXTRA"* ]]; then
156+
# (if the config file already contains the requested PHP code, don't print a warning)
157+
echo >&2
158+
echo >&2 'WARNING: environment variable "WORDPRESS_CONFIG_EXTRA" is set, but "wp-config.php" already exists'
159+
echo >&2 ' The contents of this variable will _not_ be inserted into the existing "wp-config.php" file.'
160+
echo >&2 ' (see https://github.com/docker-library/wordpress/issues/333 for more details)'
161+
echo >&2
155162
fi
156163

157164
# see http://stackoverflow.com/a/2705678/433558

php7.0/apache/docker-entrypoint.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,13 @@ if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROT
152152
153153
EOPHP
154154
chown "$user:$group" wp-config.php
155+
elif [ -e wp-config.php ] && [ -n "$WORDPRESS_CONFIG_EXTRA" ] && [[ "$(< wp-config.php)" != *"$WORDPRESS_CONFIG_EXTRA"* ]]; then
156+
# (if the config file already contains the requested PHP code, don't print a warning)
157+
echo >&2
158+
echo >&2 'WARNING: environment variable "WORDPRESS_CONFIG_EXTRA" is set, but "wp-config.php" already exists'
159+
echo >&2 ' The contents of this variable will _not_ be inserted into the existing "wp-config.php" file.'
160+
echo >&2 ' (see https://github.com/docker-library/wordpress/issues/333 for more details)'
161+
echo >&2
155162
fi
156163

157164
# see http://stackoverflow.com/a/2705678/433558

php7.0/fpm-alpine/docker-entrypoint.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,13 @@ if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROT
152152
153153
EOPHP
154154
chown "$user:$group" wp-config.php
155+
elif [ -e wp-config.php ] && [ -n "$WORDPRESS_CONFIG_EXTRA" ] && [[ "$(< wp-config.php)" != *"$WORDPRESS_CONFIG_EXTRA"* ]]; then
156+
# (if the config file already contains the requested PHP code, don't print a warning)
157+
echo >&2
158+
echo >&2 'WARNING: environment variable "WORDPRESS_CONFIG_EXTRA" is set, but "wp-config.php" already exists'
159+
echo >&2 ' The contents of this variable will _not_ be inserted into the existing "wp-config.php" file.'
160+
echo >&2 ' (see https://github.com/docker-library/wordpress/issues/333 for more details)'
161+
echo >&2
155162
fi
156163

157164
# see http://stackoverflow.com/a/2705678/433558

php7.0/fpm/docker-entrypoint.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,13 @@ if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROT
152152
153153
EOPHP
154154
chown "$user:$group" wp-config.php
155+
elif [ -e wp-config.php ] && [ -n "$WORDPRESS_CONFIG_EXTRA" ] && [[ "$(< wp-config.php)" != *"$WORDPRESS_CONFIG_EXTRA"* ]]; then
156+
# (if the config file already contains the requested PHP code, don't print a warning)
157+
echo >&2
158+
echo >&2 'WARNING: environment variable "WORDPRESS_CONFIG_EXTRA" is set, but "wp-config.php" already exists'
159+
echo >&2 ' The contents of this variable will _not_ be inserted into the existing "wp-config.php" file.'
160+
echo >&2 ' (see https://github.com/docker-library/wordpress/issues/333 for more details)'
161+
echo >&2
155162
fi
156163

157164
# see http://stackoverflow.com/a/2705678/433558

php7.1/apache/docker-entrypoint.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,13 @@ if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROT
152152
153153
EOPHP
154154
chown "$user:$group" wp-config.php
155+
elif [ -e wp-config.php ] && [ -n "$WORDPRESS_CONFIG_EXTRA" ] && [[ "$(< wp-config.php)" != *"$WORDPRESS_CONFIG_EXTRA"* ]]; then
156+
# (if the config file already contains the requested PHP code, don't print a warning)
157+
echo >&2
158+
echo >&2 'WARNING: environment variable "WORDPRESS_CONFIG_EXTRA" is set, but "wp-config.php" already exists'
159+
echo >&2 ' The contents of this variable will _not_ be inserted into the existing "wp-config.php" file.'
160+
echo >&2 ' (see https://github.com/docker-library/wordpress/issues/333 for more details)'
161+
echo >&2
155162
fi
156163

157164
# see http://stackoverflow.com/a/2705678/433558

php7.1/fpm-alpine/docker-entrypoint.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,13 @@ if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROT
152152
153153
EOPHP
154154
chown "$user:$group" wp-config.php
155+
elif [ -e wp-config.php ] && [ -n "$WORDPRESS_CONFIG_EXTRA" ] && [[ "$(< wp-config.php)" != *"$WORDPRESS_CONFIG_EXTRA"* ]]; then
156+
# (if the config file already contains the requested PHP code, don't print a warning)
157+
echo >&2
158+
echo >&2 'WARNING: environment variable "WORDPRESS_CONFIG_EXTRA" is set, but "wp-config.php" already exists'
159+
echo >&2 ' The contents of this variable will _not_ be inserted into the existing "wp-config.php" file.'
160+
echo >&2 ' (see https://github.com/docker-library/wordpress/issues/333 for more details)'
161+
echo >&2
155162
fi
156163

157164
# see http://stackoverflow.com/a/2705678/433558

php7.1/fpm/docker-entrypoint.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,13 @@ if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROT
152152
153153
EOPHP
154154
chown "$user:$group" wp-config.php
155+
elif [ -e wp-config.php ] && [ -n "$WORDPRESS_CONFIG_EXTRA" ] && [[ "$(< wp-config.php)" != *"$WORDPRESS_CONFIG_EXTRA"* ]]; then
156+
# (if the config file already contains the requested PHP code, don't print a warning)
157+
echo >&2
158+
echo >&2 'WARNING: environment variable "WORDPRESS_CONFIG_EXTRA" is set, but "wp-config.php" already exists'
159+
echo >&2 ' The contents of this variable will _not_ be inserted into the existing "wp-config.php" file.'
160+
echo >&2 ' (see https://github.com/docker-library/wordpress/issues/333 for more details)'
161+
echo >&2
155162
fi
156163

157164
# see http://stackoverflow.com/a/2705678/433558

php7.2/apache/docker-entrypoint.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,13 @@ if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROT
152152
153153
EOPHP
154154
chown "$user:$group" wp-config.php
155+
elif [ -e wp-config.php ] && [ -n "$WORDPRESS_CONFIG_EXTRA" ] && [[ "$(< wp-config.php)" != *"$WORDPRESS_CONFIG_EXTRA"* ]]; then
156+
# (if the config file already contains the requested PHP code, don't print a warning)
157+
echo >&2
158+
echo >&2 'WARNING: environment variable "WORDPRESS_CONFIG_EXTRA" is set, but "wp-config.php" already exists'
159+
echo >&2 ' The contents of this variable will _not_ be inserted into the existing "wp-config.php" file.'
160+
echo >&2 ' (see https://github.com/docker-library/wordpress/issues/333 for more details)'
161+
echo >&2
155162
fi
156163

157164
# see http://stackoverflow.com/a/2705678/433558

php7.2/fpm-alpine/docker-entrypoint.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,13 @@ if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROT
152152
153153
EOPHP
154154
chown "$user:$group" wp-config.php
155+
elif [ -e wp-config.php ] && [ -n "$WORDPRESS_CONFIG_EXTRA" ] && [[ "$(< wp-config.php)" != *"$WORDPRESS_CONFIG_EXTRA"* ]]; then
156+
# (if the config file already contains the requested PHP code, don't print a warning)
157+
echo >&2
158+
echo >&2 'WARNING: environment variable "WORDPRESS_CONFIG_EXTRA" is set, but "wp-config.php" already exists'
159+
echo >&2 ' The contents of this variable will _not_ be inserted into the existing "wp-config.php" file.'
160+
echo >&2 ' (see https://github.com/docker-library/wordpress/issues/333 for more details)'
161+
echo >&2
155162
fi
156163

157164
# see http://stackoverflow.com/a/2705678/433558

php7.2/fpm/docker-entrypoint.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,13 @@ if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROT
152152
153153
EOPHP
154154
chown "$user:$group" wp-config.php
155+
elif [ -e wp-config.php ] && [ -n "$WORDPRESS_CONFIG_EXTRA" ] && [[ "$(< wp-config.php)" != *"$WORDPRESS_CONFIG_EXTRA"* ]]; then
156+
# (if the config file already contains the requested PHP code, don't print a warning)
157+
echo >&2
158+
echo >&2 'WARNING: environment variable "WORDPRESS_CONFIG_EXTRA" is set, but "wp-config.php" already exists'
159+
echo >&2 ' The contents of this variable will _not_ be inserted into the existing "wp-config.php" file.'
160+
echo >&2 ' (see https://github.com/docker-library/wordpress/issues/333 for more details)'
161+
echo >&2
155162
fi
156163

157164
# see http://stackoverflow.com/a/2705678/433558

0 commit comments

Comments
 (0)