Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.0.7

Bug #12487 Spurious "Fatal error: Class 'Net_DNS_RR' not found"
Submitted: 2007-11-20 16:34 UTC
From: kgaughan Assigned: bate
Status: Closed Package: Net_DNS (version 1.0.0)
PHP Version: 5.2.3 OS: Ubuntu 7.10
Roadmaps: (Not assigned)    
Subscription  


 [2007-11-20 16:34 UTC] kgaughan (Keith Gaughan)
Description: ------------ Because the subclasses of Net_DNS_RR are being included in Net/DNS/RR.php *before* Net_DNS_RR is defined, the subclasses are trying to extend a class which does not yet exist. This is fixed by moving the fold block containing the require_once directives *after* the class definition for Net_DNS_RR. Test script: --------------- <?php include 'Net/DNS.php';

Comments

 [2007-11-21 08:24 UTC] bate (Marco Kaiser)
Hi, php -r "include('Net/DNS.php'); print_r(new NET_DNS());" with latest release work perfect for me. So here are an example: <?php class foo extends bar{} class bar{} print_r(new foo()); ?> this works because i we compile our php since php4. Its possible to use class and functions before we define them in a script. If this bug still exists, please provide more informations. One note, try to change include to require. You know the difference between include and require?
 [2007-11-21 10:49 UTC] kgaughan (Keith Gaughan)
You ought to have marked this as 'Suspended' or 'Open', because you didn't try the same test case as me. The behaviour of "php -r" is not the same as that of "php -a" and "php script.php" so can't be used for testing bugs exhibited under those conditions. I also duplicated this very same error under CentOS 4.4 with identical results. Here's exactly what I did to trigger it: --- START --- $ php -r "include 'Net/DNS.php'; print_r(new Net_DNS_Resolver());" Net_DNS_Resolver Object ( [nameservers] => Array ( [0] => 81.17.240.194 [1] => 81.17.240.195 ) [port] => 53 [domain] => blacknight.ie [searchlist] => Array ( [0] => blacknight.ie ) [retrans] => 5 [retry] => 4 [usevc] => 0 [stayopen] => 0 [igntc] => 0 [recurse] => 1 [defnames] => 1 [dnsrch] => 1 [errorstring] => unknown error or no error [answerfrom] => [answersize] => 0 [tcp_timeout] => 120 [resolv_conf] => /etc/resolv.conf [dotfile] => .resolv.conf [confpath] => Array ( [0] => /root [1] => . ) [debug] => 0 [useEnhancedSockets] => 1 [sockets] => [_axfr_sock] => [_axfr_rr] => [_axfr_soa_count] => ) $ php -a Interactive mode enabled <?php include 'Net/DNS.php'; Fatal error: Class 'Net_DNS_RR' not found in /usr/local/lib/php/Net/DNS/RR/A.php on line 97 --- END --- Notice the difference? BTW, I'm quite aware of the difference between include and require and it shouldn't (and won't) make the slightest bit of difference in this case. Mind, however, that cd-ing to the directory containing the PEAR libraries and executing: $ php Net/DNS.php Triggers no error. The problem, without diving into the PHP source, may be at least obliquely related to memory usage. Compiling Net/DNS.php consumes quite a lot of memory and servers with fairly low memory limits per script (say, about 20-25MB) crap out when compiling. The compiler may be attempting to do things to conserve memory when including or requiring files that moving the require_once as I did in my patch avoids. This is just a shot in the dark, mind.
 [2007-11-30 12:03 UTC] kgaughan (Keith Gaughan)
Switching this from feedback to open in the hope it'll get somebody's attention.
 [2007-11-30 12:50 UTC] bate (Marco Kaiser)
This isnt a bug the php-cli "php -a" works as expected. -a Run PHP interactively. This lets you enter snippets of PHP code that directly get executed. When readline support is enabled you can edit the lines and also have history support. this means no compilation and in this case you get this error. But i can't change the coding here because we have coding quidelines and if i change this. (apply your patch) i will break the rules. So dont run in interactive mode. Try just run php without -a :/#php <?php ...your code push STRG+D and your code will be executed as expected. :) For futher question about this behavior ask the internals@list please.