cvs: pear /DB package.xml /DB/DB fbsql.php ibase.php ifx.php msql.php mssql.php mysql.php mysqli.php oci8.php odbc.php sybase.php /DB/tests/driver
21freeResult.phpt

From: Date: Fri, 12 Jan 2007 03:11:18 +0000
Subject: cvs: pear /DB package.xml /DB/DB fbsql.php ibase.php ifx.php msql.php mssql.php mysql.php mysqli.php oci8.php odbc.php sybase.php /DB/tests/driver
21freeResult.phpt
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-44192@lists.php.net to get a copy of this message
aharvey Fri Jan 12 03:11:18 2007 UTC Added files: /pear/DB/tests/driver 21freeResult.phpt Modified files: /pear/DB package.xml /pear/DB/DB fbsql.php ibase.php ifx.php msql.php mssql.php mysql.php mysqli.php oci8.php odbc.php sybase.php Log: Changed all freeResult() methods to check that the parameter is a resource before calling the native function to free the result. Fixes bug #5762 (Empty getRow() result causes ocifreestatemet() error).

http://cvs.php.net/viewvc.cgi/pear/DB/package.xml?r1=1.218&r2=1.219&diff_format=u Index: pear/DB/package.xml diff -u pear/DB/package.xml:1.218 pear/DB/package.xml:1.219 --- pear/DB/package.xml:1.218 Fri Jan 12 02:46:59 2007 +++ pear/DB/package.xml Fri Jan 12 03:11:17 2007 @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="ISO-8859-1" ?> <package version="1.0"> - <!-- $Id: package.xml,v 1.218 2007/01/12 02:46:59 aharvey Exp $ --> + <!-- $Id: package.xml,v 1.219 2007/01/12 03:11:17 aharvey Exp $ --> <name>DB</name> <summary>Database Abstraction Layer</summary> <description> @@ -77,6 +77,8 @@ DSNs, thereby improving the output of DB::connect() on error. Bug 3759. * Added DB_common::nextQueryIsManip() to explicitly hint that the next query is a manipulation query and therefore ignore DB::isManip(). Bug 3895. +* Changed all freeResult() methods to check that the parameter is a resource + before calling the native function to free the result. Bug 5762. * Fixed DB_result::fetch*() to only increment their internal row_counters when a row number has not been provided. Bug 7502. * Fixed quoting of float values to always have the decimal point as a point, http://cvs.php.net/viewvc.cgi/pear/DB/DB/fbsql.php?r1=1.85&r2=1.86&diff_format=u Index: pear/DB/DB/fbsql.php diff -u pear/DB/DB/fbsql.php:1.85 pear/DB/DB/fbsql.php:1.86 --- pear/DB/DB/fbsql.php:1.85 Fri Jan 12 02:41:07 2007 +++ pear/DB/DB/fbsql.php Fri Jan 12 03:11:17 2007 @@ -20,7 +20,7 @@ * @author Daniel Convissor <danielc@php.net> * @copyright 1997-2005 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: fbsql.php,v 1.85 2007/01/12 02:41:07 aharvey Exp $ + * @version CVS: $Id: fbsql.php,v 1.86 2007/01/12 03:11:17 aharvey Exp $ * @link http://pear.php.net/package/DB */ @@ -320,7 +320,7 @@ */ function freeResult($result) { - return @fbsql_free_result($result); + return is_resource($result) ? fbsql_free_result($result) : false; } // }}} http://cvs.php.net/viewvc.cgi/pear/DB/DB/ibase.php?r1=1.112&r2=1.113&diff_format=u Index: pear/DB/DB/ibase.php diff -u pear/DB/DB/ibase.php:1.112 pear/DB/DB/ibase.php:1.113 --- pear/DB/DB/ibase.php:1.112 Fri Jan 12 02:41:07 2007 +++ pear/DB/DB/ibase.php Fri Jan 12 03:11:17 2007 @@ -23,7 +23,7 @@ * @author Daniel Convissor <danielc@php.net> * @copyright 1997-2005 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: ibase.php,v 1.112 2007/01/12 02:41:07 aharvey Exp $ + * @version CVS: $Id: ibase.php,v 1.113 2007/01/12 03:11:17 aharvey Exp $ * @link http://pear.php.net/package/DB */ @@ -413,7 +413,7 @@ */ function freeResult($result) { - return @ibase_free_result($result); + return is_resource($result) ? ibase_free_result($result) : false; } // }}} @@ -421,8 +421,7 @@ function freeQuery($query) { - @ibase_free_query($query); - return true; + return is_resource($query) ? ibase_free_query($query) : false; } // }}} http://cvs.php.net/viewvc.cgi/pear/DB/DB/ifx.php?r1=1.73&r2=1.74&diff_format=u Index: pear/DB/DB/ifx.php diff -u pear/DB/DB/ifx.php:1.73 pear/DB/DB/ifx.php:1.74 --- pear/DB/DB/ifx.php:1.73 Fri Jan 12 02:47:00 2007 +++ pear/DB/DB/ifx.php Fri Jan 12 03:11:17 2007 @@ -20,7 +20,7 @@ * @author Daniel Convissor <danielc@php.net> * @copyright 1997-2005 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: ifx.php,v 1.73 2007/01/12 02:47:00 aharvey Exp $ + * @version CVS: $Id: ifx.php,v 1.74 2007/01/12 03:11:17 aharvey Exp $ * @link http://pear.php.net/package/DB */ @@ -422,7 +422,7 @@ */ function freeResult($result) { - return @ifx_free_result($result); + return is_resource($result) ? ifx_free_result($result) : false; } // }}} http://cvs.php.net/viewvc.cgi/pear/DB/DB/msql.php?r1=1.61&r2=1.62&diff_format=u Index: pear/DB/DB/msql.php diff -u pear/DB/DB/msql.php:1.61 pear/DB/DB/msql.php:1.62 --- pear/DB/DB/msql.php:1.61 Fri Jan 12 02:41:07 2007 +++ pear/DB/DB/msql.php Fri Jan 12 03:11:17 2007 @@ -23,7 +23,7 @@ * @author Daniel Convissor <danielc@php.net> * @copyright 1997-2005 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: msql.php,v 1.61 2007/01/12 02:41:07 aharvey Exp $ + * @version CVS: $Id: msql.php,v 1.62 2007/01/12 03:11:17 aharvey Exp $ * @link http://pear.php.net/package/DB */ @@ -350,7 +350,7 @@ */ function freeResult($result) { - return @msql_free_result($result); + return is_resource($result) ? msql_free_result($result) : false; } // }}} http://cvs.php.net/viewvc.cgi/pear/DB/DB/mssql.php?r1=1.88&r2=1.89&diff_format=u Index: pear/DB/DB/mssql.php diff -u pear/DB/DB/mssql.php:1.88 pear/DB/DB/mssql.php:1.89 --- pear/DB/DB/mssql.php:1.88 Fri Jan 12 02:41:07 2007 +++ pear/DB/DB/mssql.php Fri Jan 12 03:11:17 2007 @@ -20,7 +20,7 @@ * @author Daniel Convissor <danielc@php.net> * @copyright 1997-2005 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: mssql.php,v 1.88 2007/01/12 02:41:07 aharvey Exp $ + * @version CVS: $Id: mssql.php,v 1.89 2007/01/12 03:11:17 aharvey Exp $ * @link http://pear.php.net/package/DB */ @@ -382,7 +382,7 @@ */ function freeResult($result) { - return @mssql_free_result($result); + return is_resource($result) ? mssql_free_result($result) : false; } // }}} http://cvs.php.net/viewvc.cgi/pear/DB/DB/mysql.php?r1=1.123&r2=1.124&diff_format=u Index: pear/DB/DB/mysql.php diff -u pear/DB/DB/mysql.php:1.123 pear/DB/DB/mysql.php:1.124 --- pear/DB/DB/mysql.php:1.123 Fri Jan 12 02:41:07 2007 +++ pear/DB/DB/mysql.php Fri Jan 12 03:11:17 2007 @@ -20,7 +20,7 @@ * @author Daniel Convissor <danielc@php.net> * @copyright 1997-2005 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: mysql.php,v 1.123 2007/01/12 02:41:07 aharvey Exp $ + * @version CVS: $Id: mysql.php,v 1.124 2007/01/12 03:11:17 aharvey Exp $ * @link http://pear.php.net/package/DB */ @@ -422,7 +422,7 @@ */ function freeResult($result) { - return @mysql_free_result($result); + return is_resource($result) ? mysql_free_result($result) : false; } // }}} http://cvs.php.net/viewvc.cgi/pear/DB/DB/mysqli.php?r1=1.77&r2=1.78&diff_format=u Index: pear/DB/DB/mysqli.php diff -u pear/DB/DB/mysqli.php:1.77 pear/DB/DB/mysqli.php:1.78 --- pear/DB/DB/mysqli.php:1.77 Fri Jan 12 02:41:07 2007 +++ pear/DB/DB/mysqli.php Fri Jan 12 03:11:17 2007 @@ -19,7 +19,7 @@ * @author Daniel Convissor <danielc@php.net> * @copyright 1997-2005 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: mysqli.php,v 1.77 2007/01/12 02:41:07 aharvey Exp $ + * @version CVS: $Id: mysqli.php,v 1.78 2007/01/12 03:11:17 aharvey Exp $ * @link http://pear.php.net/package/DB */ @@ -494,7 +494,7 @@ */ function freeResult($result) { - return @mysqli_free_result($result); + return is_resource($result) ? mysqli_free_result($result) : false; } // }}} http://cvs.php.net/viewvc.cgi/pear/DB/DB/oci8.php?r1=1.110&r2=1.111&diff_format=u Index: pear/DB/DB/oci8.php diff -u pear/DB/DB/oci8.php:1.110 pear/DB/DB/oci8.php:1.111 --- pear/DB/DB/oci8.php:1.110 Fri Jan 12 02:41:07 2007 +++ pear/DB/DB/oci8.php Fri Jan 12 03:11:17 2007 @@ -20,7 +20,7 @@ * @author Daniel Convissor <danielc@php.net> * @copyright 1997-2005 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: oci8.php,v 1.110 2007/01/12 02:41:07 aharvey Exp $ + * @version CVS: $Id: oci8.php,v 1.111 2007/01/12 03:11:17 aharvey Exp $ * @link http://pear.php.net/package/DB */ @@ -426,7 +426,7 @@ */ function freeResult($result) { - return @OCIFreeStatement($result); + return is_resource($result) ? OCIFreeStatement($result) : false; } /** http://cvs.php.net/viewvc.cgi/pear/DB/DB/odbc.php?r1=1.79&r2=1.80&diff_format=u Index: pear/DB/DB/odbc.php diff -u pear/DB/DB/odbc.php:1.79 pear/DB/DB/odbc.php:1.80 --- pear/DB/DB/odbc.php:1.79 Fri Jan 12 02:41:07 2007 +++ pear/DB/DB/odbc.php Fri Jan 12 03:11:17 2007 @@ -20,7 +20,7 @@ * @author Daniel Convissor <danielc@php.net> * @copyright 1997-2005 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: odbc.php,v 1.79 2007/01/12 02:41:07 aharvey Exp $ + * @version CVS: $Id: odbc.php,v 1.80 2007/01/12 03:11:17 aharvey Exp $ * @link http://pear.php.net/package/DB */ @@ -367,7 +367,7 @@ */ function freeResult($result) { - return @odbc_free_result($result); + return is_resource($result) ? odbc_free_result($result) : false; } // }}} http://cvs.php.net/viewvc.cgi/pear/DB/DB/sybase.php?r1=1.81&r2=1.82&diff_format=u Index: pear/DB/DB/sybase.php diff -u pear/DB/DB/sybase.php:1.81 pear/DB/DB/sybase.php:1.82 --- pear/DB/DB/sybase.php:1.81 Fri Jan 12 02:41:07 2007 +++ pear/DB/DB/sybase.php Fri Jan 12 03:11:17 2007 @@ -21,7 +21,7 @@ * @author Daniel Convissor <danielc@php.net> * @copyright 1997-2005 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: sybase.php,v 1.81 2007/01/12 02:41:07 aharvey Exp $ + * @version CVS: $Id: sybase.php,v 1.82 2007/01/12 03:11:17 aharvey Exp $ * @link http://pear.php.net/package/DB */ @@ -370,7 +370,7 @@ */ function freeResult($result) { - return @sybase_free_result($result); + return is_resource($result) ? sybase_free_result($result) : false; } // }}} http://cvs.php.net/viewvc.cgi/pear/DB/tests/driver/21freeResult.phpt?view=markup&rev=1.1 Index: pear/DB/tests/driver/21freeResult.phpt +++ pear/DB/tests/driver/21freeResult.phpt --TEST-- DB_driver::freeResult --INI-- error_reporting = 2047 --SKIPIF-- <?php chdir(dirname(__FILE__)); require_once './skipif.inc'; if ($dbh->phptype == 'mysqli') die ('skip mysqli returns result objects rather than resources'); ?> --FILE-- <?php require_once './mktable.inc'; $res = $dbh->query('SELECT * FROM phptest'); if (DB::isError($res)) { echo "Result is a DB_Error.\n"; } if (is_resource($res->result)) { echo "Result includes resource.\n"; } else { echo "Result does not include a resource!\n"; print_r($res->result); } if ($dbh->freeResult($res->result)) { echo "Resource was freed successfully.\n"; } else { echo "Error freeing result.\n"; } drop_table($dbh, 'phptest'); ?> --EXPECT-- Result includes resource. Resource was freed successfully.
« previous php.pear.cvs (#44192) next »