wordpress-mobile / wordpress-mobile/WordPress-Android
Bug: ReaderPostDetailFragment - method "updatePost", wired behaviour '[Type] Bug'
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 3.2k
- Forks
- 1.4k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 69
Description
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
-
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 )
-
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 )
-
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 ]
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in ReaderPostDetailFragment at updatePost and handleUpdatePostResponse, then trace ReaderPostTable.updatePost and its addOrUpdatePosts call using the tbl_posts table. Reproduce the refresh sequence described on Android and inspect why a null tag creates a second row. Done means repeated refreshes leave one post row and the Reader and detail views show the latest values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, kotlin
- Domain
- database, mobile
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100