WordPress-iOS
WordPress-iOS copied to clipboard
Posts: Scheduled posts don't move from Draft to Scheduled after being moved back to Draft and then edited.
Expected behavior
On saving a draft of a post that has a scheduled publish date, I see a notification with a link/prompt to publish the post. If I tap that option, it appears to confirm that the post has been scheduled.
Actual behavior
If you check the post status or other locations, the post remains in draft.
Steps to reproduce the behavior
- Create a draft post
- Tap Publish
- Publish for a later date
- Go to the Post screen > Scheduled
- From the 3 dot menu, move the post to the trash
- Go to the Post screen > Trashed
- From the 3 dot menu, move the post to draft
- Edit the post
- Tap "Update"
- When notification appears at the bottom of the screen, tap "Publish"
- See notification post has been scheduled
- Tap "View"
- Note further confirmation that post has been scheduled
- Double check in Post Settings or Drafts/Scheduled folders on Posts screen
- Note post is still a draft
https://user-images.githubusercontent.com/103850310/166850844-a75e670f-a609-4c13-8c78-42e93dda3135.mov
Tested on iPhone XS, iOS 15.4.1, WPiOS 19.7
The scheduled post seem to get into an inconsistent state if it's edited after being moved back to Draft.
Scenario 1
- Create a scheduled post
- Go to
Posts
>Scheduled
- Tap
More
- Tap
Move to Draft
- Tap
Publish
in the notification ✅ The post is back toScheduled
Scenario 2
- Create a scheduled post
- Go to
Posts
>Scheduled
- Tap
More
- Tap
Move to Draft
- Edit the post
-
Tap
Update
- Tap
Publish
in the notification ❌ The post stays inDrafts
displaying theLocal changes
message.
Scenario 3
- Create a scheduled post
- Go to
Posts
>Scheduled
- Tap
More
- Tap
Move to Trash
- Go to
Posts
>Trashed
- Tap
More
- Tap
Move to Draft
- Tap
Publish
in the notification ✅ The post is back toScheduled
Scenario 4
- Create a scheduled post
- Go to
Posts
>Scheduled
- Tap
More
- Tap
Move to Trash
- Go to
Posts
>Trashed
- Tap
More
- Tap
Move to Draft
- Edit the post
-
Tap
Update
- Tap
Publish
in the notification ❌ The post stays inDrafts
displaying theLocal changes
message.
I have investigated this issue quite a bit. Unfortunately I wasn't able to find a proper solution. Here are my findings:
- The issue is local. Service call is made correctly and when I checked the state from web, everything looked normal.
- Problem only happens when the
Publish
notification is tapped while we're on the editor. If we first dismiss that and interact with theNoticeView
on the Posts screen, there is no issue. - The inconsistent state is caused due to a mismatch between
self.state
&self.original.state
inAbstractPost.m
. - I have suspected
PostNoticeViewModel
ln.226post.status = .publish
as it statically assignspublish
and notscheduled
. Changing that didn't solve the problem. - Another possibility is that in
AbstractPost
functionhasLocalChanges
, there is a checkisRevision()
which returns false iforiginal
is nil. I suspect it must be nil but in the bug case it is not so the mismatch results in function returningtrue/YES
.
I worked on this during my rotation but couldn't reach a proper solution. I was close though. My findings:
- The issue happens with normal drafts as well, not only scheduled posts.
- Removing line 491 in
PostEditor+Publish.swift
FIXES the issue.- During my rotation I couldn't investigate thoroughly why this fixes it, but I believe the problem lies in having two managed objects for the same post.
- I couldn't fully investigate what regressions (if any) this causes.
The "Publish Date" field was removed from Post Settings and the "Draft uploaded" snackbars were removed in 24.9, so it no longer applies; closing.