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 » Logging » Log » Bug #5658

LOG 0.9.0 breaks __autoload

Details

Submitted2005-10-11 16:41 UTC
Fromnick dot locking at gmail dot com
Assignedjon
StatusClosed
PackageLog
PHP Version5.0.4
OSTrustix 2.1
Roadmaps(Not assigned)

Comments

[2005-10-11 16:41 UTC] nick dot locking at gmail dot com

Description:
------------
When I use __autoload in conjunction with Log, an upgrade to the new version breaks it completely - it seems to attempt an autoload first and then try and get its own PEAR classes, which fails ungracefully, but only, seemingly, with the SQL handler.

Test script:
---------------
require_once("Log.php");
require_once('DB.php');

// Automatically load classes.
function __autoload($className) {
require_once(INCLUDES_DIR.'/class_'.strtolower($className).'.php');
}

$logDB = Log::singleton('sql', 'log', 'username', array("db"=>$dbObjConnection));

Expected result:
----------------
Nothing!

Actual result:
--------------
An error claiming PHP can't include the file, generated from my autoload function - so it's not finding the class and is attempting to autoload it. I've seen another possibly similar bug, #3197, which could be related, claiming that an is_a check is what causes the error, although I'm not sure if this is the case.

[2005-10-24 11:08 UTC] nick dot locking at gmail dot com

This might not be autoload related after all - here's some sample code:

----------------------------------
/* PEAR stuff - should be in include-path */
require_once("Log.php");
require_once('DB.php');

// Get the database config constants.
require_once('_sitemaker_config.php');

// Attempt to create a PEAR::Log object.
if (!$LOG=Log::singleton('composite')) die('Failed to create Log object.');

/* Create DB connection */
$dbobj = DB::connect("mysql://" . DB_USER . ":" . DB_PASS . "@" . DB_HOSTNAME . "/" . DB_NAME);

// Add a DB logger to the Log object.
$logDB = Log::singleton('sql', 'log', 'logident', array("db"=>$dbobj), PEAR_LOG_DEBUG);
$LOG->addChild($logDB);

// Produce the error.
$LOG->log('Test!', PEAR_LOG_CRIT);
die();
------------------------------------------

And here's what it produces:

Notice: Undefined offset: 0 in /usr/lib/php/DB/common.php on line 993

Notice: Undefined offset: 0 in /usr/lib/php/DB/common.php on line 994

[2005-10-24 16:08 UTC] nick dot locking at gmail dot com

Jon,

You're right - it was the existing DB connection issue. I replaced the DB object with a DSN and it worked perfectly. Thanks!