Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.10.16

Bug #7075 PEAR_PackageFile_v2 :: setLogger failed on autodetection
Submitted: 2006-03-09 15:42 UTC
From: farell Assigned: cellog
Status: Closed Package: PEAR (version 1.4.8)
PHP Version: 4.4.2 OS: Windows XP
Roadmaps: (Not assigned)    
Subscription  


 [2006-03-09 15:42 UTC] farell (Laurent Laville)
Description: ------------ While i tried to implement a setLogger based solution for my own purpose, i find a strange behavior on PHP 4.4.2 See setLogger() method lines 736-742 on file [...]PEAR\PackageFile\v2.php CVS: $Id: v2.php,v 1.129 2006/02/04 00:27:58 cellog Exp $ See also test script and compare results between PHP 4.4.2 and PHP 5.1.2 Test script: --------------- <?php class logger { function logger() { } function logFoo() { } } $logger = new logger(); if (method_exists($logger, 'log')) { var_dump('method_exists :: log'); } if ($logger && (!is_object($logger))) { var_dump('method_exists 1'); } if ((!is_object($logger) || !method_exists($logger, 'log'))) { var_dump('method_exists 2'); } if ($logger && (!is_object($logger) || !method_exists($logger, 'log'))) { var_dump('method_exists 3'); } if (isset($logger) && (!is_object($logger) || !method_exists($logger, 'log'))) { var_dump('method_exists 4'); } ?> Expected result: ---------------- string(15) "method_exists 2" string(15) "method_exists 3" string(15) "method_exists 4" Actual result: -------------- with PHP 5.1.2 string(15) "method_exists 2" string(15) "method_exists 3" string(15) "method_exists 4" with PHP 4.4.2 string(15) "method_exists 2" string(15) "method_exists 4"

Comments

 [2006-03-23 04:05 UTC] cellog (Greg Beaver)
this is a bug in PHP, please report it ASAP. The problem is that (bool) $logger is false if $logger has no properties. To prove this, modify your test script by adding this after the new logger() call: $logger->a = 1; and it will work the same way in PHP 4 and PHP 5
 [2006-03-23 04:09 UTC] cellog (Greg Beaver)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.