[Vtigercrm-developers] [PATCH] PearDatabase.php sanity check in Move()

Philip philip at vtiger.com
Fri May 11 03:29:36 PDT 2007


Hi Enrico,

When tested the code i had the following exception thrown in the screen.

*Fatal error*: Uncaught exception 'Exception' with message 'given result 
set is not an object' in 
/home/crm-test3/donot_delete/vtigerCRM5/apache/htdocs/vtigerCRM/include/database/PearDatabase.php:442 
Stack trace: #0 
/home/crm-test3/donot_delete/vtigerCRM5/apache/htdocs/vtigerCRM/modules/Potentials/ListView.php(183): 
PearDatabase->query_result(false, 0, 'count') #1 
/home/crm-test3/donot_delete/vtigerCRM5/apache/htdocs/vtigerCRM/modules/Potentials/index.php(29): 
include('/home/crm-test3...') #2 
/home/crm-test3/donot_delete/vtigerCRM5/apache/htdocs/vtigerCRM/include/Ajax/CommonAjax.php(12): 
require_once('/home/crm-test3...') #3 
/home/crm-test3/donot_delete/vtigerCRM5/apache/htdocs/vtigerCRM/modules/Potentials/PotentialsAjax.php(11): 
require_once('/home/crm-test3...') #4 
/home/crm-test3/donot_delete/vtigerCRM5/apache/htdocs/vtigerCRM/index.php(582): 
include('/home/crm-test3...') #5 {main} thrown in 
*/home/crm-test3/donot_delete/vtigerCRM5/apache/htdocs/vtigerCRM/include/database/PearDatabase.php* 
on line *442


*So where should i catch this exception.

Regards,
Philip

Enrico Weigelt wrote:
> Hi folks,
>
> as we sometimes get some errors like:
>
> # Fatal error: Call to a member function Move() on a non-object 
> # in .../include/database/PearDatabase.php on line 443
>
> Obviously sometimes the query_result() method is called with an
> non-existing result object.
>
> This patch adds an check which throws an exception on missing 
> result object, so we can easily track it down.
>
>
> cu
>   
> ------------------------------------------------------------------------
>
> diff -ruN htdocs.orig/include/database/PearDatabase.php htdocs/include/database/PearDatabase.php
> --- htdocs.orig/include/database/PearDatabase.php	2007-05-09 00:56:24.000000000 +0200
> +++ htdocs/include/database/PearDatabase.php	2007-05-11 01:51:08.000000000 +0200
> @@ -438,6 +438,8 @@
>      function query_result(&$result, $row, $col=0)
>      {		
>  	//$this->println("ADODB query_result r=".$row." c=".$col);
> +	if (!is_object($result))
> +	    throw new Exception("result is not an object");
>  	$result->Move($row);
>  	$rowdata = $this->change_key_case($result->FetchRow());
>  	//$this->println($rowdata);
>   
> ------------------------------------------------------------------------
>
> _______________________________________________
> Reach hundreds of potential candidates - http://jobs.vtiger.com 




More information about the vtigercrm-developers mailing list