ZF-8190: Undefined variable in Zend_Db_Select

Issue Type: Bug Created: 2009-10-30T08:55:29.000+0000 Last Updated: 2009-11-19T20:41:10.000+0000 Status: Resolved Fix version(s): - 1.9.6 (24/Nov/09)

Reporter: Luiz Damim (luizvd) Assignee: Satoru Yoshida (satoruyoshida) Tags: - Zend_Db_Select

Related issues: - ZF-8114

Attachments: - patch.diff


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

( ! ) Notice: Undefined variable: lastFromCorrelationName in /data/html/ on line 840

To reproduce:

<pre class="literal">
$adapter = Zend_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 810, inside an if statement, but is used outside it, on line 840.

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

Tested in trunk and the bug is still present.


Posted by Luiz Damim (luizvd) on 2009-10-30T08:57:17.000+0000

Attaching the patch to solve this issue.

Posted by Satoru Yoshida (satoruyoshida) on 2009-10-30T18:01:39.000+0000

Solved in SVN r18750(trunk), r18751(1.9branch)

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.