MDL-52286 core: several fixes to ADOdb

This commit is contained in:
Marina Glancy 2015-12-14 11:01:53 +08:00
parent bca69f937c
commit cc3048eb41
5 changed files with 23 additions and 3 deletions

View file

@ -381,4 +381,22 @@ class auth_db_testcase extends advanced_testcase {
$this->cleanup_auth_database();
}
/**
* Testing the function _colonscope() from ADOdb.
*/
public function test_adodb_colonscope() {
global $CFG;
require_once($CFG->libdir.'/adodb/adodb.inc.php');
require_once($CFG->libdir.'/adodb/drivers/adodb-odbc.inc.php');
require_once($CFG->libdir.'/adodb/drivers/adodb-db2ora.inc.php');
$this->resetAfterTest(false);
$sql = "select * from table WHERE column=:1 AND anothercolumn > :0";
$arr = array('b', 1);
list($sqlout, $arrout) = _colonscope($sql,$arr);
$this->assertEquals("select * from table WHERE column=? AND anothercolumn > ?", $sqlout);
$this->assertEquals(array(1, 'b'), $arrout);
}
}

View file

@ -38,7 +38,7 @@ global $_COLONARR,$_COLONSZ;
$_COLONARR = array();
$_COLONSZ = sizeof($arr);
$sql2 = preg_replace("/(:[0-9]+)/e","_colontrack('\\1')",$sql);
$sql2 = preg_replace_callback('/(:[0-9]+)/', create_function('$m', 'return _colontrack($m[0]);'), $sql);
if (empty($_COLONARR)) return array($sql,$arr);

View file

@ -1050,7 +1050,7 @@ class ADORecordSet_mysqli extends ADORecordSet{
//if results are attached to this pointer from Stored Proceedure calls, the next standard query will die 2014
//only a problem with persistant connections
while(mysqli_more_results($this->connection->_connectionID)){
while (@mysqli_more_results($this->connection->_connectionID)) {
@mysqli_next_result($this->connection->_connectionID);
}

View file

@ -130,7 +130,7 @@ class ADORecordSet_mysqlt extends ADORecordSet_mysql{
class ADORecordSet_ext_mysqlt extends ADORecordSet_mysqlt {
function ADORecordSet_ext_mysqlt($queryID,$mode=false)
function __construct($queryID,$mode=false)
{
parent::__construct($queryID,$mode);
}

View file

@ -24,5 +24,7 @@ Added:
Our changes:
* Removed random seed initialization from lib/adodb/adodb.inc.php:216 (see 038f546 and MDL-41198).
* MDL-52286 fixed usage of /e in preg_replace, incorrect constructor in ADORecordSet_ext_mysqlt
and ADORecordSet_mysqli::_close(). Check if fixed upstream during the next upgrade and remove this line.
skodak, iarenaza, moodler, stronk7