wordpress-mobile / WordPress-Android

WordPress for Android
http://android.wordpress.org
GNU General Public License v2.0
2.96k stars 1.31k forks source link

Bug: ReaderPostDetailFragment - method "updatePost", wired behaviour '[Type] Bug' #11036

Open dukemarquis opened 4 years ago

dukemarquis commented 4 years ago

Expected behavior

in the method "updatePost" of ReaderPostDetailFragment, it triggers REST API to get the latest version of this post. After getting the newer version, in the "handleUpdatePostResponse" method, it triggers "ReaderPostTable.updatePost" method, that is where the wired behaviour comes.

wired behaviour :

in this method, first it updates the local tbl_posts database depends on the same pseudo_id. yes, in this process, it success updates. but after this, it triggers "addOrUpdatePosts" method with tag = null parameter then it causes the local tbl_posts database to create another post detail with exactly same as before except keep "tag" colomn empty.

for now, the local tbl_posts database has two rows with all the same information except different "tag" colomn. if i use my phone to navigate back to "Reader" page and refresh this page and at this time, if the owner of this post has changed this post (etc, text), i will get the newer text in the "Reader" page, but if i click this post and navigate to the detail page of this post, the detail page value won't change because this detail page uses data of "Old - unchanged row of this post" from the tbl_posts database.

i think this problem relates to the "2 same rows of the same post" in tbl_posts.

Steps to reproduce the behavior

  1. use your phone go the any post detail page, at this time, change this post text value or num_of_likes value, and use swipe refresh to refresh this detail page. ( now, the local tbl_post database will have two rows of the same post )

  2. then, return to Reader page in wordpress, change this post text or num_of_like value again, using swipe to refresh to refresh Reader page. ( now,the local tbl_post with two same rows of the same post will be different in the colomn of the value just changed )

  3. if you go back to the detail page of this post again, you will find the value is different between this detail page and Reader page.

Tested on [ Pixel 3 ], Android [ API 29 ], WPAndroid [ 13.9 rc ]
designsimply commented 4 years ago

I tried testing this and found that the Reader post detail page does refresh but only after you leave and come back. Here are the testing steps I did:

  1. In Safari, open an existing post and open the post for editing.
  2. Make a change to the post text, save, and exit.
  3. View the post and pull to refresh to see the change if needed.
  4. In the app, edit the post and make another edit to the text. Save changes.
  5. Go to Reader and find the post and tap on it to open the post detail view.
  6. Pull to refresh and notice that the latest text update made in the app is not showing.
  7. Go back to the main Reader stream and notice that the text is updated there.
  8. Go back to the post detail stream in the Reader and notice that the text is update there now too.

Results: posts updated after they are viewed in the Reader are not updated until you view the post and leave that view and go back. (1m34s)

Are my steps matching with yours? I wasn't sure about a few things in first testing step:

use your phone go the any post detail page

It's possible to go to the post detail page in multiple ways. I assumed that "use your phone" meant to use the browser on the phone in this case.

at this time, change this post text value or num_of_likes value

I assumed that editing the post directly is what you meant here.

use swipe refresh to refresh this detail page

I assumed you meant to go back to the published post in a browser on the phone.

The next step I'd like to take for this issue is to verify the exact testing steps, in detail, to confirm that I have them right and I would also like to know if the post does get updated if you repeat the process and then leave the detail post view and then go back.

dukemarquis commented 4 years ago

my english is not very well, so sorry about some intricate expressions throughout my comment.

the right process is:

  1. in the mobile app end, open one post detail page and hanging there.
  2. to edit that post in website end or change that post data in remote server database directly (in my experiment, i change this post data in server database directly).
  3. return to the mobile end, in the post detail page, swipe to refresh. (at this step, you don't need to check if the data has been updated, this step creates 2 different rows with same 'post_id' in 'tbl_post' table on your mobile)
  4. still in the mobile end, return to the 'Reader' page, hanging in there.
  5. at this time, change the post data again in website end or remote server database directly.
  6. return to the mobile end, refresh the 'Reader' page, yes, you will get the updated result of the post in 'Reader' page. (at this time, only one row in 'tbl_post' table has been updated, leaving the other row stale)
  7. now, in the 'Reader' page, click this post and go to this post's detail page, the detail page data will not change or update because this detail page get the data from 'the stale row' in 'tbl_post' table.
  8. only if you swipe to refresh in the detail page (update the stale row in 'tbl_post' table) and go back to 'Reader' page and then go back to the detail page again, you will now get the updated data.

I think probably this is not an obviouly bug, it is something like a user experience issue. i guess maybe we can refresh all the row that have same 'post_id' in 'tbl_post' if the user swipe to refresh in 'Reader' page. because if the user already refresh the 'Reader' page and click the post to go to the detail page and see the data is not synchronous, they will feel wired.

dukemarquis commented 4 years ago

sorry i click the close issue button accidentally