big issue with include_once !

From: Date: Thu, 26 Jul 2001 16:34:26 +0000
Subject: big issue with include_once !
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-1062@lists.php.net to get a copy of this message
I sent this message to the Horde list some time ago, but I discovered that the problem is the main with PEAR, look very important! -- I am using php 4.0.6, so this issue may be recent. Let's say I do that $a=include_once 'HTML/menu.php'; $b=include_once 'HTML/menu.php'; Then $a=true but $b=null/false That means that every code in the lib that has a method factory is not working rigth In fact, we have that:
    function factory ($log_type, $log_name = '', $ident = '', $conf = array()) {
        $log_type = strtolower($log_type);
        $classfile = 'Log/' . $log_type . '.php';
if (@include_once $classfile) {
            $class = 'Log_' . $log_type;
            return new $class($log_name, $ident, $conf);
        } else {
            return false;
The problem is that the first factory will work fine, but the other will fail: We will get a false for the include_once, so a false from the factory. I think we have to replace everywhere if (@include_once $classfile) {
            $class = 'Log_' . $log_type;
... By: @include_once $classfile;
            $class = 'Log_' . $log_type;
if (class_exists($class)) { ... It migth be good also to add a constant such as PEAR_DIRECTORY to include the file, because some ISP may not let you change the php.ini or work wirh .htaccess Also, I think it would be better to define the method like this:
    function &factory($driver, $params)
What do you think?

« previous php.pear.dev (#1062) next »