Skip to content

Commit

Permalink
Update condition to allow keeping both duplicated websites
Browse files Browse the repository at this point in the history
  • Loading branch information
hichamboushaba committed Jul 29, 2024
1 parent 2e4e33a commit cf23c7c
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,12 @@ class SiteSqlUtils
.equals(SiteModelTable.XMLRPC_URL, forcedHttpXmlRpcUrl)
.or().equals(SiteModelTable.XMLRPC_URL, forcedHttpsXmlRpcUrl)
.endGroup()
.endWhere().asModel
if (!siteResult.isEmpty()) {
.endWhere()
.asModel
if (siteResult.isNotEmpty()) {
AppLog.d(DB, "Site found using XML-RPC url: " + site.xmlRpcUrl)
// Four possibilities here:
// 1. DB site is WP.com, new site is WP.com with the same siteId:
// 1. DB site is WP.com, new site is WP.com with different siteIds:
// The site could be having an "Identity Crisis", while this should be fixed on the site itself,
// it shouldn't block sign-in -> proceed
// 2. DB site is WP.com, new site is XML-RPC:
Expand All @@ -187,7 +188,13 @@ class SiteSqlUtils
// 4. DB site is XML-RPC, new site is XML-RPC:
// An existing self-hosted site was logged-into again, and we couldn't identify it by URL or
// by WP.com site ID + URL --> proceed
if (siteResult[0].origin == SiteModel.ORIGIN_WPCOM_REST && site.origin != SiteModel.ORIGIN_WPCOM_REST) {
if (siteResult[0].origin == SiteModel.ORIGIN_WPCOM_REST && site.origin == SiteModel.ORIGIN_WPCOM_REST) {
AppLog.d(
DB,
"Duplicate WPCom sites with same URLs, it could be an Identity Crisis, insert both sites"
)
siteResult = emptyList()
} else if (siteResult[0].origin == SiteModel.ORIGIN_WPCOM_REST) {
AppLog.d(DB, "Site is a duplicate")
throw DuplicateSiteException
}
Expand Down

0 comments on commit cf23c7c

Please sign in to comment.