Commit 83976eee authored by Francois Marier's avatar Francois Marier
Browse files
parents d15332a7 b20421b0
......@@ -110,12 +110,12 @@ catch (Exception $e) {
throw new ConfigSanityException($errormessage);
}
try {
db_ignore_sql_exceptions(true);
load_config();
db_ignore_sql_exceptions(false);
}
catch (SQLException $e) {
if (!defined('INSTALLER')) {
throw $e;
}
db_ignore_sql_exceptions(false);
}
// Make sure wwwroot is set and available, either in the database or int the
......
......@@ -172,14 +172,14 @@ function xmldb_core_upgrade($oldversion=0) {
}
// Add the 'blockinstancecommit' event type
if ($oldversion < 2007082203) {
if ($oldversion < 2007082201) {
$event = (object)array(
'name' => 'blockinstancecommit',
);
ensure_record_exists('event_type', $event, $event);
}
if ($oldversion < 2007082201) {
if ($oldversion < 2007082202) {
// Rename the community tables to group - mysql version.
// This is really quite hacky. You can't rename columns with a foreign
// key on them, so you have to drop the key, rename the column, re-add
......@@ -213,7 +213,7 @@ function xmldb_core_upgrade($oldversion=0) {
}
// VIEW REWORK MIGRATION
if ($oldversion < 2007100200) {
if ($oldversion < 2007100203) {
$table = new XMLDBTable('view_layout');
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED,
XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
......@@ -388,7 +388,7 @@ function xmldb_core_upgrade($oldversion=0) {
// Move files in dataroot into an 'originals' directory, and remove any
// cached images
if ($oldversion < 2007082202) {
if ($oldversion < 2007082204) {
require('file.php');
foreach(array('artefact/file', 'artefact/internal/profileicons') as $dir) {
$datadir = get_config('dataroot') . $dir;
......
......@@ -1519,4 +1519,32 @@ function increment_perf_db_writes() {
global $PERF;
$PERF->dbwrites++;
}
/**
* Gives the caller the ability to disable logging of SQL exceptions in the
* SQLException constructor.
*
* This is only used by the config loading code to prevent spurious errors
* about the config table not existing going to the logs. If you are going to
* use this function, you had better have a very good reason!
*
* @param bool $status Whether to ignore logging exceptions or not. If null,
* you can retrieve the current value of this setting
*/
function db_ignore_sql_exceptions($status=null) {
global $DB_IGNORE_SQL_EXCEPTIONS;
// Initialise it if being called for the first time
if ($DB_IGNORE_SQL_EXCEPTIONS === null) {
$DB_IGNORE_SQL_EXCEPTIONS = false;
}
// Return the value if asked for
if ($status === null) {
return $DB_IGNORE_SQL_EXCEPTIONS;
}
$DB_IGNORE_SQL_EXCEPTIONS = (bool)$status;
}
?>
......@@ -638,12 +638,16 @@ class ConfigSanityException extends ConfigException {
*/
class SQLException extends SystemException {
public function __construct($message=null, $code=0) {
global $DB_IGNORE_SQL_EXCEPTIONS;
if ($GLOBALS['_TRANSACTION_LEVEL'] > 0) {
log_debug('rolling back a transaction');
db_rollback();
}
parent::__construct($message, $code);
log_warn($this->getMessage());
if (empty($DB_IGNORE_SQL_EXCEPTIONS)) {
log_warn($this->getMessage());
}
}
}
......
......@@ -476,15 +476,7 @@ function ini_get_bool($ini_get_arg) {
function load_config() {
global $CFG;
try {
$dbconfig = get_records_array('config', '', '', '', 'field, value');
}
catch (SQLException $e) {
// TODO: better reporting if config could not be obtained? This
// normally happens when the system isn't installed
log_info($e->getMessage());
return false;
}
$dbconfig = get_records_array('config', '', '', '', 'field, value');
foreach ($dbconfig as $cfg) {
if (isset($CFG->{$cfg->field}) && $CFG->{$cfg->field} != $cfg->value) {
......@@ -523,6 +515,7 @@ function get_config($key) {
function set_config($key, $value) {
global $CFG;
db_ignore_sql_exceptions(true);
if (get_record('config', 'field', $key)) {
if (set_field('config', 'value', $value, 'field', $key)) {
$status = true;
......@@ -534,6 +527,7 @@ function set_config($key, $value) {
$config->value = $value;
$status = insert_record('config', $config);
}
db_ignore_sql_exceptions(false);
if (!empty($status)) {
$CFG->{$key} = $value;
......
......@@ -27,7 +27,7 @@
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2007082205;
$config->version = 2007112300;
$config->release = '0.9.0alpha3dev';
$config->minupgradefrom = 2007080700;
$config->minupgraderelease = '0.8.0 (release tag 0.8.0_RELEASE)';
......
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