FIX SiteConfig creation

SiteConfig translations always had the default locale unless they were
added manually from the CMS. This resulted in 2 new records every time
a page in a different language was requested
This commit is contained in:
martimiz 2017-07-20 14:31:40 +02:00
parent 9b2c229ded
commit 0344b10889
1 changed files with 3 additions and 2 deletions

View File

@ -1431,13 +1431,14 @@ class Translatable extends DataExtension implements PermissionProvider
*/
protected function populateSiteConfigDefaults()
{
$table = DataObject::getSchema()->tableName(get_class($this->owner));
// Work-around for population of defaults during database initialisation.
// When the database is being setup singleton('SiteConfig') is called.
if (!DB::get_schema()->hasTable(get_class($this->owner))) {
if (!DB::get_schema()->hasTable($table)) {
return;
}
if (!DB::get_schema()->hasField(get_class($this->owner), 'Locale')) {
if (!DB::get_schema()->hasField($table, 'Locale')) {
return;
}
if (DB::get_schema()->isSchemaUpdating()) {