ZF-3344: Leftover variable assignment in Zend_Db_Table_Row_Abstract causes E_NOTICE error


On line 976 of Zend_Db_Table_Row_Abstract (revision 9565), the variable $matchColumnName is assigned. However, it is never used anywhere else in the class, which leads me to believe it's a leftover of some earlier version of this procedure.

Ordinarily this would not be a problem; however, occasionally it produces an E_NOTICE-level error which, given careless error-reporting settings, could expose potentially sensitive information to the end user about the location of the ZF installation on the server.

This situation arises when two tables are related by a third intersection table; the caller table is related to the intersection table via two of its columns, while the match table is related to the intersection table via only one of its columns. E.g.,

class CallerTable extends Zend_Db_Table_Abstract
    protected $_primary = array('pk1', 'pk2');
    protected $_sequence = false;

class MatchTable extends Zend_Db_Table_Abstract
    protected $_primary = 'pk';

class InterTable extends Zend_Db_Table_Abstract
    protected $_primary = array('match_pk', 'caller_pk1', 'caller_pk2');
    protected $_sequence = false;
    protected $_referenceMap = array(
        'Match' => array(
            'columns'         => 'match_pk',
            'refTableClass'   => 'MatchTable',
            'refTableColumns' => 'pk'
        'Caller' => array(
            'columns'         => array('caller_pk1', 'caller_pk2'),
            'refTableClass'   => 'CallerTable',
            'refTableColumns' => array('pk1', 'pk2')

$callerTable = new CallerTable();
$callerRow = $callerTable->find('first-part-of-key', 'second-part')->current();
$matches = $callerRow->findManyToManyRowset('MatchTable', 'InterTable');

Although the $matches variable is correctly populated, the following E_NOTICE error is emitted: "Notice: Undefined offset: 1 in /path/to/Zend/Db/Table/Row/Abstract.php on line 976"

This issue could be easily resolved by removing line 976 of Zend_Db_Table_Row_Abstract. Since the variable assigned on that line is never used, the only result of this will be that the E_NOTICE error is no longer emitted.



Please evaluate and categorize/fix as necessary.

Fixed in r10407

Fixed for 1.5.3 at revision 10433