mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-04 07:08:34 +02:00
BUGFIX: Prevent failed migrateVersion writes from breaking versioning system in future writes.
BUGFIX: MAke site tree pages go green when you save a new draft. API CHANGE: Add option for DataObjectDecorator::onAfterSkippedWrite() git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@101155 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
682e7d0f1a
commit
d825a6bb5c
@ -920,6 +920,8 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
if(self::get_validation_enabled()) {
|
||||
$valid = $this->validate();
|
||||
if(!$valid->valid()) {
|
||||
// Used by DODs to clean up after themselves, eg, Versioned
|
||||
$this->extend('onAfterSkippedWrite');
|
||||
throw new ValidationException($valid, "Validation error writing a $this->class object: " . $valid->message() . ". Object not written.", E_USER_WARNING);
|
||||
return false;
|
||||
}
|
||||
@ -1050,6 +1052,8 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
$this->changed = null;
|
||||
} elseif ( $showDebug ) {
|
||||
echo "<b>Debug:</b> no changes for DataObject<br />";
|
||||
// Used by DODs to clean up after themselves, eg, Versioned
|
||||
$this->extend('onAfterSkippedWrite');
|
||||
}
|
||||
|
||||
// Clears the cache for this object so get_one returns the correct object.
|
||||
@ -1059,6 +1063,9 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
$this->record['Created'] = SS_Datetime::now()->Rfc2822();
|
||||
}
|
||||
$this->record['LastEdited'] = SS_Datetime::now()->Rfc2822();
|
||||
} else {
|
||||
// Used by DODs to clean up after themselves, eg, Versioned
|
||||
$this->extend('onAfterSkippedWrite');
|
||||
}
|
||||
|
||||
// Write ComponentSets as necessary
|
||||
|
@ -391,6 +391,14 @@ class Versioned extends DataObjectDecorator {
|
||||
if(isset($thisVersion)) $this->owner->Version = str_replace("'","",$thisVersion);
|
||||
}
|
||||
|
||||
/**
|
||||
* If a write was skipped, then we need to ensure that we don't leave a migrateVersion()
|
||||
* value lying around for the next write.
|
||||
*/
|
||||
function onAfterSkippedWrite() {
|
||||
$this->migrateVersion(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a table is supporting the Versioned extensions (e.g. $table_versions does exists)
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user