Skip to content

Convert Blog to Swift (P4)#25320

Open
kean wants to merge 2 commits intotrunkfrom
task/convert-blog-to-swift-p4
Open

Convert Blog to Swift (P4)#25320
kean wants to merge 2 commits intotrunkfrom
task/convert-blog-to-swift-p4

Conversation

@kean
Copy link
Contributor

@kean kean commented Feb 27, 2026

One more part that converts the computed properties. The next PR will only need to remove the lifecycle methods and the properties.

@kean kean added this to the Someday milestone Feb 27, 2026
@kean kean added the Tech Debt label Feb 27, 2026
@kean kean force-pushed the task/convert-blog-to-swift-p4 branch from e120daa to 04d6c91 Compare February 27, 2026 14:42
@property (nonatomic, strong, readwrite, nullable) NSString *xmlrpc;
@property (nonatomic, strong, readwrite, nullable) NSString *restApiRootURL;
@property (nonatomic, strong, readwrite, nullable) NSString *apiKey;
@property (nonatomic, strong, readwrite, nonnull) NSNumber *organizationID;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The organizationID property is optional in the model. For simplicity, I removed the computed property.


// Readonly Properties
@property (nonatomic, strong, readonly, nullable) WordPressOrgXMLRPCApi *xmlrpcApi;
@property (nonatomic, strong, readwrite, nullable) WordPressOrgXMLRPCApi *xmlrpcApi;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The setter will be internal again after full conversion. I'll tighten access control.

let extra: String
if let account {
extra = " wp.com account: \(account.username ?? "") blogId: \(dotComID?.intValue ?? 0) plan: \(planTitle ?? "") (\(planID?.intValue ?? 0))"
extra = " wp.com account: \(account.username) blogId: \(dotComID?.intValue ?? 0) plan: \(planTitle ?? "") (\(planID?.intValue ?? 0))"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixing a warning introduced earlier.

setPrimitiveValue(newValue, forKey: "xmlrpc")
didChangeValue(forKey: "xmlrpc")
// Reset the API client so next time we use the new XML-RPC URL
xmlrpcApi = nil
Copy link
Contributor Author

@kean kean Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There gotta be a better way to do it...

The suggested options are (generated):

The custom accessor is only needed because of the xmlrpcApi = nil side effect. Alternatives:

  1. @NSManaged + didSet — doesn't work, didSet isn't supported on @NSManaged properties.
  2. willSave() or KVO — reset xmlrpcApi there instead. But that's more indirect and harder to follow.
  3. Lazy recomputation — make xmlrpcApi check if its URL still matches xmlrpc each time it's accessed, removing the need to nil it out. But that
    changes Blog.m logic outside the scope of this PR.

I lean towards option 3. Wdyt?
(Not in the scope of this PR)

In general, none of this code belongs to Blog, so perhaps we could fix it by introducing a better solution for DI.

return _selfHostedSiteRestApi;
}

- (BOOL)supportsRestApi {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method wasn't used anymore. It's now a private property in Blog+Features.swift.

@kean kean requested review from crazytonyli and jkmassel February 27, 2026 14:48
@wpmobilebot
Copy link
Contributor

wpmobilebot commented Feb 27, 2026

🤖 Build Failure Analysis

This build has failures. Claude has analyzed them - check the build annotations for details.

@sonarqubecloud
Copy link

@wpmobilebot
Copy link
Contributor

App Icon📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
App NameWordPress
ConfigurationRelease-Alpha
Build Number31226
VersionPR #25320
Bundle IDorg.wordpress.alpha
Commit30bd29f
Installation URL2jfhddt07cohg
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot
Copy link
Contributor

App Icon📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
App NameJetpack
ConfigurationRelease-Alpha
Build Number31226
VersionPR #25320
Bundle IDcom.jetpack.alpha
Commit30bd29f
Installation URL7ambdqvej7b98
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@kean kean removed the request for review from jkmassel February 27, 2026 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants