Skip to content

Use REST editor for XML-RPC-disabled FAB actions - #25830

Merged
crazytonyli merged 4 commits into
release/27.1from
bugfix/create-post
Jul 23, 2026
Merged

Use REST editor for XML-RPC-disabled FAB actions#25830
crazytonyli merged 4 commits into
release/27.1from
bugfix/create-post

Conversation

@crazytonyli

@crazytonyli crazytonyli commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Description

This fixes a production app bug.

When XML-RPC is disabled, the quick actions to create post and pages present the AbstractPost post editor, which does not work when XML-RPC is disabled. This PR switches to use the "Custom Post Types" post editor which uses core REST API.

I intentionally kept the scope small, due to we are in the code freeze. The same issue would happen on other creating post entry points: universal link, shortcuts, etc. I will create a separate PR to fix them on the trunk branch.

@crazytonyli crazytonyli added this to the 27.1 ❄️ milestone Jul 23, 2026
@crazytonyli
crazytonyli requested a review from jkmassel July 23, 2026 00:29
@dangermattic

Copy link
Copy Markdown
Collaborator
2 Warnings
⚠️ View files have been modified, but no screenshot or video is included in the pull request. Consider adding some for clarity.
⚠️ This PR is assigned to the milestone 27.1 ❄️. The due date for this milestone has already passed.
Please assign it to a milestone with a later deadline or check whether the release for this milestone has already been finished.

Generated by 🚫 Danger

@wpmobilebot

wpmobilebot commented Jul 23, 2026

Copy link
Copy Markdown
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 Number33420
VersionPR #25830
Bundle IDorg.wordpress.alpha
Commitc1dc500
Installation URL1emc7pinc39q0
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot

wpmobilebot commented Jul 23, 2026

Copy link
Copy Markdown
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 Number33420
VersionPR #25830
Bundle IDcom.jetpack.alpha
Commitc1dc500
Installation URL2lvqcojl2f7fo
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@crazytonyli

Copy link
Copy Markdown
Contributor Author

In the presenting and dismissing editor animation, a site title label slides in and out of the screen, which is unexpected. It's caused by the navigation bar customization code in MySiteViewController. I'm going to leave that issue in to avoid increase the scope, too.

ScreenRecording_07-23-2026.12-54-39_1.MP4

let blog: Blog
let postType: PinnedPostType
let initialContent: EditorContent?
let presentingViewController: UIViewController

@jkmassel jkmassel Jul 23, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Claude thinks you have a retain cycle here:

Suggested change
let presentingViewController: UIViewController
unowned let presentingViewController: UIViewController
Details **Retain cycle — the editor leaks on every create.**

presentCoreRESTEditor(...) assigns this view as the rootView of the very UIHostingController it then passes back in here as presentingViewController:

controller.rootView = AnyView(
    CoreRESTPostEditorRoute(..., presentingViewController: controller)
)

That makes controller → rootView → CoreRESTPostEditorRoute → presentingViewController → controller a strong reference cycle, so the hosting controller and the whole editor hierarchy (editor VC, web view, view models, WpService) never deallocate after dismissal — one leak per post/page created.

Unlike the sibling views (PinnedPostTypeView, CustomPostTabView, ApplicationPasswordRequiredView), where the presenter is an external VC and weak var …? is right, here the presenter is the controller that owns this view. unowned breaks the cycle and states that invariant — the owner is always alive while this view exists — while keeping the type non-optional so nothing downstream changes:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in c1dc500

@jkmassel jkmassel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I tested this on-device with https://xmlrpc-disabled-by-plugin.wpmt.co/ and it worked for me!

Left one suggestion

@crazytonyli
crazytonyli enabled auto-merge (squash) July 23, 2026 23:15
@wpmobilebot

Copy link
Copy Markdown
Contributor

🤖 Build Failure Analysis

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

@crazytonyli
crazytonyli merged commit 0854ed7 into release/27.1 Jul 23, 2026
28 checks passed
@crazytonyli
crazytonyli deleted the bugfix/create-post branch July 23, 2026 23:29
crazytonyli added a commit that referenced this pull request Jul 24, 2026
* Apply Swift formatting

* Generalize the post type resolver view

* Use REST editor for XML-RPC-disabled FAB actions

* Make presentingViewController a weak reference
pull Bot pushed a commit to kliu/WordPress-iOS that referenced this pull request Jul 24, 2026
* Improve self-hosted sign-in error logging (wordpress-mobile#25814)

* Prevent site title button clipping (wordpress-mobile#25831)

* Use REST editor for XML-RPC-disabled FAB actions (wordpress-mobile#25830)

* Apply Swift formatting

* Generalize the post type resolver view

* Use REST editor for XML-RPC-disabled FAB actions

* Make presentingViewController a weak reference

* Merge release_notes/27.1 into release/27.1 (wordpress-mobile#25835)

* Add editorialized release notes for version

* Update metadata strings

* Update metadata strings

---------

Co-authored-by: Tony Li <tony.li@automattic.com>

* Update app translations – `Localizable.strings`

* Update app translations – Other `.strings`

* Update plural translations from GlotPress

* Update WordPress metadata translations

* Update Jetpack metadata translations

* Bump version number

---------

Co-authored-by: Tony Li <tony.li@automattic.com>
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.

4 participants