Home » Authentication » LiveUser » Bug #5526
init failed error after modifying code
Details
| 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) |
Comments
[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',
),
)
),
),
);
[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