Verified Commit 5c3d0f0a authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Add DEBUG option for selecting debugging features

parent b605d112
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -23,6 +23,11 @@ define('UPLOADS', 'media');
 **/
define('CONCATENATE_SCRIPTS', false);

/**
 * Log all errors, warnings and info log lines to STDOUT
 */
define('WP_DEBUG_LOG', '/dev/stdout');

/**
 * Stop the site-health tool from complaining about unwritable filesystems.
 * Background upgrades are performed by a user with write privileges via the
+32 −0
Original line number Diff line number Diff line
@@ -90,6 +90,38 @@ database.

The hostname of the MySQL server providing the database.

### DEBUG

**Type**: string\
**Format**: comma or space separated list\
**Required**: no\
**Example**: "display,script"

If set (even if empty, unless it contains the value `false`) the Wordpress option 
[`WP_DEBUG`][wp_debug] is enabled which will cause error, warning and notice messages to be 
printed to the container output.

The value can contain any of the following, separated by commas or spaces (other values will 
cause an error):

| Value                           | Effect                                                 |
| -----                           | ------                                                 |
| `true` \| `yes` \| `y` \| `on`  | Default if `DEBUG` is set                              |
| `false` \| `no` \| `n` \| `off` | Disables default behaviour, can be combined with others|
| `all`                           | Shorthand for `"display,script,s3"`                    |
| `display`                       | Enables displaying messages in output (not recommended)|
| `script`                        | Enables [`SCRIPT_DEBUG`][script_debug]                 |
| `s3`                            | Enables debug on S3 transfers (may cause memory issues)|

> **Note:**  `false` can be combined with `script` or `s3` to enable the latter features 
> without [`WP_DEBUG`][wp_debug].

[wp_debug]:
  https://developer.wordpress.org/advanced-administration/debug/debug-wordpress/#wp_debug

[script_debug]:
  https://developer.wordpress.org/advanced-administration/debug/debug-wordpress/#script_debug

### HOME_URL

**Type**: string\
+1 −1
Original line number Diff line number Diff line
@@ -68,7 +68,7 @@ add_filter(
		$params['bucket_endpoint'] = true;
		$params['disable_host_prefix_injection'] = true;
		$params['use_path_style_endpoint'] = true;
		$params['debug'] = WP_DEBUG && WP_DEBUG_DISPLAY;
		$params['debug'] = S3_DEBUG;
		return $params;
	}
);
+24 −2
Original line number Diff line number Diff line
@@ -79,8 +79,6 @@ create_config()

	wp config set WP_SITEURL "${site_url%/}"
	wp config set WP_HOME "${home_url%/}"

	wp config set WP_DEBUG_LOG /dev/stdout;
}

setup_database() {
@@ -212,6 +210,29 @@ setup_sandbox()
		static/wp-content/upgrade
}

setup_debug()
{
	[[ -v DEBUG ]] || return

	local IFS=', ' feature
	local enable=true display=false script=false s3=false

	for feature in ${DEBUG:-true}; do
		case $feature in
			false|n|no|off) enable=false ;;
			all) script=true display=true s3=true ;;
			display) display=true ;;
			script) script=true ;;
			s3) s3=true ;;
		esac
	done

	wp config set WP_DEBUG $enable --raw
	wp config set WP_DEBUG_DISPLAY $display --raw
	wp config set SCRIPT_DEBUG $script --raw
	wp config set S3_DEBUG $s3 --raw
}

collect_static()
{
	get_media_dir
@@ -317,6 +338,7 @@ case "$1" in
		timestamp "Starting Wordpress preparation"
		create_config
		setup_components
		setup_debug
		setup_media
		collect_static
		generate_static