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 » Database » DB_DataObject » Bug #5614

Insufficient parameter checking in joinAdd()

Details

Request #5614Insufficient parameter checking in joinAdd()
Submitted2005-10-06 05:54 UTC
Frommarkus at fischer dot name
Assignedalan_k
StatusClosed
PackageDB_DataObject
PHP Version4.3.10
OSAny
Roadmaps(Not assigned)

Comments

[2005-10-06 05:54 UTC] markus at fischer dot name

Description:
------------
The method joinAdd() doesn't verify if the object passed is a DB_DataObject.

It only verifies if it is an object:
if (!is_object($obj)) {
$this->raiseError("joinAdd: called without an object", DB_DATAOBJECT_ERROR_NODATA,PEAR_ERROR_DIE);
}

but assumed it's an DB_DataObject because it calls the ->links() method:

if (!$ofield && ($olinks = $obj->links())) {

The check should make sure it's a valid DB_DataObject (is_subclass_of) and not just an object.

Test script:
---------------
$oTable1 =& DB_DataObject::factory("table1");
$oTableUnknown =& DB_DataObject::factory("someunknowntable");
$oTable1->joinAdd($oTableUnknown, "INNER");

Expected result:
----------------
An error should be raised.

Actual result:
--------------
Bails out with a fatal error:

Fatal error: Call to undefined function: links() in /data/www/webroot/pear/share/php/DB/DataObject.php on line 2899