Merge pull request #187 from tractorcow/pulls/2.0/obsolete-fix

Improve dev/build with obsolete class names
This commit is contained in:
Ingo Schommer 2015-04-09 15:47:21 +12:00
commit 10a8352a6b

View File

@ -684,7 +684,7 @@ class Translatable extends DataExtension implements PermissionProvider {
/** /**
* @todo Find more appropriate place to hook into database building * @todo Find more appropriate place to hook into database building
*/ */
function requireDefaultRecords() { public function requireDefaultRecords() {
// @todo This relies on the Locale attribute being on the base data class, and not any subclasses // @todo This relies on the Locale attribute being on the base data class, and not any subclasses
if($this->owner->class != ClassInfo::baseDataClass($this->owner->class)) return false; if($this->owner->class != ClassInfo::baseDataClass($this->owner->class)) return false;
@ -725,7 +725,7 @@ class Translatable extends DataExtension implements PermissionProvider {
$stage, $stage,
sprintf('"SiteTree"."ID" = %d', $id) sprintf('"SiteTree"."ID" = %d', $id)
); );
if(!$obj) continue; if(!$obj || $obj->ObsoleteClassName) continue;
$obj->Locale = Translatable::default_locale(); $obj->Locale = Translatable::default_locale();
$obj->writeToStage($stage); $obj->writeToStage($stage);
@ -737,7 +737,7 @@ class Translatable extends DataExtension implements PermissionProvider {
} else { } else {
foreach($idsWithoutLocale as $id) { foreach($idsWithoutLocale as $id) {
$obj = DataObject::get_by_id($this->owner->class, $id); $obj = DataObject::get_by_id($this->owner->class, $id);
if(!$obj) continue; if(!$obj || $obj->ObsoleteClassName) continue;
$obj->Locale = Translatable::default_locale(); $obj->Locale = Translatable::default_locale();
$obj->write(); $obj->write();