Index: branches/5.2.x/core/install/upgrades.php =================================================================== diff -u -N -r15137 -r15176 --- branches/5.2.x/core/install/upgrades.php (.../upgrades.php) (revision 15137) +++ branches/5.2.x/core/install/upgrades.php (.../upgrades.php) (revision 15176) @@ -1,6 +1,6 @@ Array ('from' => 'BanRules', 'to' => 'UserBanRules'), + 'conf' => Array ('from' => 'ConfigurationValues', 'to' => 'SystemSettings'), + 'c' => Array ('from' => 'Category', 'to' => 'Categories'), + 'cf' => Array ('from' => 'CustomField', 'to' => 'CustomFields'), + 'draft' => Array ('from' => 'Drafts', 'to' => 'FormSubmissionReplyDrafts'), + 'emailevents' => Array ('from' => 'Events', 'to' => 'EmailEvents'), + 'fav' => Array ('from' => 'Favorites', 'to' => 'UserFavorites'), + 'img' => Array ('from' => 'Images', 'to' => 'CatalogImages'), + '#file' => Array ('from' => 'ItemFiles', 'to' => 'CatalogFiles'), + 'rev' => Array ('from' => 'ItemReview', 'to' => 'CatalogReviews'), + 'lang' => Array ('from' => 'Language', 'to' => 'Languages'), + 'permission-type' => Array ('from' => 'PermissionConfig', 'to' => 'CategoryPermissionsConfig'), + 'phrases' => Array ('from' => 'Phrase', 'to' => 'LanguageLabels'), + 'g' => Array ('from' => 'PortalGroup', 'to' => 'UserGroups'), + 'user-profile' => Array ('from' => 'PersistantSessionData', 'to' => 'UserPersistentSessionData'), + 'u' => Array ('from' => 'PortalUser', 'to' => 'Users'), + 'u-cdata' => Array ('from' => 'PortalUserCustomData', 'to' => 'UserCustomData'), + 'search' => Array ('from' => 'RelatedSearches', 'to' => 'CategoryRelatedSearches'), + 'rel' => Array ('from' => 'Relationship', 'to' => 'CatalogRelationships'), + 'search-log' => Array ('from' => 'SearchLog', 'to' => 'SearchLogs'), + 'skin' => Array ('from' => 'Skins', 'to' => 'AdminSkins'), + 'submission-log' => Array ('from' => 'SubmissionLog', 'to' => 'FormSubmissionReplies'), + 'theme' => Array ('from' => 'Theme', 'to' => 'Themes'), + 'ug' => Array ('from' => 'UserGroup', 'to' => 'UserGroupRelations'), + 'visits' => Array ('from' => 'Visits', 'to' => 'UserVisits'), + 'session-log' => Array ('from' => 'SessionLogs', 'to' => 'UserSessionLogs'), + ); + + /** * Changes table structure, where multilingual fields of TEXT type are present * * @param string $mode when called mode {before, after) @@ -1407,7 +1442,9 @@ */ function Upgrade_5_1_0_B1($mode) { - if ($mode == 'before') { + if ( $mode == 'before' ) { + $this->_renameTables('from'); + // migrate email events $table_structure = $this->Conn->Query('DESCRIBE ' . TABLE_PREFIX . 'Events', 'Field'); @@ -1537,6 +1574,23 @@ } /** + * Makes sure we rename tables to legacy names before doing other upgrades before 5.2.0-B1 upgrade + * + * @param string $name + * @param Array $arguments + */ + public function __call($name, $arguments) + { + if ( substr($name, 0, 12) == 'Upgrade_5_1_' && $arguments[0] == 'before' ) { + $this->_renameTables('from'); + } + + if ( substr($name, 0, 13) == 'Upgrade_5_2_0' && $arguments[0] == 'before' ) { + $this->_renameTables('to'); + } + } + + /** * Move country/state translations from Phrase to CountryStates table * */ @@ -1681,7 +1735,11 @@ */ function Upgrade_5_1_0($mode) { - if ($mode == 'after') { + if ( $mode == 'before' ) { + $this->_renameTables('from'); + } + + if ( $mode == 'after' ) { $base_url = $this->Application->BaseURL(); $sql = 'UPDATE ' . TABLE_PREFIX . 'FormSubmissions @@ -1697,6 +1755,10 @@ */ function Upgrade_5_1_1_B1($mode) { + if ( $mode == 'before' ) { + $this->_renameTables('from'); + } + if ($mode == 'after') { $this->processDisplayToPublic(); } @@ -1765,21 +1827,41 @@ */ function Upgrade_5_1_3($mode) { - if ($mode != 'after') { - return ; + if ( $mode == 'before' ) { + $this->_renameTables('from'); } - $this->moveTranslation('LA_COL_', 'LA_FLD_', 'ColumnTranslation'); + if ( $mode == 'after' ) { + $this->moveTranslation('LA_COL_', 'LA_FLD_', 'ColumnTranslation'); + } } /** + * Makes sure table names match upgrade script + * + * @param string $key + * @return void + * @access private + */ + private function _renameTables($key) + { + foreach ($this->renamedTables as $prefix => $table_info) { + $this->Application->setUnitOption($prefix, 'TableName', TABLE_PREFIX . $table_info[$key]); + } + } + + /** * Update to 5.2.0-B1; Transform list sortings storage * * @param string $mode when called mode {before, after) */ public function Upgrade_5_2_0_B1($mode) { - if ($mode == 'after') { + if ( $mode == 'before' ) { + $this->_renameTables('to'); + } + + if ( $mode == 'after' ) { $this->transformSortings(); $this->moveTranslation('LA_COL_', 'LA_FLD_', 'ColumnTranslation'); // because of "la_col_ItemPrefix" phrase $this->moveTranslation('LA_HINT_', 'LA_FLD_', 'HintTranslation');