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

Bug #5526 init failed error after modifying code
Submitted: 2005-09-26 20:51 UTC
From: liveuser at gisborne dot emailuser dot net Assigned: lsmith
Status: Closed Package: LiveUser
PHP Version: 5.0.4 OS: Linux
Roadmaps: (Not assigned)    
Subscription  


 [2005-09-26 20:51 UTC] liveuser at gisborne dot emailuser dot net
Description: ------------ As near as I can tell, this happens randomly (but fairly often) after modifying any code (often, code having nothing to do with LiveUser). It always disappears on reloading the page, and I think stays away until I modify code. The manifestation is this error: init failed array(1) { [0]=> &array(7) { ["code"]=> int(-1) ["params"]=> array(1) { ["msg"]=> string(39) "Could not instanciate storage container" } ["package"]=> string(8) "LiveUser" ["level"]=> string(9) "exception" ["time"]=> float(1127480179.3557) ["context"]=> array(4) { ["file"]=> string(43) "/usr/local/lib/php/LiveUser/Perm/ Simple.php" ["line"]=> int(156) ["function"]=> string(4) "init" ["class"]=> string(21) "LiveUser_Perm_Complex" } ["message"]=> string(13) "Unknown error" } } Test script: --------------- Can't reliably reproduce, but here is my init stuff: $result = array('login' => array( 'force' => true, 'regenid' => true ), 'logout' => array( 'destroy' => true, ), 'cookie' => array( 'name' => '<name goes here>', 'lifetime' => 1000, 'secret' => '<password goes here>', 'savedir' => $PATH_PREFIX . '/php-other/cookies', 'secure' => false, 'path' => '/', 'domain' => '' ), 'authContainers' => array( array( 'type' => 'DB', 'loginTimeout' => 0, 'expireTime' => 3600, 'idleTime' => 1800, 'allowDuplicateHandles' => 0, 'storage' => array( 'dsn' => $this->dsn, 'alias' => array( 'auth_user_id' => 'authUserId', 'lastlogin' => 'lastLogin', 'is_active' => 'isActive', 'owner_user_id' => 'owner_user_id', 'owner_group_id' => 'owner_group_id', 'users' => 'peoples', ), 'fields' => array( 'lastlogin' => 'timestamp', 'is_active' => 'boolean', 'owner_user_id' => 'integer', 'owner_group_id' => 'integer', ), 'tables' => array( 'users' => array( 'fields' => array( 'lastlogin' => false, 'is_active' => false, 'owner_user_id' => false, 'owner_group_id' => false, ), ), ), ), ), ), 'permContainer' => array( 'type' => 'Complex', 'storage' => array( 'DB' => array( 'dsn' => $this->dsn, 'prefix' => 'liveuser_', 'alias' => array( 'perm_users' => 'perm_peoples', ), ) ), ), );

Comments

 [2005-09-26 21:06 UTC] lsmith
Other users have reported similar issues, but nobody was so far able to locate the issue or notice a pattern: http://pear-forum.de/ftopic735.html
 [2005-09-27 08:02 UTC] lsmith
Ok .. I just checked how this error message can occur. It can only happen if LiveUser::storageFactory() returns false. There are two cases in which this can happen. 1) if LiveUser::loadClass() is unable to load the file associated with the storage container (in your case "LiveUser_Perm_Storage_DB") and there are no more other storage container in the storage container stack (in your case there is only one .. and we have not implemented any container that would make it feasible to have more than one anyways) 2) if the init() method in the storage container instance failed. this can only happen if DB::connect() fails. in this case however an error is placed on the stack. therefore for 2) to happen there would need to be 2 errors on the stack. So it can only be 1) it seems. Are you using some kind of bytecode cache?
 [2005-10-10 13:29 UTC] nkahn at cmd dot lu
I had the same problem. It seems to come form the "storageFactory" method of LiveUser class. In fact this method deletes permission container storage configuration after having created the container (see "unset($confArray[$key]);" file LiveUser.php, line 636, version 0.16.6 beta). So if you call this method a second time in the same script, it won't find any configuration and will fail resulting in a "Cannot instantiate permission container" error. I have modified file Simple.php with the following patch : --- Simple.php.bak 2005-10-10 14:53:33.000000000 +0200 +++ Simple.php 2005-10-10 15:05:10.000000000 +0200 @@ -149,8 +149,10 @@ class LiveUser_Perm_Simple } } } - - $this->_storage =& LiveUser::storageFactory($conf['storage']); + + // copy storage information otherwise it will be deleted + $storageConf = $conf['storage']; + $this->_storage =& LiveUser::storageFactory($storageConf); if ($this->_storage === false) { $this->_stack->push(LIVEUSER_ERROR, 'exception', array('msg' => 'Could not instanciate storage container')); Hope it could help. Nicolas Kahn
 [2005-10-10 16:38 UTC] lsmith
Damn, I overlooked this. The problem is indeed that we need the conf array passed by ref, since it can contain object instances that require being pass by ref. Could you try the following: RCS file: /repository/pear/LiveUser/LiveUser.php,v retrieving revision 1.112 diff -w -b -r1.112 LiveUser.php 614c614,619 < unset($confArray[$key]); --- > $newConfArray = array(); > foreach ($confArray as $keyNew => $foo) { > if ($key !== $keyNew) { > $newConfArray[$keyNew] =& $confArray[$keyNew]; > } > } 616c621 < if ($storage->init($storageConf, $confArray) === false) { --- > if ($storage->init($storageConf, $newConfArray) === false) {
 [2005-10-12 16:51 UTC] lsmith
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.