PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Networking » Net_DNS » Bug #7350

Fatal error in pear\Net\DNS\RR.php

Details

Submitted2006-04-09 11:53 UTC
Fromflatron123 at freemail dot hu
Assignedbate
StatusClosed
PackageNet_DNS
PHP Version5.1.1
OSWindows XP Pro SP2
Roadmaps(Not assigned)

Comments

[2006-04-09 11:53 UTC] flatron123 at freemail dot hu

Description:
------------
When I run this script, I get a fatal error:
Fatal error: Cannot re-assign $this in C:\Program Files\xampp\php\pear\Net\DNS\RR.php on line 60

Test script:
---------------
$resolver = new Net_DNS_Resolver();
$response = $resolver->query('freemail.hu', 'MX');
if ($response) {
foreach ($response->answer as $rr) {
$rr->display();
}
if (count($response->additional)) {
foreach ($response->additional as $rr) {
$rr->display();
}
}
}

Expected result:
----------------
I expect that script to resolve the MXs of freemail.hu, this script is an example written on this page under the Net_DNS class documentation.

Actual result:
--------------
Fatal error: Cannot re-assign $this in C:\Program Files\xampp\php\pear\Net\DNS\RR.php on line 60

[2006-04-14 07:37 UTC] bb at wavecon dot de

I hit this bug also and found a simple solution:

Just replace "$this" with "return" in the constructor of the RR.php.

[2006-07-26 06:56 UTC] matthew at cosnet dot net dot au

Tried the above suggestion with result:

PHP Warning: preg_match() expects parameter 2 to be string, object given in /usr/share/pear/Net/DNS/Resolver.php on line 1025
PHP Notice: Object of class Net_DNS_Packet to string conversion in /usr/share/pear/Net/DNS/Packet.php on line 327
PHP Notice: Trying to get property of non-object in dodns.php on line 13
PHP Fatal error: Call to a member function display() on a non-object in dodns.php on line 13

[2006-08-01 14:50 UTC] astylman at hotmail dot com

In addition to the fix proposed by Benjamin, I tried the following with success:

First open the C:\Program\Files\xampp\php\pear\Net\DNS\Resolver.php file.

In the implementation of the function make_query_packet(), i.e. on line 1010, do the following change:

replace

if (is_object($packetORname) && get_class($packetORname) == "net_dns_packet")

with

if (is_object($packetORname) && strtolower(get_class($packetORname)) == "net_dns_packet")

Its seems that when we have a packet, the function get_class($packetORname) returns the string "Net_DNS_Packet". When trying to compare this string with the "net_dns_packet" string the comparison returns false instead of true (as expected), as there is a problem of case sensitivity. Converting to lowercase the result returned by the function get_class($packetORname) with the help of the function strtolower(get_class($packetORname)) seemed to solve the problem (at least for me).

Hope this will help.