From df45eb5af672d6c5e22f5e0afe193d461895c4f5 Mon Sep 17 00:00:00 2001 From: Roly Rudy Gutierrez Pinto Date: Fri, 11 Oct 2019 07:49:19 -0400 Subject: [PATCH] PMC-1002 Error message: "mysql_free_result() couldnt fetch mysql_result" in appears in the _ERROR_ variable --- thirdparty/creole/drivers/mssql/MSSQLResultSet.php | 6 ++++-- thirdparty/creole/drivers/mysqli/MySQLiResultSet.php | 7 ++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/thirdparty/creole/drivers/mssql/MSSQLResultSet.php b/thirdparty/creole/drivers/mssql/MSSQLResultSet.php index b66008179..f9c2f1330 100644 --- a/thirdparty/creole/drivers/mssql/MSSQLResultSet.php +++ b/thirdparty/creole/drivers/mssql/MSSQLResultSet.php @@ -171,10 +171,12 @@ class MSSQLResultSet extends ResultSetCommon implements ResultSet /** * @see ResultSet::close() */ - function close() + public function close() { if (extension_loaded('sqlsrv')) { - $ret = @sqlsrv_free_stmt($this->result); + if (is_resource($this->result)) { + $ret = @sqlsrv_free_stmt($this->result); + } } else { $ret = @mssql_free_result($this->result); } diff --git a/thirdparty/creole/drivers/mysqli/MySQLiResultSet.php b/thirdparty/creole/drivers/mysqli/MySQLiResultSet.php index 4a2f104c6..cb8dd29b8 100644 --- a/thirdparty/creole/drivers/mysqli/MySQLiResultSet.php +++ b/thirdparty/creole/drivers/mysqli/MySQLiResultSet.php @@ -98,7 +98,12 @@ class MySQLiResultSet extends ResultSetCommon implements ResultSet { */ public function close() { - if ($this->result instanceof mysqli_result) { + /** + * This is not a definitive solution because there are several behaviors + * reported to use the "mysqli_free_result()" function, see + * https://bugs.php.net/bug.php?id=63486 + */ + if ($this->result instanceof mysqli_result && isset($this->result->lengths)) { @mysqli_free_result($this->result); } $this->fields = array();