Index: branches/5.3.x/core/install/upgrades.php =================================================================== diff -u -N -r15956 -r15999 --- branches/5.3.x/core/install/upgrades.php (.../upgrades.php) (revision 15956) +++ branches/5.3.x/core/install/upgrades.php (.../upgrades.php) (revision 15999) @@ -1,6 +1,6 @@ updateDeploymentLog(); + $this->migrateSSLSettings(); + $this->migrateSSLSiteDomains(); } } @@ -2444,4 +2446,56 @@ $sql = 'ALTER TABLE ' . $table_name . ' DROP AppliedDBRevisions'; $this->Conn->Query($sql); } + + /** + * Migrates SSL settings to new format. + * + * @return void + */ + protected function migrateSSLSettings() + { + $mapping = array( + 'SSL_URL' => 'SSLDomain', + 'AdminSSL_URL' => 'AdminSSLDomain', + ); + + foreach ( $mapping as $old_setting => $new_setting ) { + $old_value = $this->Application->ConfigValue($old_setting); + + if ( $old_value ) { + $this->Application->SetConfigValue($new_setting, parse_url($old_value, PHP_URL_HOST)); + } + + $sql = 'DELETE FROM ' . $this->Application->getUnitConfig('conf')->getTableName() . ' + WHERE VariableName = ' . $this->Conn->qstr($old_setting); + $this->Conn->Query($sql); + } + } + + /** + * Migrates SSL site domains. + * + * @return void + */ + protected function migrateSSLSiteDomains() + { + /** @var kDBItem $object */ + $object = $this->Application->recallObject('site-domain.migrate', null, array('skip_autoload' => true)); + + $sql = 'SELECT * + FROM ' . $this->Application->getUnitConfig('site-domain')->getTableName() . ' + WHERE SSLDomainName <> ""'; + $site_domains = $this->Conn->Query($sql); + + foreach ( $site_domains as $site_domain ) { + if ( strpos($site_domain['SSLDomainName'], '//') === false ) { + continue; + } + + // use object to reset domain cache as well + $object->LoadFromHash($site_domain); + $object->SetDBField('SSLDomainName', parse_url($site_domain['SSLDomainName'], PHP_URL_HOST)); + $object->Update(); + } + } } \ No newline at end of file