Expose WikiPage.php's replaceSectionAtRev function through the API
Open, NormalPublic1 Story Points

Jdforrester-WMF updated the task description. (Show Details)
Jdforrester-WMF raised the priority of this task from to Normal.
Jdforrester-WMF added a subscriber: Jdforrester-WMF.
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptNov 4 2015, 4:23 PM
Elitre added a subscriber: Elitre.Nov 19 2015, 4:05 PM

Hmm… action=edit&section=N? :D

What does replaceSectionAtRev do? Let me guess, it lets you replace a specific section in a specific revision of a page? Is there something specific we plan to use this functionality for?

What does replaceSectionAtRev do? Let me guess, it lets you replace a specific section in a specific revision of a page?

Indeed.

Is there something specific we plan to use this functionality for?

Yes, this is for the parent task.

Right now if you start editing a section in source mode, it loads only that section's wikitext. This means the editor doesn't have access to the rest of the page; consequently, it can't let the user switch to editing visually (which requires access to the whole page for contextual information like access to references and categories, link numbering, and a bunch of other page-wide features).

When you submit a wikitext section edit, the content transmitted is the new wikitext plus the revision and section reference sufficient to locate and replace said section's content (which is how it knows when you edit conflict, amongst other things). But this call is made inside MediaWiki and not available through the API, so we can't use this tool to get the "new" page-wide wikitext from which to edit visually.

Consequently, switching from source mode to visual mode whilst editing a section is currently a destructive act, which is irritating for users and shouldn't be needed. Yet another example of MW's APIs being insufficient for client-equivalence to the "real" (desktop) interface, and how we've had to build it as we've gone along.