1
0
mirror of https://github.com/php/php-src.git synced 2026-04-09 00:53:30 +02:00

fix the singleton and factory methods for

a). php 4.0.6 (where include_once might return false)
b). to use references and not copy so many objects
This commit is contained in:
Chuck Hagenbuch
2001-11-06 21:46:41 +00:00
parent 2c5764d46f
commit 352e52716a

View File

@@ -51,11 +51,13 @@ class Log {
* @return The newly created concrete Log instance, or an
* false on an error.
*/
function factory ($log_type, $log_name = '', $ident = '', $conf = array()) {
function &factory($log_type, $log_name = '', $ident = '', $conf = array())
{
$log_type = strtolower($log_type);
$classfile = 'Log/' . $log_type . '.php';
if (@include_once $classfile) {
$class = 'Log_' . $log_type;
@include_once $classfile;
$class = 'Log_' . $log_type;
if (class_exists($class)) {
return new $class($log_name, $ident, $conf);
} else {
return false;
@@ -101,7 +103,7 @@ class Log {
$signature = md5($log_type . '][' . $log_name . '][' . $ident . '][' . implode('][', $conf));
if (!isset($instances[$signature])) {
$instances[$signature] = Log::factory($log_type, $log_name, $ident, $conf);
$instances[$signature] = &Log::factory($log_type, $log_name, $ident, $conf);
}
return $instances[$signature];
}