Index: branches/5.3.x/core/install/upgrades.php =================================================================== diff -u -N -r15698 -r15910 --- branches/5.3.x/core/install/upgrades.php (.../upgrades.php) (revision 15698) +++ branches/5.3.x/core/install/upgrades.php (.../upgrades.php) (revision 15910) @@ -1,6 +1,6 @@ Application->recallObject('kMultiLanguageHelper'); /* @var $ml_helper kMultiLanguageHelper */ - $this->Application->UnitConfigReader->iterateConfigs(Array (&$this, 'updateTextFields'), $ml_helper->getLanguages()); + $languages = $ml_helper->getLanguages(); + $this->Application->UnitConfigReader->ReReadConfigs(); + + foreach ($this->Application->UnitConfigReader->getPrefixes() as $prefix) { + $this->updateTextFields($prefix, $languages); + } } } @@ -108,46 +113,50 @@ * Callback function, that makes all ml fields of text type null with same default value * * @param string $prefix - * @param Array $config_data * @param Array $languages - * @return bool + * + * @return boolean */ - function updateTextFields($prefix, &$config_data, $languages) + function updateTextFields($prefix, $languages) { - if (!isset($config_data['TableName']) || !isset($config_data['Fields'])) { + $config = $this->Application->getUnitConfig($prefix); + + if ( $config->getTableName() === false || $config->getFields() === false ) { // invalid config found or prefix not found return false; } - $table_name = $config_data['TableName']; - $table_structure = $this->Conn->Query('DESCRIBE '.$table_name, 'Field'); - if (!$table_structure) { + $table_name = $config->getTableName(); + $table_structure = $this->Conn->Query('DESCRIBE ' . $table_name, 'Field'); + + if ( !$table_structure ) { // table not found return false; } - $sqls = Array (); - foreach ($config_data['Fields'] as $field => $options) { - if (isset($options['formatter']) && $options['formatter'] == 'kMultiLanguage' && !isset($options['master_field'])) { + $sqls = Array(); + + foreach ( $config->getFields() as $field => $options ) { + if ( isset($options['formatter']) && $options['formatter'] == 'kMultiLanguage' && !isset($options['master_field']) ) { // update all l_ fields (new format) - foreach ($languages as $language_id) { - $ml_field = 'l'.$language_id.'_'.$field; + foreach ( $languages as $language_id ) { + $ml_field = 'l' . $language_id . '_' . $field; - if ($table_structure[$ml_field]['Type'] == 'text') { - $sqls[] = 'CHANGE '.$ml_field.' '.$ml_field.' TEXT NULL DEFAULT NULL'; + if ( $table_structure[$ml_field]['Type'] == 'text' ) { + $sqls[] = 'CHANGE ' . $ml_field . ' ' . $ml_field . ' TEXT NULL DEFAULT NULL'; } } // update if found (old format) - if (isset($table_structure[$field]) && $table_structure[$field]['Type'] == 'text') { - $sqls[] = 'CHANGE '.$field.' '.$field.' TEXT NULL DEFAULT NULL'; + if ( isset($table_structure[$field]) && $table_structure[$field]['Type'] == 'text' ) { + $sqls[] = 'CHANGE ' . $field . ' ' . $field . ' TEXT NULL DEFAULT NULL'; } } } - if ($sqls) { - $sql = 'ALTER TABLE '.$table_name.' '.implode(', ', $sqls); + if ( $sqls ) { + $sql = 'ALTER TABLE ' . $table_name . ' ' . implode(', ', $sqls); $this->Conn->Query($sql); }