Bug #19281 [Fbk]: with error_reporting(-1) there is undefined property _sock
| From: | michael dot kefeder at world4you dot com | Date: | Fri, 10 Feb 2012 09:52:09 +0000 |
| Subject: | Bug #19281 [Fbk]: with error_reporting(-1) there is undefined property _sock | ||
| References: | 1 | Groups: | php.pear.bugs |
| Request: | Send a blank email to pear-bugs+get-8259@lists.php.net to get a copy of this message | ||
Edit report at https://pear.php.net/bugs/bug.php?id=19281&edit=1
ID: 19281
Updated by: michael.kefeder@world4you.com
Reported By: michael dot kefeder at world4you dot com
Summary: with error_reporting(-1) there is undefined property
_sock
Status: Feedback
Type: Bug
Package: Net_DNS2
Operating System: Linus
Package Version: 1.2.0
PHP Version: 5.3.8
Roadmap Versions:
New Comment:
You are correct, I misinterpreted the problem we have, it is not about
nameservers that cannot be reached, but nameservers-names that don't
resolve to a valid IP Address. I ran into this checking SOA records
against information found in whois for domains, now when they provide
domain names for their nameservers that no longer exist the problem
comes up. Workaround is of course to check the return value of
gethostbyname() and not even try to query that machine, but it is still
the case that other bogus input for $resolver->setServers() will throw
an exception and after that print a warning when destructed, which can
be fixed easily by checking for that property.
here's some code to illustrate it:
error_reporting(-1);
require_once('Net/DNS2.php');
$resolver = new Net_DNS2_Resolver();
$resolver->retrans = 0;
$resolver->recurse = 0;
$Domain = 'domain.eu';
try
{
$resolver->setServers(array(gethostbyname('not.existing.anywhere')));
$dns_response = $resolver->query($Domain, 'SOA');
var_dump(is_array($dns_response));
}
catch (Net_DNS2_Exception $e)
{
echo $e->getMessage();
}
Previous Comments:
------------------------------------------------------------------------
[2012-02-09 21:45:10] mikepultz
-Status: Open
+Status: Feedback
-Type: Feature/Change Request
+Type: Bug
We are unable to reproduce the bug as reported.
Please provide a simple script (10 lines or less)
or a link to an external script that can be used
to reproduce the bug.
If you can provide the script, feel free to add it
to this bug and change the status back to "Open".
Thank you for your interest in PEAR.
Thanks for reporting this Michael,
Can you send me an example script that's broken? I tried putting in a
fake name
servers, but I couldn't get it to fail.
Thanks,
Mike
------------------------------------------------------------------------
[2012-02-08 15:19:30] michaelkefeder
Description:
------------
When a Net_DNS2 object gets destructed it calls Sockets::close()
function, in there it checks if $this->_sock is a resource, but when
nameservers cannot be reached for example that property doesn't seem to
be set and therefore a warning is emitted. i propose to change the
function to include a property_exists() check first in file
Net/DNS2/Socket/Sockets.php:
public function close()
{
if (property_exists($this, '_sock')
&&is_resource($this->_sock) === true) {
@socket_close($this->_sock);
}
return true;
}
------------------------------------------------------------------------
--
Edit this bug report at https://pear.php.net/bugs/bug.php?id=19281&edit=1