Page MenuHomePhabricator

Each version of the same page has active 'Save page' option
Closed, ResolvedPublic

Description

Found when checking
T101845
Android app showing cached versions of pages too aggressively

  1. Save a page in Saved pages
  2. Edit the page and there will be 'Save page' option available again.

As a result, 'Saved pages' display the same entry multiple times

Screenshot_2015-06-12-13-52-32.jpg (1×800 px, 117 KB)

Note: Each entry in 'Saved pages' shows the same content.

Event Timeline

Etonkovidova raised the priority of this task from to Needs Triage.
Etonkovidova updated the task description. (Show Details)
Etonkovidova subscribed.

If a page was updated, then after 'Refresh page', it can be saved. After that, clicking on the page from Saved pages, brings up a page that can be saved again.

Screenshot_2015-06-12-14-47-04.jpg (1×800 px, 127 KB)

Etonkovidova renamed this task from Each version of the same page has 'Save page' option to Each version of the same page has active 'Save page' option.Jun 15 2015, 7:57 PM
Etonkovidova set Security to None.

So, there are a couple of different things going on here. First, the app doesn't reliably know when it's on a saved page. Second, because of yet another instance of our null namespace problem[0], the app allows saving duplicate entries for non-mainspace entries.

To deal with the first problem, I removed the existing code dealing with page save state[1] and implemented a check over the saved pages in the db when the options menu is prepared to determine whether the current page is in fact a saved page. (If this is too expensive, then we'll have find another way; I experimented with maintaining page saved state as a property of a PageTitle but that proved unreliable.[2])

For the second, testing showed that duplicate entries are only saved for pages outside mainspace. If the query is changed to take namespace into account[3], then duplicate entries are only saved for mainspace pages and not for others. Until we figure out how to deal with null namespace values[4], we'll have to accept one or the other, and allowing duplicate saves only for non-mainspace pages -- i.e., the current behavior -- seems like the lesser evil.

Patch to follow.

[0] See T105472.

[1] This previous code did not actually keep track of page save state but set it as saved when navigating from the saved pages fragment or when refreshing after saving a page. As such, it failed to detect when the user navigated to a saved page from other sources, e.g., an ordinary search.

[2] Fire up the debugger and put a break point in PageFragment.onPrepareOptionsMenu, for instance, and you'll find that when a new page is loaded, it's called twice, with two different PageTitle objects returned by model.getTitle()....

[3] I.e., by making the equivalent changes to these: https://gerrit.wikimedia.org/r/#/c/227068/2/wikipedia/src/main/java/org/wikipedia/history/HistoryEntryPersistenceHelper.java.

[4] See my earlier discussion at https://gerrit.wikimedia.org/r/#/c/228291/ and https://gerrit.wikimedia.org/r/#/c/229319/.

Change 229959 had a related patch set uploaded (by Mholloway):
WIP: Fix saved page logic

https://gerrit.wikimedia.org/r/229959

Change 230129 had a related patch set uploaded (by Mholloway):
WIP: Add db query support for null selection arguments

https://gerrit.wikimedia.org/r/230129

Change 231325 had a related patch set uploaded (by Mholloway):
WIP: Update SQL query generation to handle mainspace and other null params

https://gerrit.wikimedia.org/r/231325

Change 230129 abandoned by Mholloway:
Add db query support for null selection arguments

Reason:
Dropping in favor of https://gerrit.wikimedia.org/r/#/c/231325/.

https://gerrit.wikimedia.org/r/230129

Change 231325 merged by jenkins-bot:
Update SQL query generation to handle mainspace and other null params

https://gerrit.wikimedia.org/r/231325

Change 229959 merged by jenkins-bot:
Check if page is saved in DB when preparing 'save page' options menu item

https://gerrit.wikimedia.org/r/229959

Checked with 2.0.110-alpha-2015-09-09 on Nexus 5(Android 5.1.1)

Dbrant subscribed.