MDL-52544 oracle: Apply upstream pull request to AdoDB oracle driver
authorDamyon Wiese <damyon@moodle.com>
Tue, 12 Jul 2016 08:44:23 +0000 (16:44 +0800)
committerDamyon Wiese <damyon@moodle.com>
Wed, 13 Jul 2016 00:45:06 +0000 (08:45 +0800)
Upstream: https://github.com/ADOdb/ADOdb/pull/259

Prevent segfault with ocipo driver on php7.

The OCIFetchinto function is causing segfaults on php7 - probably because the fields array
is not initialised or it is optimised out. This fixes just changes to use the safer function
oci_fetch_array instead.

lib/adodb/drivers/adodb-oci8po.inc.php
lib/adodb/readme_moodle.txt

index 7c6049b..15e89fb 100644 (file)
@@ -138,8 +138,10 @@ class ADORecordset_oci8po extends ADORecordset_oci8 {
        // 10% speedup to move MoveNext to child class
        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;
+                       $this->fields = $ret;
                        $this->_currentRow++;
                        $this->_updatefields();
 
@@ -169,10 +171,12 @@ class ADORecordset_oci8po extends ADORecordset_oci8 {
                                $arr = array();
                                return $arr;
                        }
-               if (!@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) {
+               $ret = @oci_fetch_array($this->_queryID,$this->fetchMode);
+               if ($ret === false) {
                        $arr = array();
                        return $arr;
                }
+               $this->fields = $ret;
                $this->_updatefields();
                $results = array();
                $cnt = 0;
@@ -188,8 +192,9 @@ class ADORecordset_oci8po extends ADORecordset_oci8 {
        {
                global $ADODB_ANSI_PADDING_OFF;
 
-               $ret = @OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode);
+               $ret = @oci_fetch_array($this->_queryID,$this->fetchMode);
                if ($ret) {
+                       $this->fields = $ret;
                        $this->_updatefields();
 
                        if (!empty($ADODB_ANSI_PADDING_OFF)) {
@@ -198,7 +203,7 @@ class ADORecordset_oci8po extends ADORecordset_oci8 {
                                }
                        }
                }
-               return $ret;
+               return $ret !== false;
        }
 
 }
index a088b63..a2590c6 100644 (file)
@@ -27,5 +27,6 @@ Our changes:
  * Removed random seed initialization from lib/adodb/adodb.inc.php:216 (see 038f546 and MDL-41198).
  * MDL-52286 Added muting erros in ADORecordSet::__destruct().
    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