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

Issue Type: Bug Created: 2010-12-27T08:26:53.000+0000 Last Updated: 2012-08-31T08:43:23.000+0000 Status: Open Fix version(s): Reporter: Anthon Pang, VIP Software Technologies Inc. (vipsoft) Assignee: Shahar Evron (shahar) Tags: - Zend_Http_Client

Related issues: Attachments:


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]


Posted by matthieu (matthieu) on 2012-03-01T00:57:53.000+0000

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

Posted by Anthon Pang, VIP Software Technologies Inc. (vipsoft) on 2012-03-01T02:26:36.000+0000

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:

<pre class="highlight">
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,

Have you found an issue?

See the Overview section for more details.


© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.