Page MenuHomePhabricator

Live preview "Show changes" indicates no changes in on new pages
Closed, ResolvedPublic2 Estimated Story Points

Description

  1. Enable live preview in Special:Preferences > Editing
  2. Visit new page, click [Create source] to create
  3. Enter lots of text, [Preview] many times
  4. Much later, wonder if you've saved your latest version yet, so click [Show changes]

Result: nothing is displayed, so you assume you've made no changes and quit your browser, and all your work is lost.

Expected result: please please do what regular [Show changes] does and display

  Latest revision       Your text
Line 1: 	    Line 1:
(nothing)           + lots of text
                    + lots more text

so I know that I haven't actually saved the page yet.


From T176558:

Steps to reproduce:

  1. Go to Preferences > Editing , ensure that "Show previews without reloading the page" is checked
  2. Go to edit the source of a non-existing page, e.g. https://en.wikipedia.org/w/index.php?title=asdffdsa&action=edit&debug=true
  3. Enter a few words into the main textbox
  4. Click the button "Show changes"

Expected results:

  • The diff is shown above

Actual results:

  • The spinner is briefly shown, and a warning is logged to the console (see below)

Error in the console:

TypeError: response[0].query.pages[0].revisions is undefined

Event Timeline

Spage raised the priority of this task from to High.
Spage updated the task description. (Show Details)
Spage subscribed.

Yeah this is a difference in behavior between the api and the edit page.
It mostly has to do with the fact that the diff api is a subpart of the revisions api. And for a new article, there is no revision yet of course...

https://en.wikipedia.org/w/api.php?action=help&modules=query%2Brevisions

TheDJ added a project: MediaWiki-API.

And the API bug here is?

TheDJ added a project: MediaWiki-API.

And the API bug here is?

There is a disjunct between editing page abilities and api abilities. That seems to me like a shared problem, that both tags should get an opportunity to discuss.

Probably the thing to do here is to add fromtext and totext (and possibly frompst and topst) to action=compare.

Change 236078 had a related patch set uploaded (by TheDJ):
[WIP] API: Compare should be able to deal with text

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

Ricordisamoa renamed this task from Show changes in Live preview indicates no changes in a brand new file, data loss results to Show changes in Live preview indicates no changes in a brand new page, data loss results.Mar 31 2016, 2:33 AM
Ricordisamoa subscribed.

Change 236078 abandoned by TheDJ:
[WIP] API: Compare should be able to deal with text

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

MusikAnimal renamed this task from Show changes in Live preview indicates no changes in a brand new page, data loss results to Live preview "Show changes" indicates no changes in on new pages.Sep 8 2021, 10:43 PM
MusikAnimal updated the task description. (Show Details)
MusikAnimal subscribed.

Change 723258 had a related patch set uploaded (by Daimona Eaytoy; author: Daimona Eaytoy):

[mediawiki/core@master] Unbreak live preview for page creations

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

Daimona changed the point value for this task from 1 to 2.Sep 24 2021, 1:11 PM

QA notes: as part of this change, we switched from using ApiQueryRevisions to ApiCompare. As such, it'd be great if you could also ensure that the output live preview is (still) correct and consistent with that of the normal preview. In particular, this includes section edits (create a page with some sections and click the "edit section" link next to a section, instead of the "edit" link at the top), that were changed with the patch above. Thanks!

Change 723258 merged by jenkins-bot:

[mediawiki/core@master] Unbreak \"show changes\" in live preview for page creations

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

@Daimona Testing on beta, while editing a pre-existing page (for example), if I click "Show changes" the response from ApiCompare includes:

{"warnings":{"main":{"*":"Unrecognized parameter: fromcontentmodel-main."}} ...

Similarly, while editing a section (for example) the response includes:

{"warnings":{"main":{"*":"Unrecognized parameters: fromcontentmodel-main, fromsection-main."}} ...

There are no warnings when creating a new page.

EDIT:
I am also finding on Commons that the "Show changes" also shows data for the mediainfo slot of a revision (for example, this image). The API response also shows the same warnings as above.

mediainfo_slot_show_changes.png (1×1 px, 122 KB)

It does not appear with "normal" previews.

Hard to tell if this is a regression, because prod Commons is now on the latest version, and I don't have an environment to test the previous version.

@Daimona Testing on beta, while editing a pre-existing page (for example), if I click "Show changes" the response from ApiCompare includes:

{"warnings":{"main":{"*":"Unrecognized parameter: fromcontentmodel-main."}} ...

Similarly, while editing a section (for example) the response includes:

{"warnings":{"main":{"*":"Unrecognized parameters: fromcontentmodel-main, fromsection-main."}} ...

There are no warnings when creating a new page.

EDIT:
I am also finding on Commons that the "Show changes" also shows data for the mediainfo slot of a revision (for example, this image). The API response also shows the same warnings as above.

mediainfo_slot_show_changes.png (1×1 px, 122 KB)

It does not appear with "normal" previews.

Hard to tell if this is a regression, because prod Commons is now on the latest version, and I don't have an environment to test the previous version.

I think all of this issues have the same cause: we're not setting the "fromslots" parameter. This is why "fromcontentmodel-main" is not recognized. And of course it includes all slots from the base page. We're already setting the param for article creations. This should be an easy fix.

Change 725011 had a related patch set uploaded (by Daimona Eaytoy; author: Daimona Eaytoy):

[mediawiki/core@master] Always pass \"fromslot\" to ApiCompare in live preview

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

I changed the patch above to only avoid the API warning. To fix the issue on commons we would need to only use the main slot from when passing "fromtitle". However, this doesn't seem to be possible, if my understanding of the documentation is correct.

I ran the old API request on commons (link) and it seems to be a regression.

To fix the issue on commons we would need to only use the main slot from when passing "fromtitle". However, this doesn't seem to be possible, if my understanding of the documentation is correct.

It is possible, for some reason I didn't notice the "slots" parameter in the documentation. Updated the patch above to use it. So, with the patch above, both the API warnings and the MCR diffs are fixed.

Change 725011 merged by jenkins-bot:

[mediawiki/core@master] Fix API warning in live preview

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

Bug in the description no longer occurs. While creating a new page, Live Preview will display any changes you have made as appropriate.

QA notes: as part of this change, we switched from using ApiQueryRevisions to ApiCompare. As such, it'd be great if you could also ensure that the output live preview is (still) correct and consistent with that of the normal preview. In particular, this includes section edits (create a page with some sections and click the "edit section" link next to a section, instead of the "edit" link at the top), that were changed with the patch above. Thanks!

I have compared the output of Live and normal previews. The only differences I found were those mentioned here T293022#7431771 (I will raise a separate bug, as there are a couple of places where a similar thing happens).

I did this also for section edits, new and existing pages, and pages with Multi-Content_Revisions.

Test environment: Various. Most recently: https://en.wikipedia.beta.wmflabs.org MediaWiki 1.38.0-alpha (66e58d1) 03:30, 19 October 2021.

Nardog removed a project: Patch-For-Review.
Daimona added a subscriber: NRodriguez.

(Reopening for @NRodriguez to sign off)

Great work, unable to reproduce, thanks for the great documentation on steps in the ticket