mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Checking for static $enabled when processing $versionableExtensions,
as db/build was failing when Translatable::$enabled=false Fixed indentation in augumentDatabase() (merged from branches/gsoc) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@42154 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
53016680d5
commit
c4ab634207
@ -107,9 +107,8 @@ class Versioned extends DataObjectDecorator {
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* An array of DataObject extensions that may require versioning for extra tables
|
* An array of DataObject extensions that may require versioning for extra tables
|
||||||
* The array value is a set of suffixes to form these table names, assuming a preceding '_'
|
* The array value is a set of suffixes to form these table names, assuming a preceding '_'.
|
||||||
*
|
* E.g. if Extension1 creates a new table 'Class_suffix1'
|
||||||
* e.g. if Extension1 creates a new table 'Class_suffix1'
|
|
||||||
* and Extension2 the tables 'Class_suffix2' and 'Class_suffix3':
|
* and Extension2 the tables 'Class_suffix2' and 'Class_suffix3':
|
||||||
*
|
*
|
||||||
* $versionableExtensions = array(
|
* $versionableExtensions = array(
|
||||||
@ -117,6 +116,9 @@ class Versioned extends DataObjectDecorator {
|
|||||||
* 'Extension2' => array('suffix2', 'suffix3'),
|
* 'Extension2' => array('suffix2', 'suffix3'),
|
||||||
* );
|
* );
|
||||||
*
|
*
|
||||||
|
* Make sure your extension has a static $enabled-property that determines if it is
|
||||||
|
* processed by Versioned.
|
||||||
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected static $versionableExtensions = array('Translatable' => 'lang');
|
protected static $versionableExtensions = array('Translatable' => 'lang');
|
||||||
@ -127,7 +129,7 @@ class Versioned extends DataObjectDecorator {
|
|||||||
// Build a list of suffixes whose tables need versioning
|
// Build a list of suffixes whose tables need versioning
|
||||||
$allSuffixes = array();
|
$allSuffixes = array();
|
||||||
foreach (Versioned::$versionableExtensions as $versionableExtension => $suffixes) {
|
foreach (Versioned::$versionableExtensions as $versionableExtension => $suffixes) {
|
||||||
if ($this->owner->hasExtension($versionableExtension)) {
|
if ($this->owner->hasExtension($versionableExtension) && singleton($versionableExtension)->stat('enabled')) {
|
||||||
$allSuffixes = array_merge($allSuffixes, (array)$suffixes);
|
$allSuffixes = array_merge($allSuffixes, (array)$suffixes);
|
||||||
foreach ((array)$suffixes as $suffix) {
|
foreach ((array)$suffixes as $suffix) {
|
||||||
$allSuffixes[$suffix] = $versionableExtension;
|
$allSuffixes[$suffix] = $versionableExtension;
|
||||||
@ -135,7 +137,7 @@ class Versioned extends DataObjectDecorator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the zero-suffix table to the list (table name = class name)
|
// Add the default table with an empty suffix to the list (table name = class name)
|
||||||
array_push($allSuffixes,'');
|
array_push($allSuffixes,'');
|
||||||
|
|
||||||
foreach ($allSuffixes as $key => $suffix) {
|
foreach ($allSuffixes as $key => $suffix) {
|
||||||
@ -150,14 +152,12 @@ class Versioned extends DataObjectDecorator {
|
|||||||
if($this->owner->parentClass() == "DataObject") {
|
if($this->owner->parentClass() == "DataObject") {
|
||||||
$rootTable = true;
|
$rootTable = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($suffix && ($ext = $this->owner->getExtension($allSuffixes[$suffix]))) {
|
if ($suffix && ($ext = $this->owner->getExtension($allSuffixes[$suffix]))) {
|
||||||
if (!$ext->isVersionedTable($table)) continue;
|
if (!$ext->isVersionedTable($table)) continue;
|
||||||
$fields = $ext->fieldsInExtraTables($suffix);
|
$fields = $ext->fieldsInExtraTables($suffix);
|
||||||
$indexes = $fields['indexes'];
|
$indexes = $fields['indexes'];
|
||||||
$fields = $fields['db'];
|
$fields = $fields['db'];
|
||||||
} else if (!$ext) continue;
|
}
|
||||||
|
|
||||||
|
|
||||||
// Create tables for other stages
|
// Create tables for other stages
|
||||||
foreach($this->stages as $stage) {
|
foreach($this->stages as $stage) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user