From 973a3d64f9f0c4eb9d8636b0f08c5780e5c0965a Mon Sep 17 00:00:00 2001 From: mmustafasenoglu Date: Thu, 25 Jun 2026 13:44:53 +0300 Subject: [PATCH] fix: add specific error message for plain permalink sites When a self-hosted WordPress site uses plain permalinks, the REST API root is advertised as a query-parameter form (rest_route=/) which can cause login failures. This change detects this case and shows a specific, actionable error message directing users to enable pretty permalinks. Before: "Cannot load the WordPress site details" After: "This site uses plain permalinks, which are not fully supported. Please enable pretty permalinks in Settings > Permalinks, or contact your hosting provider for assistance." Fixes wordpress-mobile/WordPress-iOS#25604 Signed-off-by: mustafasenoglu --- .../Classes/Login/SelfHostedSiteAuthenticator.swift | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/WordPress/Classes/Login/SelfHostedSiteAuthenticator.swift b/WordPress/Classes/Login/SelfHostedSiteAuthenticator.swift index adcac2c2b49b..f8657f9d4ac9 100644 --- a/WordPress/Classes/Login/SelfHostedSiteAuthenticator.swift +++ b/WordPress/Classes/Login/SelfHostedSiteAuthenticator.swift @@ -69,6 +69,7 @@ struct SelfHostedSiteAuthenticator { case xmlrpcDisabled(Error) case xmlrpcEndpointNotFound case loadingSiteInfoFailure(Error) + case plainPermalinkNotSupported(apiRootURL: String) case savingSiteFailure case mismatchedUser(expectedUsername: String) case cancelled @@ -90,6 +91,12 @@ struct SelfHostedSiteAuthenticator { value: "Cannot load the WordPress site details", comment: "Error message shown when failing to load details from a self-hosted WordPress site" ) + case .plainPermalinkNotSupported: + return NSLocalizedString( + "addSite.selfHosted.plainPermalinkNotSupported", + value: "This site uses plain permalinks, which are not fully supported. Please enable pretty permalinks in Settings > Permalinks, or contact your hosting provider for assistance.", + comment: "Error message when a self-hosted site uses plain permalinks (rest_route query form) which causes REST API issues" + ) case .savingSiteFailure: return NSLocalizedString( "addSite.selfHosted.savingSiteFailure", @@ -386,6 +393,11 @@ struct SelfHostedSiteAuthenticator { (siteSettings, isAdmin, jetpackSite, jetpackConnection, xmlrpcOptions) = try await (siteSettings_, isAdmin_, jetpackSite_, jetpackConnection_, xmlrpcOptions_) } catch { + // If the API root URL uses the rest_route query-parameter form + // (plain permalinks), provide a more actionable error message. + if apiRootURL.query(forKey: "rest_route") != nil { + throw .plainPermalinkNotSupported(apiRootURL: apiRootURL.absoluteString) + } throw .loadingSiteInfoFailure(error) }