2009年10月27日星期二

[fw-db] Undefined variable in Zend_Db_Select

Sorry, I did hit Send too early.

The changes in Zend_Db_Select in release 1.9.4 started to cause an undefined variable notice:

( ! ) Notice: Undefined variable: lastFromCorrelationName in /data/html/vilagenet.com.br/library/Zend/Db/Select.php on line 828

To reproduce:
$adapter = Vilage_Db_Table::getDefaultAdapter();
$select = $adapter->select()
    ->from('sometable', 'id');

$select2 = $adapter->select()
    ->from(null, 'COUNT(*) FROM (' . $select->__toString() . ') AS count');

$result = $adapter->fetchCol($select2);

The variable $lastFromCorrelationName is declared in Zend_Db_Select on line 798, inside an `if` statement, but is used outside it, on line 828.

Moving the declaration to just outside the `if` (line 789) corrects the problem, and all unit tests still pass.

This is a bug or this is the intended behaviour, and I´m using the component in a subverted way?

Thanks in advance.

没有评论: