storageFactory: more bugs?

Balarama Bosch <[email protected]> Fri, 28 Oct 2005 17:12:30 -0500
Newsgroups gmane.comp.php.pear.liveuser
Message-ID <[email protected]>
I'm trying to upgrade to PHP5 (it works perfectly in php4.4.0, and I'm
not changing any code), and encountered the following with LiveUser
0.16.7:

I keep getting 'Unknown Errors' in my debug log, resulting from the
storageFactory returning false.

I traced it back to line 614 of LiveUser.php:


        $storageConf =& $confArray[$key];
        unset($confArray[$key]);
        $storage = &new $storageName();
        if ($storage->init($storageConf, $confArray) === false) {
            $storage = false;
        }
        return $storage;


The unset($confArray[$key]) command removes data from the original conf
array, which is passed by reference.
Again, this only seems to be causing problems in PHP5, not in PHP4.4.0,
though the original conf array still gets maimed in both versions.

Why is the storage array being unset?
Perhaps $confArray should not be passed by reference on line, but as a
copy? This seems to fix the problem.

line 590:
instead of: function &storageFactory(&$confArray, $classprefix = 'LiveUser_Perm_')
use:        function &storageFactory($confArray, $classprefix = 'LiveUser_Perm_')

Also, $storage->init($storageConf, $confArray) seems odd. Are there some
implementations of storage classes that take more than 1 argument in the
init method? I could find only 1 argument in the init methods...

Hope to hear from you guys.

Cheers,
  Balarama Bosch