Index: install/install_toolkit.php
===================================================================
--- install/install_toolkit.php (revision 15165)
+++ install/install_toolkit.php (working copy)
@@ -879,6 +879,7 @@
*/
function deleteCache($refresh_permissions = false)
{
+ $this->Application->HandleEvent(new kEvent('adm:OnResetMemcache')); // not in DB = 100% invalidate
$this->Application->HandleEvent(new kEvent('adm:OnResetConfigsCache'));
$this->Application->HandleEvent(new kEvent('adm:OnResetSections'));
$this->Application->HandleEvent(new kEvent('c:OnResetCMSMenuCache'));
Index: install/prerequisites.php
===================================================================
--- install/prerequisites.php (revision 15165)
+++ install/prerequisites.php (working copy)
@@ -38,6 +38,18 @@
protected $Conn = null;
/**
+ * Version upgrade rules
+ *
+ * @var array
+ * @access private
+ */
+ private $upgradeRules = Array (
+ '5.0.0' => Array ('from' => '5.0.0-B1', 'to' => '5.1.0-B1'),
+ '5.1.0' => Array ('from' => '5.1.0-B1', 'to' => '5.2.0-B1'),
+ '5.2.0' => Array ('from' => '5.2.0-B1', 'to' => '5.3.0-B1'),
+ );
+
+ /**
* Sets common instance of installator toolkit
*
* @param kInstallToolkit $instance
@@ -52,7 +64,7 @@
*
* @return kDBConnection
*/
- function &getConnection()
+ function getConnection()
{
return $this->_toolkit->Conn;
}
@@ -68,26 +80,30 @@
{
$errors = Array ();
- if ($mode == 'upgrade') {
+ if ( $mode == 'upgrade' ) {
$sql = 'SELECT Version
FROM ' . TABLE_PREFIX . 'Modules
WHERE Name = "In-Portal"';
+ $inportal_version = $this->getConnection()->GetOne($sql);
- $conn =& $this->getConnection();
- $inportal_version = $conn->GetOne($sql);
-
- if ($inportal_version === false) {
- // only, when In-Portal was installed
+ if ( $inportal_version === false ) {
+ // only, when In-Portal was installed (below 4.3.x)
return $errors;
}
- $min_version = '4.3.1';
+ $min_version = '4.3.1'; // K4-based installator was created, that no longer maintained old upgrade scripts
- $current_version = $this->_toolkit->ConvertModuleVersion($inportal_version);
- $needed_version = $this->_toolkit->ConvertModuleVersion($min_version);
- if ($current_version < $needed_version) {
- $errors[] = 'Please upgrade "In-Portal" to version ' . $min_version;
+ if ( version_compare($inportal_version, $min_version, '<') ) {
+ $errors[] = 'Please upgrade "In-Portal" to version ' . $min_version . ' first';
}
+
+ // example: to upgrade to 5.1.0-B1 or more you at least need to have 5.0.0 installed
+ foreach ($this->upgradeRules as $min_version => $version_rules) {
+ if ( version_compare($versions[0], $version_rules['from'], '<') && version_compare($versions[1], $version_rules['to'], '>=') ) {
+ $errors[] = 'Please upgrade "In-Portal" to version ' . $min_version . ' first';
+ break;
+ }
+ }
}
return $errors;
@@ -166,7 +182,7 @@
$ret = Array();
$sql = 'SELECT VERSION()';
- $conn =& $this->getConnection();
+ $conn = $this->getConnection();
$db_version = preg_replace('/[^\d.]/', '', $conn->GetOne($sql));
$ret['version'] = version_compare($db_version, '5.0', '>=');
Index: install/upgrades.php
===================================================================
--- install/upgrades.php (revision 15165)
+++ install/upgrades.php (working copy)
@@ -23,6 +23,41 @@
class CoreUpgrades extends kUpgradeHelper {
/**
+ * Tables, that were renamed during 5.2.0 version upgrade
+ *
+ * @var Array
+ * @access private
+ */
+ private $renamedTables = Array (
+ 'ban-rule' => 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');
Index: units/helpers/user_helper.php
===================================================================
--- units/helpers/user_helper.php (revision 15165)
+++ units/helpers/user_helper.php (working copy)
@@ -363,6 +363,13 @@
*/
protected function _processInterfaceLanguage()
{
+ if ( defined('IS_INSTALL') && IS_INSTALL ) {
+ $this->event->SetRedirectParam('m_lang', 1); // data
+ $this->Application->Session->SetField('Language', 1); // interface
+
+ return;
+ }
+
$language_field = $this->Application->isAdmin ? 'AdminLanguage' : 'FrontLanguage';
$primary_language_field = $this->Application->isAdmin ? 'AdminInterfaceLang' : 'PrimaryLang';
$is_root = $this->Application->RecallVar('user_id') == USER_ROOT;