Resolve merge regressions

This commit is contained in:
Damian Mooyman 2016-02-25 15:41:32 +13:00
parent 3b0a9f4ba2
commit 4f1f2497be
2 changed files with 10 additions and 9 deletions

View File

@ -122,10 +122,10 @@ class DBClassName extends Enum {
return $class;
}
// If there is no class for this table, strip table modifiers (_Live / _versions) off the end
if(preg_match('/^(?<class>.+)(_[^_]+)$/i', $this->getTable(), $matches)) {
if(preg_match('/^(?<class>.+)(_[^_]+)$/i', $table, $matches)) {
return $this->getClassNameFromTable($matches['class']);
}
return null;
}
@ -162,12 +162,12 @@ class DBClassName extends Enum {
if(empty(self::$classname_cache[$table])) {
self::$classname_cache[$table] = array();
}
// Check existing cache
if(!empty(self::$classname_cache[$table][$name])) {
return self::$classname_cache[$table][$name];
}
// Get all class names
$classNames = $this->getEnum();
if(DB::get_schema()->hasField($table, $name)) {
@ -201,7 +201,7 @@ class DBClassName extends Enum {
if($defaultClass && class_exists($defaultClass)) {
return $defaultClass;
}
// Fallback to first option
$enum = $this->getEnum();
return reset($enum);

View File

@ -1167,12 +1167,13 @@ class Versioned extends DataExtension implements TemplateGlobalProvider {
$oldMode = Versioned::get_reading_mode();
Versioned::reading_stage($toStage);
// Migrate stage prior to write
$from->setSourceQueryParam('Versioned.mode', 'stage');
$from->setSourceQueryParam('Versioned.stage', $toStage);
$conn = DB::get_conn();
if(method_exists($conn, 'allowPrimaryKeyEditing')) {
$conn = DB::get_conn();
$conn->allowPrimaryKeyEditing($baseClass, true);
// Migrate stage prior to write
$from->setSourceQueryParam('Versioned.mode', 'stage');
$from->setSourceQueryParam('Versioned.stage', $toStage);
$from->write();
$conn->allowPrimaryKeyEditing($baseClass, false);
} else {