@@ -172,11 +172,12 @@ class SiteSqlUtils
172172 .equals(SiteModelTable .XMLRPC_URL , forcedHttpXmlRpcUrl)
173173 .or ().equals(SiteModelTable .XMLRPC_URL , forcedHttpsXmlRpcUrl)
174174 .endGroup()
175- .endWhere().asModel
176- if (! siteResult.isEmpty()) {
175+ .endWhere()
176+ .asModel
177+ if (siteResult.isNotEmpty()) {
177178 AppLog .d(DB , " Site found using XML-RPC url: " + site.xmlRpcUrl)
178179 // Four possibilities here:
179- // 1. DB site is WP.com, new site is WP.com with the same siteId :
180+ // 1. DB site is WP.com, new site is WP.com with different siteIds :
180181 // The site could be having an "Identity Crisis", while this should be fixed on the site itself,
181182 // it shouldn't block sign-in -> proceed
182183 // 2. DB site is WP.com, new site is XML-RPC:
@@ -187,7 +188,13 @@ class SiteSqlUtils
187188 // 4. DB site is XML-RPC, new site is XML-RPC:
188189 // An existing self-hosted site was logged-into again, and we couldn't identify it by URL or
189190 // by WP.com site ID + URL --> proceed
190- if (siteResult[0 ].origin == SiteModel .ORIGIN_WPCOM_REST && site.origin != SiteModel .ORIGIN_WPCOM_REST ) {
191+ if (siteResult[0 ].origin == SiteModel .ORIGIN_WPCOM_REST && site.origin == SiteModel .ORIGIN_WPCOM_REST ) {
192+ AppLog .d(
193+ DB ,
194+ " Duplicate WPCom sites with same URLs, it could be an Identity Crisis, insert both sites"
195+ )
196+ siteResult = emptyList()
197+ } else if (siteResult[0 ].origin == SiteModel .ORIGIN_WPCOM_REST ) {
191198 AppLog .d(DB , " Site is a duplicate" )
192199 throw DuplicateSiteException
193200 }
0 commit comments