Home » Authentication » LiveUser » Bug #5669
new singleton could preserve BC
Details
| Request #5669 | new singleton could preserve BC |
|---|---|
| Submitted | 2005-10-12 08:30 UTC |
| From | jeroen at terena dot nl |
| Assigned | lsmith |
| Status | Closed |
| Package | LiveUser |
| PHP Version | 5.0.5 |
| OS | debian |
| Roadmaps | (Not assigned) |
Comments
[2005-10-12 08:30 UTC] jeroen at terena dot nl
Description:
------------
Moving from 0.16.6 to 0.16.7 breaks BC in the singleton method
Test script:
---------------
$lu = Liveuser::singleton($conf) does not return an instance anymore
I think you could do this by changing the method slightly:
function &singleton(&$conf, $signature = null)
{
static $instances;
if (!isset($instances)) {
$instances = array();
}
if (is_null($signature)) {
if (empty($instances)) {
$signature = uniqid(); //or some other default string
} else {
$signature = key($instances);
}
} elseif (!array_key_exists($signature, $instances)) {
$instances[$signature] =& LiveUser::factory($conf);
}
return $instances[$signature];
}
This would create a default signature and I think BC could be preserved this way.
Expected result:
----------------
Liveuser object returned
Actual result:
--------------
returns false