2009年2月4日星期三

[fw-db] Unable to post new issue on issue tracker?

I was going to post this as a new issue on the Issue Tracker, but I don't
seem to have permission to do it any more - can anyone else post new issues?

Anyway, issue description & proposed improvement below:

Description:
No error checking is done on Zend_Db_Table_Row_Abstract select() method.
This is an issue (at least for me) when you try to perform db-related
actions on a disconnected row object, e.g. when I instantiate an object
derived from Zend_Db_Table_Row_Abstract using
Zend_Auth::getInstance()->getStorage() and then call a method on it.

The error given is simply "Fatal error at Zend/Db/Table/Row/Abstract.php
line 398: method called on non-object". I believe that this is a common
error for developers, and that throwing an exception here would be extremely
helpful in debugging applications.


The fix is to alter the select() method to something like

/**
* Returns an instance of the parent table's Zend_Db_Table_Select
object.
*
* @return Zend_Db_Table_Select
*/
public function select()
{
if(!($this->getTable() instanceof Zend_Db_Table_Abstract))
{
throw new Zend_Db_Exception("getTable did not return a
Zend_Db_Table_Abstract object");
}
return $this->getTable()->select();
}

--
View this message in context: http://www.nabble.com/Unable-to-post-new-issue-on-issue-tracker--tp21827995p21827995.html
Sent from the Zend DB mailing list archive at Nabble.com.

没有评论: