ZF-10069: setSubscription($data) always find $data in database

Issue Type: Bug Created: 2010-06-28T13:41:18.000+0000 Last Updated: 2010-06-30T13:56:41.000+0000 Status: Resolved Fix version(s): - 1.10.7 (28/Jul/10)

Reporter: Artur Adib (arturadib) Assignee: Ramon Henrique Ornelas (ramon) Tags: - Zend_Feed_Pubsubhubbub

Related issues: Attachments:


Under Zend/Feed/Pubsubhubbub/Model/Subscription.php one finds the function setSubscription($data) with code (line 54):

    $result = $this->_db->find($data['id']);
    if ($result) { ... }

At least in my application, where _db is a Mysqli interface, $result is always evaluated to true even if no rows are found.

Shouldn't the test be done instead with count()?

    $result = $this->_db->find($data['id']);
    if (count($result)>0) { ... }


Posted by Ramon Henrique Ornelas (ramon) on 2010-06-28T17:25:14.000+0000

This problem occur in all method of Zend_Feed_Pubsubhubbub_Model_Subscription. Because Zend_Db_Table:>find() returns Zend_Db_Table_Rowset.

In This case the condition always is true. Sample code.

<pre class="highlight">
//same what not exists row to $id past, object returns Zend_Db_Table_Rowset
$result = $this->_db->find($key); 
if ($result) {  // always is true
    return true;

Posted by Ramon Henrique Ornelas (ramon) on 2010-06-30T12:16:46.000+0000

Fixed in trunk r22507.

Posted by Ramon Henrique Ornelas (ramon) on 2010-06-30T13:56:39.000+0000

Merged to branch release-1.10 r22509

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.