Home » Networking » Net_DNS » Bug #1871
Cannot re-assign $this in RR.php
Details
| Submitted | 2004-07-14 14:56 UTC |
|---|---|
| From | lapo at lapo dot it |
| Assigned | cox |
| Status | Closed |
| Package | Net_DNS |
| PHP Version | 5.0.0RC2 (Release Candidate 2) |
| OS | Windows 2000 |
| Roadmaps | (Not assigned) |
Comments
[2004-07-14 14:56 UTC] lapo at lapo dot it
Description:
------------
I guess this is no more vaild in the ZendEngine2:
$this = $this->new_from_string($rrdata);
Reproduce code:
---------------
include('Net_DNS.php');
Expected result:
----------------
no fatal error
Actual result:
--------------
[14-Jul-2004 16:52:08] PHP Fatal error: Cannot re-assign $this in D:\Program Files\PHP\PEAR\Net\DNS\RR.php on line 65
[2004-08-31 23:56 UTC] ben at ripcord dot co dot nz
I see this bug too. Keen to see it fixed.
[2004-09-02 13:36 UTC] michal at feix dot cz
Yes, this is really no longer possible with new Zend engine. The workaround is quite simple. All you need is to make the following change in Net/DNS/RR.php:
function Net_DNS_RR($rrdata)
{
if (is_string($rrdata)) {
$new_this = $this->new_from_string($rrdata);
} else if (count($rrdata) == 7) {
list ($name, $rrtype, $rrclass, $ttl, $rdlength, $data, $offset) = $rrdata;
$new_this = $this->new_from_data($name, $rrtype, $rrclass, $ttl, $rdlength, $data, $offset);
} else {
$new_this = $this->new_from_array($rrdata);
}
foreach ($get_object_vars($new_this) as $key => $val)
$this->$key = $val;
}
Sorry for not pasting the diff output instead.
[2004-09-02 14:12 UTC] michal at feix dot cz
Oops, my previous post contains a small typo. Of course, there should be no '$' in front of get_object_vars call. Here is my diff:
--- RR.php.old Thu Sep 2 15:42:37 2004
+++ RR.php Thu Sep 2 15:45:11 2004
@@ -56,15 +56,17 @@
/* class constructor - Net_DNS_RR($rrdata) {{{ */
function Net_DNS_RR($rrdata)
{
if (is_string($rrdata)) {
- $this = $this->new_from_string($rrdata);
+ $new_this = $this->new_from_string($rrdata);
} else if (count($rrdata) == 7) {
list ($name, $rrtype, $rrclass, $ttl, $rdlength, $data, $offset) = $rrdata;
- $this = $this->new_from_data($name, $rrtype, $rrclass, $ttl, $rdlength, $data, $offset);
+ $new_this = $this->new_from_data($name, $rrtype, $rrclass, $ttl, $rdlength, $data, $offset);
} else {
- $this = $this->new_from_array($rrdata);
+ $new_this = $this->new_from_array($rrdata);
}
+ foreach (get_object_vars($new_this) as $key => $val)
+ $this->$key = $val;
}
/* }}} */
/* Net_DNS_RR::new_from_data($name, $ttl, $rrtype, $rrclass, $rdlength, $data, $offset) {{{ */
[2004-12-11 22:38 UTC] tanguy dot pruvot at laposte dot net
what are you waiting to update package ?
[2005-04-06 15:35 UTC] cox at idecnet dot com
The patch for RR.php does not work. The other one for make_query should be fixed.
[2005-04-08 16:14 UTC] cox at idecnet dot com
Ok, fixed in CVS. Thanks for the help!
Tomas V.V.Cox