mirror of
https://github.com/moodle/moodle.git
synced 2025-08-09 10:56:56 +02:00
Merge branch 'MDL-52544-master' of git://github.com/damyon/moodle
This commit is contained in:
commit
74ec2dd63d
3 changed files with 53 additions and 18 deletions
|
@ -138,8 +138,10 @@ class ADORecordset_oci8po extends ADORecordset_oci8 {
|
||||||
// 10% speedup to move MoveNext to child class
|
// 10% speedup to move MoveNext to child class
|
||||||
function MoveNext()
|
function MoveNext()
|
||||||
{
|
{
|
||||||
if(@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) {
|
$ret = @oci_fetch_array($this->_queryID,$this->fetchMode);
|
||||||
|
if($ret !== false) {
|
||||||
global $ADODB_ANSI_PADDING_OFF;
|
global $ADODB_ANSI_PADDING_OFF;
|
||||||
|
$this->fields = $ret;
|
||||||
$this->_currentRow++;
|
$this->_currentRow++;
|
||||||
$this->_updatefields();
|
$this->_updatefields();
|
||||||
|
|
||||||
|
@ -169,10 +171,12 @@ class ADORecordset_oci8po extends ADORecordset_oci8 {
|
||||||
$arr = array();
|
$arr = array();
|
||||||
return $arr;
|
return $arr;
|
||||||
}
|
}
|
||||||
if (!@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) {
|
$ret = @oci_fetch_array($this->_queryID,$this->fetchMode);
|
||||||
|
if ($ret === false) {
|
||||||
$arr = array();
|
$arr = array();
|
||||||
return $arr;
|
return $arr;
|
||||||
}
|
}
|
||||||
|
$this->fields = $ret;
|
||||||
$this->_updatefields();
|
$this->_updatefields();
|
||||||
$results = array();
|
$results = array();
|
||||||
$cnt = 0;
|
$cnt = 0;
|
||||||
|
@ -188,8 +192,9 @@ class ADORecordset_oci8po extends ADORecordset_oci8 {
|
||||||
{
|
{
|
||||||
global $ADODB_ANSI_PADDING_OFF;
|
global $ADODB_ANSI_PADDING_OFF;
|
||||||
|
|
||||||
$ret = @OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode);
|
$ret = @oci_fetch_array($this->_queryID,$this->fetchMode);
|
||||||
if ($ret) {
|
if ($ret) {
|
||||||
|
$this->fields = $ret;
|
||||||
$this->_updatefields();
|
$this->_updatefields();
|
||||||
|
|
||||||
if (!empty($ADODB_ANSI_PADDING_OFF)) {
|
if (!empty($ADODB_ANSI_PADDING_OFF)) {
|
||||||
|
@ -198,7 +203,7 @@ class ADORecordset_oci8po extends ADORecordset_oci8 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $ret;
|
return $ret !== false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,5 +27,6 @@ Our changes:
|
||||||
* Removed random seed initialization from lib/adodb/adodb.inc.php:216 (see 038f546 and MDL-41198).
|
* Removed random seed initialization from lib/adodb/adodb.inc.php:216 (see 038f546 and MDL-41198).
|
||||||
* MDL-52286 Added muting erros in ADORecordSet::__destruct().
|
* MDL-52286 Added muting erros in ADORecordSet::__destruct().
|
||||||
Check if fixed upstream during the next upgrade and remove this note.
|
Check if fixed upstream during the next upgrade and remove this note.
|
||||||
|
* MDL-52544 Pull upstream patch for php7 and ocipo.
|
||||||
|
|
||||||
skodak, iarenaza, moodler, stronk7, abgreeve
|
skodak, iarenaza, moodler, stronk7, abgreeve
|
||||||
|
|
|
@ -774,6 +774,8 @@ class oci_native_moodle_database extends moodle_database {
|
||||||
return ' ';
|
return ' ';
|
||||||
} else if (is_bool($value)) {
|
} else if (is_bool($value)) {
|
||||||
return (int)$value;
|
return (int)$value;
|
||||||
|
} else if (is_null($value)) {
|
||||||
|
return '';
|
||||||
} else {
|
} else {
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
@ -786,6 +788,8 @@ class oci_native_moodle_database extends moodle_database {
|
||||||
return ' ';
|
return ' ';
|
||||||
} else if (is_bool($value)) {
|
} else if (is_bool($value)) {
|
||||||
return (int)$value;
|
return (int)$value;
|
||||||
|
} else if (is_null($value)) {
|
||||||
|
return '';
|
||||||
} else {
|
} else {
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
@ -855,6 +859,9 @@ class oci_native_moodle_database extends moodle_database {
|
||||||
} else if (gettype($value) == 'integer') {
|
} else if (gettype($value) == 'integer') {
|
||||||
return '0'; // Transform 0 to '0' that evaluates the same for PHP
|
return '0'; // Transform 0 to '0' that evaluates the same for PHP
|
||||||
|
|
||||||
|
} else if (is_null($value)) {
|
||||||
|
return '';
|
||||||
|
|
||||||
} else if ($value === '') {
|
} else if ($value === '') {
|
||||||
return ' '; // Transform '' to ' ' that DON'T EVALUATE THE SAME
|
return ' '; // Transform '' to ' ' that DON'T EVALUATE THE SAME
|
||||||
// (we'll transform back again on get_records_XXX functions and others)!!
|
// (we'll transform back again on get_records_XXX functions and others)!!
|
||||||
|
@ -922,8 +929,7 @@ class oci_native_moodle_database extends moodle_database {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function bind_params($stmt, array $params=null, $tablename=null) {
|
protected function bind_params($stmt, array & $params=null, $tablename=null, array & $descriptors = null) {
|
||||||
$descriptors = array();
|
|
||||||
if ($params) {
|
if ($params) {
|
||||||
$columns = array();
|
$columns = array();
|
||||||
if ($tablename) {
|
if ($tablename) {
|
||||||
|
@ -943,15 +949,21 @@ class oci_native_moodle_database extends moodle_database {
|
||||||
if (is_array($value)) { // Let's go to bind special cases (lob descriptors)
|
if (is_array($value)) { // Let's go to bind special cases (lob descriptors)
|
||||||
if (isset($value['clob'])) {
|
if (isset($value['clob'])) {
|
||||||
$lob = oci_new_descriptor($this->oci, OCI_DTYPE_LOB);
|
$lob = oci_new_descriptor($this->oci, OCI_DTYPE_LOB);
|
||||||
|
if ($descriptors === null) {
|
||||||
|
throw new coding_exception('moodle_database::bind_params() $descriptors not specified for clob');
|
||||||
|
}
|
||||||
|
$descriptors[] = $lob;
|
||||||
oci_bind_by_name($stmt, $key, $lob, -1, SQLT_CLOB);
|
oci_bind_by_name($stmt, $key, $lob, -1, SQLT_CLOB);
|
||||||
$lob->writeTemporary($this->oracle_dirty_hack($tablename, $columnname, $params[$key]['clob']), OCI_TEMP_CLOB);
|
$lob->writeTemporary($this->oracle_dirty_hack($tablename, $columnname, $params[$key]['clob']), OCI_TEMP_CLOB);
|
||||||
$descriptors[] = $lob;
|
|
||||||
continue; // Column binding finished, go to next one
|
continue; // Column binding finished, go to next one
|
||||||
} else if (isset($value['blob'])) {
|
} else if (isset($value['blob'])) {
|
||||||
$lob = oci_new_descriptor($this->oci, OCI_DTYPE_LOB);
|
$lob = oci_new_descriptor($this->oci, OCI_DTYPE_LOB);
|
||||||
|
if ($descriptors === null) {
|
||||||
|
throw new coding_exception('moodle_database::bind_params() $descriptors not specified for clob');
|
||||||
|
}
|
||||||
|
$descriptors[] = $lob;
|
||||||
oci_bind_by_name($stmt, $key, $lob, -1, SQLT_BLOB);
|
oci_bind_by_name($stmt, $key, $lob, -1, SQLT_BLOB);
|
||||||
$lob->writeTemporary($params[$key]['blob'], OCI_TEMP_BLOB);
|
$lob->writeTemporary($params[$key]['blob'], OCI_TEMP_BLOB);
|
||||||
$descriptors[] = $lob;
|
|
||||||
continue; // Column binding finished, go to next one
|
continue; // Column binding finished, go to next one
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -961,9 +973,12 @@ class oci_native_moodle_database extends moodle_database {
|
||||||
// conditions and other raw SQLs not covered by the above function.
|
// conditions and other raw SQLs not covered by the above function.
|
||||||
if (strlen($value) > 4000) {
|
if (strlen($value) > 4000) {
|
||||||
$lob = oci_new_descriptor($this->oci, OCI_DTYPE_LOB);
|
$lob = oci_new_descriptor($this->oci, OCI_DTYPE_LOB);
|
||||||
|
if ($descriptors === null) {
|
||||||
|
throw new coding_exception('moodle_database::bind_params() $descriptors not specified for clob');
|
||||||
|
}
|
||||||
|
$descriptors[] = $lob;
|
||||||
oci_bind_by_name($stmt, $key, $lob, -1, SQLT_CLOB);
|
oci_bind_by_name($stmt, $key, $lob, -1, SQLT_CLOB);
|
||||||
$lob->writeTemporary($this->oracle_dirty_hack($tablename, $columnname, $params[$key]), OCI_TEMP_CLOB);
|
$lob->writeTemporary($this->oracle_dirty_hack($tablename, $columnname, $params[$key]), OCI_TEMP_CLOB);
|
||||||
$descriptors[] = $lob;
|
|
||||||
continue; // Param binding finished, go to next one.
|
continue; // Param binding finished, go to next one.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1009,6 +1024,7 @@ class oci_native_moodle_database extends moodle_database {
|
||||||
|
|
||||||
protected function free_descriptors($descriptors) {
|
protected function free_descriptors($descriptors) {
|
||||||
foreach ($descriptors as $descriptor) {
|
foreach ($descriptors as $descriptor) {
|
||||||
|
$descriptor->close();
|
||||||
oci_free_descriptor($descriptor);
|
oci_free_descriptor($descriptor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1045,8 +1061,10 @@ class oci_native_moodle_database extends moodle_database {
|
||||||
list($sql, $params) = $this->tweak_param_names($sql, $params);
|
list($sql, $params) = $this->tweak_param_names($sql, $params);
|
||||||
$this->query_start($sql, $params, SQL_QUERY_UPDATE);
|
$this->query_start($sql, $params, SQL_QUERY_UPDATE);
|
||||||
$stmt = $this->parse_query($sql);
|
$stmt = $this->parse_query($sql);
|
||||||
$this->bind_params($stmt, $params);
|
$descriptors = [];
|
||||||
|
$this->bind_params($stmt, $params, null, $descriptors);
|
||||||
$result = oci_execute($stmt, $this->commit_status);
|
$result = oci_execute($stmt, $this->commit_status);
|
||||||
|
$this->free_descriptors($descriptors);
|
||||||
$this->query_end($result, $stmt);
|
$this->query_end($result, $stmt);
|
||||||
oci_free_statement($stmt);
|
oci_free_statement($stmt);
|
||||||
|
|
||||||
|
@ -1109,8 +1127,10 @@ class oci_native_moodle_database extends moodle_database {
|
||||||
list($rawsql, $params) = $this->tweak_param_names($rawsql, $params);
|
list($rawsql, $params) = $this->tweak_param_names($rawsql, $params);
|
||||||
$this->query_start($rawsql, $params, SQL_QUERY_SELECT);
|
$this->query_start($rawsql, $params, SQL_QUERY_SELECT);
|
||||||
$stmt = $this->parse_query($rawsql);
|
$stmt = $this->parse_query($rawsql);
|
||||||
$this->bind_params($stmt, $params);
|
$descriptors = [];
|
||||||
|
$this->bind_params($stmt, $params, null, $descriptors);
|
||||||
$result = oci_execute($stmt, $this->commit_status);
|
$result = oci_execute($stmt, $this->commit_status);
|
||||||
|
$this->free_descriptors($descriptors);
|
||||||
$this->query_end($result, $stmt);
|
$this->query_end($result, $stmt);
|
||||||
|
|
||||||
return $this->create_recordset($stmt);
|
return $this->create_recordset($stmt);
|
||||||
|
@ -1144,8 +1164,10 @@ class oci_native_moodle_database extends moodle_database {
|
||||||
list($rawsql, $params) = $this->tweak_param_names($rawsql, $params);
|
list($rawsql, $params) = $this->tweak_param_names($rawsql, $params);
|
||||||
$this->query_start($rawsql, $params, SQL_QUERY_SELECT);
|
$this->query_start($rawsql, $params, SQL_QUERY_SELECT);
|
||||||
$stmt = $this->parse_query($rawsql);
|
$stmt = $this->parse_query($rawsql);
|
||||||
$this->bind_params($stmt, $params);
|
$descriptors = [];
|
||||||
|
$this->bind_params($stmt, $params, null, $descriptors);
|
||||||
$result = oci_execute($stmt, $this->commit_status);
|
$result = oci_execute($stmt, $this->commit_status);
|
||||||
|
$this->free_descriptors($descriptors);
|
||||||
$this->query_end($result, $stmt);
|
$this->query_end($result, $stmt);
|
||||||
|
|
||||||
$records = null;
|
$records = null;
|
||||||
|
@ -1183,8 +1205,10 @@ class oci_native_moodle_database extends moodle_database {
|
||||||
list($sql, $params) = $this->tweak_param_names($sql, $params);
|
list($sql, $params) = $this->tweak_param_names($sql, $params);
|
||||||
$this->query_start($sql, $params, SQL_QUERY_SELECT);
|
$this->query_start($sql, $params, SQL_QUERY_SELECT);
|
||||||
$stmt = $this->parse_query($sql);
|
$stmt = $this->parse_query($sql);
|
||||||
$this->bind_params($stmt, $params);
|
$descriptors = [];
|
||||||
|
$this->bind_params($stmt, $params, null, $descriptors);
|
||||||
$result = oci_execute($stmt, $this->commit_status);
|
$result = oci_execute($stmt, $this->commit_status);
|
||||||
|
$this->free_descriptors($descriptors);
|
||||||
$this->query_end($result, $stmt);
|
$this->query_end($result, $stmt);
|
||||||
|
|
||||||
$records = null;
|
$records = null;
|
||||||
|
@ -1241,16 +1265,17 @@ class oci_native_moodle_database extends moodle_database {
|
||||||
list($sql, $params, $type) = $this->fix_sql_params($sql, $params);
|
list($sql, $params, $type) = $this->fix_sql_params($sql, $params);
|
||||||
$sql .= $returning;
|
$sql .= $returning;
|
||||||
|
|
||||||
$id = null;
|
$id = 0;
|
||||||
|
|
||||||
// note we don't need tweak_param_names() here. Placeholders are safe column names. MDL-28080
|
// note we don't need tweak_param_names() here. Placeholders are safe column names. MDL-28080
|
||||||
// list($sql, $params) = $this->tweak_param_names($sql, $params);
|
// list($sql, $params) = $this->tweak_param_names($sql, $params);
|
||||||
$this->query_start($sql, $params, SQL_QUERY_INSERT);
|
$this->query_start($sql, $params, SQL_QUERY_INSERT);
|
||||||
$stmt = $this->parse_query($sql);
|
$stmt = $this->parse_query($sql);
|
||||||
$descriptors = $this->bind_params($stmt, $params, $table);
|
|
||||||
if ($returning) {
|
if ($returning) {
|
||||||
oci_bind_by_name($stmt, ":oracle_id", $id, 10, SQLT_INT);
|
oci_bind_by_name($stmt, ":oracle_id", $id, 10, SQLT_INT);
|
||||||
}
|
}
|
||||||
|
$descriptors = [];
|
||||||
|
$this->bind_params($stmt, $params, $table, $descriptors);
|
||||||
$result = oci_execute($stmt, $this->commit_status);
|
$result = oci_execute($stmt, $this->commit_status);
|
||||||
$this->free_descriptors($descriptors);
|
$this->free_descriptors($descriptors);
|
||||||
$this->query_end($result, $stmt);
|
$this->query_end($result, $stmt);
|
||||||
|
@ -1364,7 +1389,8 @@ class oci_native_moodle_database extends moodle_database {
|
||||||
// list($sql, $params) = $this->tweak_param_names($sql, $params);
|
// list($sql, $params) = $this->tweak_param_names($sql, $params);
|
||||||
$this->query_start($sql, $params, SQL_QUERY_UPDATE);
|
$this->query_start($sql, $params, SQL_QUERY_UPDATE);
|
||||||
$stmt = $this->parse_query($sql);
|
$stmt = $this->parse_query($sql);
|
||||||
$descriptors = $this->bind_params($stmt, $params, $table);
|
$descriptors = [];
|
||||||
|
$this->bind_params($stmt, $params, $table, $descriptors);
|
||||||
$result = oci_execute($stmt, $this->commit_status);
|
$result = oci_execute($stmt, $this->commit_status);
|
||||||
$this->free_descriptors($descriptors);
|
$this->free_descriptors($descriptors);
|
||||||
$this->query_end($result, $stmt);
|
$this->query_end($result, $stmt);
|
||||||
|
@ -1454,7 +1480,8 @@ class oci_native_moodle_database extends moodle_database {
|
||||||
list($sql, $params) = $this->tweak_param_names($sql, $params);
|
list($sql, $params) = $this->tweak_param_names($sql, $params);
|
||||||
$this->query_start($sql, $params, SQL_QUERY_UPDATE);
|
$this->query_start($sql, $params, SQL_QUERY_UPDATE);
|
||||||
$stmt = $this->parse_query($sql);
|
$stmt = $this->parse_query($sql);
|
||||||
$descriptors = $this->bind_params($stmt, $params, $table);
|
$descriptors = [];
|
||||||
|
$this->bind_params($stmt, $params, $table, $descriptors);
|
||||||
$result = oci_execute($stmt, $this->commit_status);
|
$result = oci_execute($stmt, $this->commit_status);
|
||||||
$this->free_descriptors($descriptors);
|
$this->free_descriptors($descriptors);
|
||||||
$this->query_end($result, $stmt);
|
$this->query_end($result, $stmt);
|
||||||
|
@ -1485,8 +1512,10 @@ class oci_native_moodle_database extends moodle_database {
|
||||||
list($sql, $params) = $this->tweak_param_names($sql, $params);
|
list($sql, $params) = $this->tweak_param_names($sql, $params);
|
||||||
$this->query_start($sql, $params, SQL_QUERY_UPDATE);
|
$this->query_start($sql, $params, SQL_QUERY_UPDATE);
|
||||||
$stmt = $this->parse_query($sql);
|
$stmt = $this->parse_query($sql);
|
||||||
$this->bind_params($stmt, $params);
|
$descriptors = [];
|
||||||
|
$this->bind_params($stmt, $params, null, $descriptors);
|
||||||
$result = oci_execute($stmt, $this->commit_status);
|
$result = oci_execute($stmt, $this->commit_status);
|
||||||
|
$this->free_descriptors($descriptors);
|
||||||
$this->query_end($result, $stmt);
|
$this->query_end($result, $stmt);
|
||||||
oci_free_statement($stmt);
|
oci_free_statement($stmt);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue