From 613966f0a630cfd1add350b498b827acf0f717da Mon Sep 17 00:00:00 2001
From: jrfnl <github_nospam@adviesenzo.nl>
Date: Thu, 10 Dec 2015 01:52:05 +0100
Subject: [PATCH] Turn error display off when WP_DEBUG is `false`.

And general boyscouting the touched function.
---
 src/wp-includes/load.php | 28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/src/wp-includes/load.php b/src/wp-includes/load.php
index 9d247ba..174aa9c 100644
--- a/src/wp-includes/load.php
+++ b/src/wp-includes/load.php
@@ -267,16 +267,15 @@ function timer_stop( $display = 0, $precision = 3 ) {
  * It is strongly recommended that plugin and theme developers use `WP_DEBUG`
  * in their development environments.
  *
- * `WP_DEBUG_DISPLAY` and `WP_DEBUG_LOG` perform no function unless `WP_DEBUG`
- * is true.
+ * When `WP_DEBUG` is `true` *and* `WP_DEBUG_DISPLAY` is true, WordPress will
+ * force errors to be displayed.
+ * When `WP_DEBUG` is `false`, WordPress will turn the display of errors off.
+ * Defining `WP_DEBUG_DISPLAY` as `null` prevents WordPress from changing the
+ * global configuration setting in both cases.
  *
- * When `WP_DEBUG_DISPLAY` is true, WordPress will force errors to be displayed.
- * `WP_DEBUG_DISPLAY` defaults to true. Defining it as null prevents WordPress
- * from changing the global configuration setting. Defining `WP_DEBUG_DISPLAY`
- * as false will force errors to be hidden.
- *
- * When `WP_DEBUG_LOG` is true, errors will be logged to debug.log in the content
- * directory.
+ * `WP_DEBUG_LOG` performs no function unless `WP_DEBUG` is true.
+ * When `WP_DEBUG_LOG` is true, errors will be logged to debug.log in the
+ * /wp-content/ directory.
  *
  * Errors are never displayed for XML-RPC requests.
  *
@@ -287,10 +286,11 @@ function wp_debug_mode() {
 	if ( WP_DEBUG ) {
 		error_reporting( E_ALL );
 
-		if ( WP_DEBUG_DISPLAY )
+		if ( WP_DEBUG_DISPLAY ) {
 			ini_set( 'display_errors', 1 );
-		elseif ( null !== WP_DEBUG_DISPLAY )
+		} elseif ( null !== WP_DEBUG_DISPLAY ) {
 			ini_set( 'display_errors', 0 );
+		}
 
 		if ( WP_DEBUG_LOG ) {
 			ini_set( 'log_errors', 1 );
@@ -298,9 +298,13 @@ function wp_debug_mode() {
 		}
 	} else {
 		error_reporting( E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR );
+		if ( null !== WP_DEBUG_DISPLAY ) {
+			ini_set( 'display_errors', 0 );
+		}
 	}
-	if ( defined( 'XMLRPC_REQUEST' ) )
+	if ( defined( 'XMLRPC_REQUEST' ) ) {
 		ini_set( 'display_errors', 0 );
+	}
 }
 
 /**
-- 
1.9.4.msysgit.2

