From 352e52716ae1245686c0a4737a027cd1ea90f71b Mon Sep 17 00:00:00 2001 From: Chuck Hagenbuch Date: Tue, 6 Nov 2001 21:46:41 +0000 Subject: [PATCH] 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 --- pear/Log.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pear/Log.php b/pear/Log.php index f4c029c002b..1df0928f535 100644 --- a/pear/Log.php +++ b/pear/Log.php @@ -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]; }