PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Authentication » LiveUser » Bug #5669

new singleton could preserve BC

Details

Request #5669new singleton could preserve BC
Submitted2005-10-12 08:30 UTC
Fromjeroen at terena dot nl
Assignedlsmith
StatusClosed
PackageLiveUser
PHP Version5.0.5
OSdebian
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