Commit ac9e5527 authored by Aaron Wells's avatar Aaron Wells

Upgrade our ADODB driver from the long-obsolete mysql driver to the actively...

Upgrade our ADODB driver from the long-obsolete mysql driver to the actively developed mysqli driver

Bug 1187964: The biggest improvement is that the ADODB mysqli driver actually supports transactions!

Change-Id: I8e55ea28cd6e6b8ed5c883646c1172d318af5554
parent 14298751
......@@ -45,9 +45,9 @@ $cfg = new stdClass();
/**
* database connection details
* valid values for dbtype are 'postgres8' and 'mysql5'
* valid values for dbtype are 'postgres' and 'mysql'
*/
$cfg->dbtype = 'postgres8';
$cfg->dbtype = 'postgres';
$cfg->dbhost = 'localhost';
$cfg->dbport = null;
$cfg->dbname = '';
......
......@@ -120,13 +120,20 @@ try {
// the error is instead.
ob_start();
// Transform $CFG->dbtype into the name of the ADODB driver we will use
if (is_postgres()) {
$CFG->dbtype = 'postgres7';
}
else if (is_mysql()) {
$CFG->dbtype = 'mysql';
// If they have mysqli, use it. Otherwise, fall back to the older "mysql" extension.
if (extension_loaded('mysqli')) {
$CFG->dbtype = 'mysqli';
}
else {
$CFG->dbtype = 'mysql';
}
}
$db = &ADONewConnection($CFG->dbtype);
if (empty($CFG->dbhost)) {
$CFG->dbhost = '';
......
......@@ -31,8 +31,8 @@ defined('INTERNAL') || die();
$string['phpversion'] = 'Mahara will not run on PHP < %s. Please upgrade your PHP version or move Mahara to a different host.';
$string['jsonextensionnotloaded'] = 'Your server configuration does not include the JSON extension. Mahara requires this in order to send some data to and from the browser. Please make sure that it is loaded in php.ini or install it if it is not installed.';
$string['pgsqldbextensionnotloaded'] = 'Your server configuration does not include the pgsql extension. Mahara requires this in order to store data in a relational database. Please make sure that it is loaded in php.ini or install it if it is not installed.';
$string['mysqldbextensionnotloaded'] = 'Your server configuration does not include the mysql extension. Mahara requires this in order to store data in a relational database. Please make sure that it is loaded in php.ini or install it if it is not installed.';
$string['unknowndbtype'] = 'Your server configuration references an unknown database type. Valid values are "postgres8" and "mysql5". Please change the database type setting in config.php.';
$string['mysqldbextensionnotloaded'] = 'Your server configuration does not include the mysqli or mysql extension. Mahara requires this in order to store data in a relational database. Please make sure that it is loaded in php.ini or install it if it is not installed.';
$string['unknowndbtype'] = 'Your server configuration references an unknown database type. Valid values are "postgres" and "mysql". Please change the database type setting in config.php.';
$string['domextensionnotloaded'] = 'Your server configuration does not include the dom extension. Mahara requires this in order to parse XML data from a variety of sources.';
$string['xmlextensionnotloaded'] = 'Your server configuration does not include the %s extension. Mahara requires this in order to parse XML data from a variety of sources. Please make sure that it is loaded in php.ini or install it if it is not installed.';
$string['gdextensionnotloaded'] = 'Your server configuration does not include the gd extension. Mahara requires this in order to perform resizes and other operations on uploaded images. Please make sure that it is loaded in php.ini or install it if it is not installed.';
......@@ -135,7 +135,7 @@ $string['timezoneidentifierunusable'] = 'PHP on your website host does not retur
$string['postmaxlessthanuploadmax'] = 'Your PHP post_max_size setting (%s) is smaller than your upload_max_filesize setting (%s). Uploads larger than %s will fail without displaying an error. Usually, post_max_size should be much larger than upload_max_filesize.';
$string['smallpostmaxsize'] = 'Your PHP post_max_size setting (%s) is very small. Uploads larger than %s will fail without displaying an error.';
$string['notenoughsessionentropy'] = 'Your PHP session.entropy_length setting is too small. Set it to at least 16 in your php.ini to ensure that generated session IDs are random and unpredictable enough.';
$string['switchtomysqli'] = 'The <strong>mysqli</strong> PHP extension is not installed on your server, so Mahara is falling back to the deprecated original <strong>mysql</strong> PHP extension. We recommend installing <a href="http://php.net/manual/en/book.mysqli.php">mysqli</a>.';
$string['noreplyaddressmissingorinvalid'] = 'The noreply address setting is either empty or has an invalid email address. Please check the configuration in the <a href="%s">site options in the email settings</a>.';
$string['openbasedirenabled'] = 'Your server has the php open_basedir restriction enabled.';
$string['openbasedirpaths'] = 'Mahara can only open files within the following path(s): %s.';
......
......@@ -843,7 +843,7 @@ class ActivityTypeWatchlist extends ActivityType {
// mysql compatibility (sigh...)
$casturl = 'CAST(? AS TEXT)';
if (get_config('dbtype') == 'mysql') {
if (is_mysql()) {
$casturl = 'CAST(? AS CHAR)'; // note, NOT varchar
}
$sql = 'SELECT u.*, p.method, ap.value AS lang, ' . $casturl . ' AS url
......
This diff is collapsed.
......@@ -119,6 +119,7 @@ function table_column($table, $oldfield, $field, $type='integer', $size='10',
case 'mysql':
case 'mysqlt':
case 'mysqli':
switch (strtolower($type)) {
case 'text':
......
......@@ -45,13 +45,15 @@ function ensure_sanity() {
throw new ConfigSanityException(get_string('jsonextensionnotloaded', 'error'));
}
switch (get_config('dbtype')) {
case 'postgres8':
case 'postgres':
case 'postgres8': // for legacy purposes we also accept "postgres8"
if (!extension_loaded('pgsql')) {
throw new ConfigSanityException(get_string('pgsqldbextensionnotloaded', 'error'));
}
break;
case 'mysql5':
if (!extension_loaded('mysql')) {
case 'mysql':
case 'mysql5': // for legacy purposes we also accept "mysql5"
if (!extension_loaded('mysqli') && !extension_loaded('mysql')) {
throw new ConfigSanityException(get_string('mysqldbextensionnotloaded', 'error'));
}
break;
......
......@@ -1349,5 +1349,9 @@ function site_warnings() {
$warnings[] = get_string('mbstringneeded', 'error');
}
if (get_config('dbtype') == 'mysql') {
$warnings[] = get_string('switchtomysqli', 'error');
}
return $warnings;
}
......@@ -171,7 +171,7 @@ class XMLDBmysql extends XMLDBGenerator {
}
/**
* Given one XMLDBTable and one XMLDBField, return the SQL statements needded to create its enum
* Given one XMLDBTable and one XMLDBField, return the SQL statements needded to create its enum
* (usually invoked from getModifyEnumSQL()
*/
function getCreateEnumSQL($xmldb_table, $xmldb_field) {
......@@ -179,8 +179,8 @@ class XMLDBmysql extends XMLDBGenerator {
return $this->getAlterFieldSQL($xmldb_table, $xmldb_field);
}
/**
* Given one XMLDBTable and one XMLDBField, return the SQL statements needded to drop its enum
/**
* Given one XMLDBTable and one XMLDBField, return the SQL statements needded to drop its enum
* (usually invoked from getModifyEnumSQL()
*/
function getDropEnumSQL($xmldb_table, $xmldb_field) {
......@@ -189,7 +189,7 @@ class XMLDBmysql extends XMLDBGenerator {
}
/**
* Given one XMLDBTable and one XMLDBField, return the SQL statements needded to create its default
* Given one XMLDBTable and one XMLDBField, return the SQL statements needded to create its default
* (usually invoked from getModifyDefaultSQL()
*/
function getCreateDefaultSQL($xmldb_table, $xmldb_field) {
......@@ -217,7 +217,7 @@ class XMLDBmysql extends XMLDBGenerator {
}
/**
* Given one XMLDBTable and one XMLDBField, return the SQL statements needded to drop its default
* Given one XMLDBTable and one XMLDBField, return the SQL statements needded to drop its default
* (usually invoked from getModifyDefaultSQL()
*/
function getDropDefaultSQL($xmldb_table, $xmldb_field) {
......@@ -253,7 +253,7 @@ class XMLDBmysql extends XMLDBGenerator {
}
/**
* Given one XMLDBTable returns one array with all the check constrainsts
* Given one XMLDBTable returns one array with all the check constrainsts
* in the table (fetched from DB)
* Each element contains the name of the constraint and its description
* If no check constraints are found, returns an empty array
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment