Merge branch 'MDL-81246-403' of https://github.com/HuongNV13/moodle into MOODLE_403_STABLE

This commit is contained in:
Sara Arjona
2024-03-25 17:01:45 +01:00
2 changed files with 11 additions and 3 deletions
+3 -1
View File
@@ -680,9 +680,11 @@ class sqlsrv_native_moodle_database extends moodle_database {
* @return bool
*/
private function free_result($resource) {
if (!is_bool($resource)) { // true/false resources cannot be freed
if (!is_bool($resource) && is_resource($resource)) {
// We need to make sure that the statement resource is in the correct type before freeing it.
return sqlsrv_free_stmt($resource);
}
return false;
}
/**
+8 -2
View File
@@ -85,7 +85,10 @@ class sqlsrv_native_moodle_recordset extends moodle_recordset {
return false;
}
if (!$row = sqlsrv_fetch_array($this->rsrc, SQLSRV_FETCH_ASSOC)) {
sqlsrv_free_stmt($this->rsrc);
if (is_resource($this->rsrc)) {
// We need to make sure that the statement resource is in the correct type before freeing it.
sqlsrv_free_stmt($this->rsrc);
}
$this->rsrc = null;
$this->unregister();
return false;
@@ -133,7 +136,10 @@ class sqlsrv_native_moodle_recordset extends moodle_recordset {
public function close() {
if ($this->rsrc) {
sqlsrv_free_stmt($this->rsrc);
if (is_resource($this->rsrc)) {
// We need to make sure that the statement resource is in the correct type before freeing it.
sqlsrv_free_stmt($this->rsrc);
}
$this->rsrc = null;
}
$this->current = null;