Commit 527ffdf2 authored by Francois Marier's avatar Francois Marier
Browse files
parents e2404cea bd53de52
......@@ -5,7 +5,7 @@
{if $artefacttitle}<h3>{$artefacttitle}</h3>{/if}
<div>{$artefactdescription}</div>
{if isset($attachments)}
<table>
<table class="cb">
<tbody>
<tr><th colspan="2">{str tag=attachedfiles section=artefact.blog}:</th></tr>
{foreach from=$attachments item=item}
......
......@@ -364,9 +364,7 @@ abstract class ArtefactType {
return;
}
if (empty($GLOBALS['_TRANSACTION_STARTED'])) {
db_begin();
}
db_begin();
// Call delete() on children (if there are any)
if ($children = $this->get_children_instances()) {
......@@ -400,9 +398,7 @@ abstract class ArtefactType {
$this->parentdirty = true;
$this->deleted = true;
if (!empty($GLOBALS['_TRANSACTION_STARTED'])) {
db_commit();
}
db_commit();
}
/**
......
......@@ -242,7 +242,7 @@ class BlockInstance {
if ($field == 'configdata') {
$value = serialize($value);
}
if ($this->{$field} != $value) {
if ($this->{$field} !== $value) {
// only set it to dirty if it's changed
$this->dirty = true;
$this->{$field} = $value;
......
This diff is collapsed.
......@@ -320,10 +320,30 @@ function xmldb_core_upgrade($oldversion=0) {
$key->setAttributes(XMLDB_KEY_FOREIGN, array('block'), 'block_instance', array('id'));
add_key($table, $key);
// These fields will be dropped after the template migration. However,
// given that the table needs to be used by block instances being
// created, make the fields nullable during that time.
// Note - XMLDB - you are a whore. Hate, Nigel
execute_sql('ALTER TABLE {view_artefact} ALTER ctime DROP NOT NULL');
execute_sql('ALTER TABLE {view_artefact} ALTER format DROP NOT NULL');
// Install all the blocktypes and their categories now, as they'll be
// needed for the template migration
install_blocktype_categories();
foreach(array('textbox', 'file/image', 'file/filedownload', 'blog/blogpost', 'blog/blog') as $blocktype) {
$data = check_upgrades("blocktype.$blocktype");
upgrade_plugin($data);
}
// install the view column widths
install_view_column_widths();
// Run the template migration
require_once(get_config('docroot') . 'lib/db/templatemigration.php');
upgrade_template_migration();
change_field_notnull(new XMLDBTAble('view_artefact'), new XMLDBTable('block'));
// TODO - enable this again
//execute_sql('ALTER TABLE {view_artefact} ALTER block SET NOT NULL');
$table = new XMLDBTable('view_artefact');
$field = new XMLDBField('oldblock');
......
......@@ -178,7 +178,7 @@ function table_column($table, $oldfield, $field, $type='integer', $size='10',
//}
//Use transactions
execute_sql('BEGIN');
db_begin();
//Always use temporary column
execute_sql('ALTER TABLE '. $CFG->prefix . $table .' ADD COLUMN '. $field .' '. $type);
......@@ -224,7 +224,7 @@ function table_column($table, $oldfield, $field, $type='integer', $size='10',
execute_sql('ALTER TABLE '. $CFG->prefix . $table .' RENAME COLUMN '. $field .' TO '. $realfield);
return execute_sql('COMMIT');
return db_commit();
default:
switch (strtolower($type)) {
......
......@@ -1436,7 +1436,7 @@ function db_array_to_ph($array) {
// This is used by the SQLException, to detect if there is a transaction when
// an error occurs, so it can roll the transaction back
$GLOBALS['_TRANSACTION_STARTED'] = false;
$GLOBALS['_TRANSACTION_LEVEL'] = 0;
/**
* This function starts a smart transaction
......@@ -1445,7 +1445,8 @@ $GLOBALS['_TRANSACTION_STARTED'] = false;
function db_begin() {
global $db;
$GLOBALS['_TRANSACTION_STARTED'] = true;
$GLOBALS['_TRANSACTION_LEVEL']++;
log_debug('db_begin(): transaction level now ' . $GLOBALS['_TRANSACTION_LEVEL']);
$db->StartTrans();
}
......@@ -1457,14 +1458,19 @@ function db_begin() {
*/
function db_commit() {
global $db;
$GLOBALS['_TRANSACTION_STARTED'] = false;
$GLOBALS['_TRANSACTION_LEVEL']--;
log_debug('db_commit(): transaction level now ' . $GLOBALS['_TRANSACTION_LEVEL']);
if ($db->HasFailedTrans()) {
$db->CompleteTrans();
throw new SQLException('Transaction Failed');
if ($GLOBALS['_TRANSACTION_LEVEL'] == 0) {
if ($db->HasFailedTrans()) {
$db->CompleteTrans();
throw new SQLException('Transaction Failed');
}
}
$db->CompleteTrans();
log_debug('peforming commit');
return $db->CompleteTrans();
}
/**
......@@ -1472,9 +1478,12 @@ function db_commit() {
*/
function db_rollback() {
global $db;
$GLOBALS['_TRANSACTION_STARTED'] = false;
log_debug('db_rollback(): rolling back transaction from level '. $GLOBALS['_TRANSACTION_LEVEL']);
$db->FailTrans();
$db->CompleteTrans();
for ($i = $GLOBALS['_TRANSACTION_LEVEL']; $i >= 0; $i--) {
$db->CompleteTrans();
}
$GLOBALS['_TRANSACTION_LEVEL'] = 0;
}
/**
......
......@@ -395,6 +395,8 @@ function exception (Exception $e) {
$e->set_log_off();
}
}
// Display the message and die
$e->handle_exception();
}
......@@ -460,7 +462,7 @@ class MaharaException extends Exception {
return $this->getMessage();
}
public function handle_exception() {
public final function handle_exception() {
if (!empty($this->log)) {
log_message($this->getMessage(), LOG_LEVEL_WARN, true, true, $this->getFile(), $this->getLine(), $this->getTrace());
......@@ -635,12 +637,13 @@ class ConfigSanityException extends ConfigException {
* An SQL related error occured
*/
class SQLException extends SystemException {
public function handle_exception() {
if (!empty($GLOBALS['_TRANSACTION_STARTED'])) {
public function __construct($message=null, $code=0) {
if ($GLOBALS['_TRANSACTION_LEVEL'] > 0) {
log_debug('rolling back a transaction');
db_rollback();
}
parent::__construct($message, $code);
log_warn($this->getMessage());
parent::handle_exception();
}
}
......
......@@ -670,31 +670,8 @@ function core_install_firstcoredata_defaults() {
}
// install the view column widths
$layouts = array(
2 => array(
'50,50',
'67,33',
'33,67',
),
3 => array(
'33,33,33',
'25,50,25',
'15,70,15',
),
4 => array(
'25,25,25,25',
'20,30,30,20',
),
);
install_view_column_widths();
$layout = new StdClass;
foreach ($layouts as $column => $widths) {
foreach ($widths as $width) {
$layout->columns = $column;
$layout->widths = $width;
insert_record('view_layout', $layout);
}
}
db_commit();
}
......@@ -852,4 +829,38 @@ function install_blocktype_categories() {
}
}
/**
* Installs all the allowed column widths for views. Used when installing core
* defaults, and also when upgrading from 0.8 to 0.9
*/
function install_view_column_widths() {
db_begin();
$layouts = array(
2 => array(
'50,50',
'67,33',
'33,67',
),
3 => array(
'33,33,33',
'25,50,25',
'15,70,15',
),
4 => array(
'25,25,25,25',
'20,30,30,20',
),
);
$layout = new StdClass;
foreach ($layouts as $column => $widths) {
foreach ($widths as $width) {
$layout->columns = $column;
$layout->widths = $width;
insert_record('view_layout', $layout);
}
}
db_commit();
}
?>
......@@ -153,6 +153,15 @@ div.editview {
.blockinstance-content p {
margin: .25em 0 .5em;
}
.blockinstance-content h1,
.blockinstance-content h2,
.blockinstance-content h3,
.blockinstance-content h4,
.blockinstance-content h5,
.blockinstance-content h6 {
margin: .25em 0 0;
}
.column-content .add-button {
margin: 5px 0;
}
......
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