From 6375b102d50189e874b3adfd32007fab22a335a6 Mon Sep 17 00:00:00 2001 From: David Jardin Date: Wed, 13 Nov 2013 09:23:30 +0100 Subject: [PATCH] # [#32608] After update 2.5.14=>2.5.16 the com_update produces errors Thanks David Jardin (Fix #2500) --- installation/CHANGELOG | 3 +++ libraries/joomla/http/transport/stream.php | 24 +++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/installation/CHANGELOG b/installation/CHANGELOG index 0e6706011eda8..03b7b11e483f8 100644 --- a/installation/CHANGELOG +++ b/installation/CHANGELOG @@ -26,6 +26,9 @@ $ -> Language fix or change - -> Removed ! -> Note +13-Nov-2013 Jean-Marie Simonet + # [#32608] After update 2.5.14=>2.5.16 the com_update produces errors Thanks David Jardin + 12-Nov-2013 Jean-Marie Simonet # [#30648] Incorrect ID for trash toolbar button when message is added Thanks Jurian Even # [#29596] Inefficient code Thanks Ben tasker diff --git a/libraries/joomla/http/transport/stream.php b/libraries/joomla/http/transport/stream.php index 780ab1403ca21..36bcf4868d7fc 100644 --- a/libraries/joomla/http/transport/stream.php +++ b/libraries/joomla/http/transport/stream.php @@ -121,8 +121,30 @@ public function request($method, JUri $uri, $data = null, array $headers = null, // Create the stream context for the request. $context = stream_context_create(array('http' => $options)); + // Capture PHP errors + $php_errormsg = ''; + $track_errors = ini_get('track_errors'); + ini_set('track_errors', true); + // Open the stream for reading. - $stream = fopen((string) $uri, 'r', false, $context); + $stream = @fopen((string) $uri, 'r', false, $context); + + if (!$stream) + { + if (!$php_errormsg) + { + // Error but nothing from php? Create our own + $php_errormsg = sprintf('Could not connect to resource: %s', $uri, $err, $errno); + } + + // Restore error tracking to give control to the exception handler + ini_set('track_errors', $track_errors); + + throw new RuntimeException($php_errormsg); + } + + // Restore error tracking to what it was before. + ini_set('track_errors', $track_errors); // Get the metadata for the stream, including response headers. $metadata = stream_get_meta_data($stream);