From 80937742da2f6b8446d38d11d6202ec9f09514f7 Mon Sep 17 00:00:00 2001 From: ryan Date: Tue, 5 Aug 2008 05:45:34 +0000 Subject: [PATCH] Suppress fopen errors if WP_DEBUG is not enabled. Props jacobsantos. fixes #7456 see #4779 git-svn-id: http://svn.automattic.com/wordpress/trunk@8545 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/http.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/wp-includes/http.php b/wp-includes/http.php index ff8d7a3b85..f28cb83e1a 100644 --- a/wp-includes/http.php +++ b/wp-includes/http.php @@ -542,10 +542,16 @@ class WP_Http_Fopen { $arrURL = parse_url($url); + if ( false === $arrURL ) + return new WP_Error('http_request_failed', sprintf(__('Malformed URL: %s'), $url)); + if ( 'http' != $arrURL['scheme'] || 'https' != $arrURL['scheme'] ) $url = str_replace($arrURL['scheme'], 'http', $url); - $handle = fopen($url, 'r'); + if ( !defined('WP_DEBUG') || ( defined('WP_DEBUG') && false === WP_DEBUG ) ) + $handle = @fopen($url, 'r'); + else + $handle = fopen($url, 'r'); if (! $handle) return new WP_Error('http_request_failed', sprintf(__('Could not open handle for fopen() to %s'), $url)); @@ -637,6 +643,9 @@ class WP_Http_Streams { $arrURL = parse_url($url); + if ( false === $arrURL ) + return new WP_Error('http_request_failed', sprintf(__('Malformed URL: %s'), $url)); + if ( 'http' != $arrURL['scheme'] || 'https' != $arrURL['scheme'] ) $url = str_replace($arrURL['scheme'], 'http', $url); @@ -656,7 +665,10 @@ class WP_Http_Streams { $context = stream_context_create($arrContext); - $handle = fopen($url, 'r', false, $context); + if ( !defined('WP_DEBUG') || ( defined('WP_DEBUG') && false === WP_DEBUG ) ) + $handle = @fopen($url, 'r'); + else + $handle = fopen($url, 'r'); if ( ! $handle) return new WP_Error('http_request_failed', sprintf(__('Could not open handle for fopen() to %s'), $url)); @@ -1107,4 +1119,4 @@ function wp_remote_retrieve_body(&$response) { return $response['body']; } -?> \ No newline at end of file +?>