Index: branches/5.2.x/core/install/upgrades.php =================================================================== diff -u -N -r15378 -r15447 --- branches/5.2.x/core/install/upgrades.php (.../upgrades.php) (revision 15378) +++ branches/5.2.x/core/install/upgrades.php (.../upgrades.php) (revision 15447) @@ -1,6 +1,6 @@ Conn->GetOne('SELECT LanguageId FROM '.TABLE_PREFIX.'Language WHERE PrimaryLang = 1')) return ; - $this->Conn->Query('UPDATE '.TABLE_PREFIX.'Language SET PrimaryLang = 1 ORDER BY LanguageId LIMIT 1'); + if ( $mode == 'before' ) { + $sql = 'SELECT LanguageId + FROM ' . TABLE_PREFIX . 'Language + WHERE PrimaryLang = 1'; + + if ( $this->Conn->GetOne($sql) ) { + return; + } + + $this->Conn->Query('UPDATE ' . TABLE_PREFIX . 'Language SET PrimaryLang = 1 ORDER BY LanguageId LIMIT 1'); } } @@ -2192,5 +2199,36 @@ $this->Conn->Query($sql); } } + + // add new ml columns to phrases/e-mail events + $ml_helper->createFields('phrases'); + $ml_helper->createFields('emailevents'); } + + /** + * Update to 5.2.0 + * + * @param string $mode when called mode {before, after) + */ + public function Upgrade_5_2_0($mode) + { + if ( $mode != 'after' ) { + return; + } + + $table_name = $this->Application->getUnitOption('c', 'TableName'); + + $sql = 'SELECT NamedParentPath, CachedTemplate, CategoryId + FROM ' . $table_name; + $categories = $this->Conn->GetIterator($sql); + + foreach ($categories as $category_data) { + $fields_hash = Array ( + 'NamedParentPathHash' => kUtil::crc32(mb_strtolower(preg_replace('/^Content\//i', '', $category_data['NamedParentPath']))), + 'CachedTemplateHash' => kUtil::crc32(mb_strtolower($category_data['CachedTemplate'])), + ); + + $this->Conn->doUpdate($fields_hash, $table_name, 'CategoryId = ' . $category_data['CategoryId']); + } + } } \ No newline at end of file