From 89a9762c429578a909fda2a9f664cb202232d06c Mon Sep 17 00:00:00 2001 From: Peter Westwood Date: Wed, 18 Nov 2009 08:22:49 +0000 Subject: [PATCH] Ensure WP_DEBUG is always defined and simplify the checks on it. Fixes #11090 props nacin. git-svn-id: https://develop.svn.wordpress.org/trunk@12207 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/functions.php | 10 ++++------ wp-includes/http.php | 10 +++++----- wp-includes/wp-db.php | 2 +- wp-settings.php | 1 + 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 151ccc6c12..af58d5af13 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -2927,8 +2927,7 @@ function atom_service_url_filter($url) * to get the backtrace up to what file and function called the deprecated * function. * - * The current behavior is to trigger an user error if WP_DEBUG is defined and - * is true. + * The current behavior is to trigger an user error if WP_DEBUG is true. * * This function is to be used in every function in depreceated.php * @@ -2949,7 +2948,7 @@ function _deprecated_function($function, $version, $replacement=null) { do_action('deprecated_function_run', $function, $replacement); // Allow plugin to filter the output error trigger - if( defined('WP_DEBUG') && ( true === WP_DEBUG ) && apply_filters( 'deprecated_function_trigger_error', true )) { + if( WP_DEBUG && apply_filters( 'deprecated_function_trigger_error', true )) { if( !is_null($replacement) ) trigger_error( sprintf( __('%1$s is deprecated since version %2$s! Use %3$s instead.'), $function, $version, $replacement ) ); else @@ -2964,8 +2963,7 @@ function _deprecated_function($function, $version, $replacement=null) { * to get the backtrace up to what file and function included the deprecated * file. * - * The current behavior is to trigger an user error if WP_DEBUG is defined and - * is true. + * The current behavior is to trigger an user error if WP_DEBUG is true. * * This function is to be used in every file that is depreceated * @@ -2986,7 +2984,7 @@ function _deprecated_file($file, $version, $replacement=null) { do_action('deprecated_file_included', $file, $replacement); // Allow plugin to filter the output error trigger - if( defined('WP_DEBUG') && ( true === WP_DEBUG ) && apply_filters( 'deprecated_file_trigger_error', true )) { + if( WP_DEBUG && apply_filters( 'deprecated_file_trigger_error', true ) ) { if( !is_null($replacement) ) trigger_error( sprintf( __('%1$s is deprecated since version %2$s! Use %3$s instead.'), $file, $version, $replacement ) ); else diff --git a/wp-includes/http.php b/wp-includes/http.php index 3d623fe482..cd5fb6a2ed 100644 --- a/wp-includes/http.php +++ b/wp-includes/http.php @@ -655,7 +655,7 @@ class WP_Http_Fsockopen { $proxy = new WP_HTTP_Proxy(); - if ( !defined('WP_DEBUG') || ( defined('WP_DEBUG') && false === WP_DEBUG ) ) { + if ( !WP_DEBUG ) { if ( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) ) $handle = @fsockopen( $proxy->host(), $proxy->port(), $iError, $strError, $r['timeout'] ); else @@ -826,7 +826,7 @@ class WP_Http_Fopen { if ( 'http' != $arrURL['scheme'] && 'https' != $arrURL['scheme'] ) $url = str_replace($arrURL['scheme'], 'http', $url); - if ( !defined('WP_DEBUG') || ( defined('WP_DEBUG') && false === WP_DEBUG ) ) + if ( !WP_DEBUG ) $handle = @fopen($url, 'r'); else $handle = fopen($url, 'r'); @@ -999,7 +999,7 @@ class WP_Http_Streams { $context = stream_context_create($arrContext); - if ( ! defined('WP_DEBUG') || ( defined('WP_DEBUG') && false === WP_DEBUG ) ) + if ( !WP_DEBUG ) $handle = @fopen($url, 'r', false, $context); else $handle = fopen($url, 'r', false, $context); @@ -1167,7 +1167,7 @@ class WP_Http_ExtHTTP { } } - if ( !defined('WP_DEBUG') || ( defined('WP_DEBUG') && false === WP_DEBUG ) ) //Emits warning level notices for max redirects and timeouts + if ( !WP_DEBUG ) //Emits warning level notices for max redirects and timeouts $strResponse = @http_request($r['method'], $url, $r['body'], $options, $info); else $strResponse = http_request($r['method'], $url, $r['body'], $options, $info); //Emits warning level notices for max redirects and timeouts @@ -1184,7 +1184,7 @@ class WP_Http_ExtHTTP { $theHeaders = WP_Http::processHeaders($theHeaders); if ( ! empty( $theBody ) && isset( $theHeaders['headers']['transfer-encoding'] ) && 'chunked' == $theHeaders['headers']['transfer-encoding'] ) { - if ( !defined('WP_DEBUG') || ( defined('WP_DEBUG') && false === WP_DEBUG ) ) + if ( !WP_DEBUG ) $theBody = @http_chunked_decode($theBody); else $theBody = http_chunked_decode($theBody); diff --git a/wp-includes/wp-db.php b/wp-includes/wp-db.php index b04ae8b43f..f70cd86237 100644 --- a/wp-includes/wp-db.php +++ b/wp-includes/wp-db.php @@ -357,7 +357,7 @@ class wpdb { function __construct($dbuser, $dbpassword, $dbname, $dbhost) { register_shutdown_function(array(&$this, "__destruct")); - if ( defined('WP_DEBUG') and WP_DEBUG == true ) + if ( WP_DEBUG ) $this->show_errors(); if ( defined('DB_CHARSET') ) diff --git a/wp-settings.php b/wp-settings.php index 2194bdbac8..b52c3bb0b8 100644 --- a/wp-settings.php +++ b/wp-settings.php @@ -210,6 +210,7 @@ if ( defined('WP_DEBUG') && WP_DEBUG == true ) { ini_set('error_log', WP_CONTENT_DIR . '/debug.log'); } } else { + define('WP_DEBUG', false); if ( defined('E_RECOVERABLE_ERROR') ) error_reporting(E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR); else