WordPress-iOS icon indicating copy to clipboard operation
WordPress-iOS copied to clipboard

Posts: Scheduled posts don't move from Draft to Scheduled after being moved back to Draft and then edited.

Open lmischner opened this issue 2 years ago • 3 comments

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

  1. Create a draft post
  2. Tap Publish
  3. Publish for a later date
  4. Go to the Post screen > Scheduled
  5. From the 3 dot menu, move the post to the trash
  6. Go to the Post screen > Trashed
  7. From the 3 dot menu, move the post to draft
  8. Edit the post
  9. Tap "Update"
  10. When notification appears at the bottom of the screen, tap "Publish"
  11. See notification post has been scheduled
  12. Tap "View"
  13. Note further confirmation that post has been scheduled
  14. Double check in Post Settings or Drafts/Scheduled folders on Posts screen
  15. 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

lmischner avatar May 05 '22 01:05 lmischner

The scheduled post seem to get into an inconsistent state if it's edited after being moved back to Draft.

Scenario 1

  1. Create a scheduled post
  2. Go to Posts > Scheduled
  3. Tap More
  4. Tap Move to Draft
  5. Tap Publish in the notification ✅ The post is back to Scheduled

Scenario 2

  1. Create a scheduled post
  2. Go to Posts > Scheduled
  3. Tap More
  4. Tap Move to Draft
  5. Edit the post
  6. Tap Update
  7. Tap Publish in the notification ❌ The post stays in Drafts displaying the Local changes message.

Scenario 3

  1. Create a scheduled post
  2. Go to Posts > Scheduled
  3. Tap More
  4. Tap Move to Trash
  5. Go to Posts > Trashed
  6. Tap More
  7. Tap Move to Draft
  8. Tap Publish in the notification ✅ The post is back to Scheduled

Scenario 4

  1. Create a scheduled post
  2. Go to Posts > Scheduled
  3. Tap More
  4. Tap Move to Trash
  5. Go to Posts > Trashed
  6. Tap More
  7. Tap Move to Draft
  8. Edit the post
  9. Tap Update
  10. Tap Publish in the notification ❌ The post stays in Drafts displaying the Local changes message.

tiagomar avatar May 06 '22 17:05 tiagomar

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 the NoticeView on the Posts screen, there is no issue.
  • The inconsistent state is caused due to a mismatch between self.state & self.original.state in AbstractPost.m.
  • I have suspected PostNoticeViewModel ln.226 post.status = .publish as it statically assigns publish and not scheduled. Changing that didn't solve the problem.
  • Another possibility is that in AbstractPost function hasLocalChanges, there is a check isRevision() which returns false if original is nil. I suspect it must be nil but in the bug case it is not so the mismatch results in function returning true/YES.

alpavanoglu avatar May 27 '22 14:05 alpavanoglu

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.

hassaanelgarem avatar Aug 19 '22 12:08 hassaanelgarem

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.

kean avatar May 01 '24 17:05 kean