cvs: pear /Log/Log composite.php
| From: | Jon Parise | Date: | Thu, 03 Apr 2003 07:23:47 +0000 |
| Subject: | cvs: pear /Log/Log composite.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-9714@lists.php.net to get a copy of this message | ||
jon Thu Apr 3 02:23:47 2003 EDT
Modified files:
/pear/Log/Log composite.php
Log:
- Remove unnecessary calls to reset(); foreach() resets the array index.
- Ensure that objects passed to addChild() are Log instances.
- Make removeChild() return a boolean result.
Index: pear/Log/Log/composite.php
diff -u pear/Log/Log/composite.php:1.9 pear/Log/Log/composite.php:1.10
--- pear/Log/Log/composite.php:1.9 Thu Apr 3 01:24:46 2003
+++ pear/Log/Log/composite.php Thu Apr 3 02:23:47 2003
@@ -1,5 +1,5 @@
<?php
-// $Id: composite.php,v 1.9 2003/04/03 06:24:46 jon Exp $
+// $Id: composite.php,v 1.10 2003/04/03 07:23:47 jon Exp $
// $Horde: horde/lib/Log/composite.php,v 1.2 2000/06/28 21:36:13 jon Exp $
/**
@@ -8,7 +8,7 @@
*
* @author Chuck Hagenbuch <chuck@horde.org>
* @author Jon Parise <jon@php.net>
- * @version $Revision: 1.9 $
+ * @version $Revision: 1.10 $
* @since Horde 1.3
* @package Log
*/
@@ -47,7 +47,6 @@
function open()
{
if (!$this->_opened) {
- reset($this->_children);
foreach ($this->_children as $child) {
$child->open();
}
@@ -62,7 +61,6 @@
function close()
{
if ($this->_opened) {
- reset($this->_children);
foreach ($this->_children as $child) {
$child->close();
}
@@ -87,7 +85,6 @@
*/
function log($message, $priority = PEAR_LOG_INFO)
{
- reset($this->_children);
foreach ($this->_children as $child) {
$child->log($message, $priority);
}
@@ -120,12 +117,12 @@
*/
function addChild(&$child)
{
- if (!is_object($child)) {
+ /* Make sure this is a Log instance. */
+ if (!is_a($child, 'Log')) {
return false;
}
$child->_childID = uniqid(rand());
-
$this->_children[$child->_childID] = &$child;
return true;
@@ -136,13 +133,19 @@
*
* @param object $child The Log instance to remove.
*
+ * @return boolean True if the Log instance was successfully removed.
+ *
* @access public
*/
function removeChild($child)
{
- if (isset($this->_children[$child->_childID])) {
- unset($this->_children[$child->_childID]);
+ if (!isset($this->_children[$child->_childID])) {
+ return false;
}
+
+ unset($this->_children[$child->_childID]);
+
+ return true;
}
}