ZF-10871: Socket adapter's error handler may emit Notice for undefined variable: errno


Notice: Undefined variable: errno in /path/Zend/Http/Client/Adapter/Socket.php on line 236

Backtrace -->

0 Piwik_ErrorHandler(8, Undefined variable: errno, /path/Zend/Http/Client/Adapter/Socket.php, 236, Array ([host] => tcp://,[port] => 80,[secure] => ,[context] => Resource id #126,[flags] => 4)) called at [/path/Zend/Http/Client/Adapter/Socket.php:236]

1 Zend_Http_Client_Adapter_Socket->connect(, 80, ) called at [/path/Zend/Http/Client.php:969]

2 Zend_Http_Client->request(GET) called at [/path/Zend/Feed.php:171]

3 Zend_Feed::import( called at [.../ExampleRssWidget.php:103]


Would it be possible for a Zend Developer to fix this NOTICE error message?

It affects us at as we are seeing the notice. WE would love not to patch our local copy. Fixing all NOTICEs is best practise. Thank you for your time!

Reported bug in Piwik:

As well as "undefined errno" in the ticket there is also: Notice: Undefined variable: errstr in /home/xxx/httpdocs/piwik/libs/Zend/Http/Client/Adapter/Socket.php on line 236

The cause is when stream_socket_client is disabled, $errno and $errstr (which are passed by reference) are never initialized by the function.

The patch is:

Index: Zend/Http/Client/Adapter/Socket.php
--- Socket.php  (revision 5942)
+++ Socket.php  (working copy)
@@ -222,6 +222,7 @@
             $flags = STREAM_CLIENT_CONNECT;
             if ($this->config['persistent']) $flags |= STREAM_CLIENT_PERSISTENT;
+            $errno = $errstr = '';
             $this->socket = @stream_socket_client($host . ':' . $port,