Bug #19281 [Fbk->Csd]: with error_reporting(-1) there is undefined property _sock
| From: | mike at mrhost dot ca | Date: | Fri, 10 Feb 2012 21:27:27 +0000 |
| Subject: | Bug #19281 [Fbk->Csd]: with error_reporting(-1) there is undefined property _sock | ||
| References: | 1 | Groups: | php.pear.bugs |
| Request: | Send a blank email to pear-bugs+get-8264@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: mike@mrhost.ca
Reported By: michael dot kefeder at world4you dot com
Summary: with error_reporting(-1) there is undefined property
_sock
-Status: Feedback
+Status: Closed
Type: Bug
Package: Net_DNS2
Operating System: Linus
Package Version: 1.2.0
PHP Version: 5.3.8
-Assigned To:
+Assigned To: mikepultz
Roadmap Versions:
New Comment:
-Status: Feedback
+Status: Closed
-Assigned To:
+Assigned To: mikepultz
Ok- it's fixed in SVN.
The problem was that the Net_DNS2_Socket::_sock property was set to
private,
while it should have been set protected.
When the lookup worked- it would have just created a new local "_sock"
property,
and then it would be able to close() it. In your case, it never created
the local
property, and it couldn't access the private property, so it generated
the "undefined
property" error.
You can grab a copy from trunk, or just change the "_sock" property from
private
to protected in Net/DNS2/Socket.php.
As for your code- what you could do is create a second Net_DNS2 object
initially to
do the A look up of the DNS server hostname, against your systems
recursive
DNS. If that succeeds, then use the IP address in the second instance of
Net_DNS2
to do your actual work.
Mike
Previous Comments:
------------------------------------------------------------------------
[2012-02-10 09:52:08] michaelkefeder
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();
}
------------------------------------------------------------------------
[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