Zend Framework

setSubscription($data) always find $data in database

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.10.4
  • Fix Version/s: 1.10.7
  • Component/s: Zend_Feed_Pubsubhubbub
  • Labels:
    None

Description

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) { ... }

Activity

Hide
Ramon Henrique Ornelas added a comment -

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.

//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;
}
Show
Ramon Henrique Ornelas added a comment - 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.
//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;
}
Hide
Ramon Henrique Ornelas added a comment -

Fixed in trunk r22507.

Show
Ramon Henrique Ornelas added a comment - Fixed in trunk r22507.
Hide
Ramon Henrique Ornelas added a comment -

Merged to branch release-1.10 r22509

Show
Ramon Henrique Ornelas added a comment - Merged to branch release-1.10 r22509

People

Vote (1)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: