Page MenuHomePhabricator

Add option to ApiQueryRevisions to do the pre-save transform on rvdifftotext before diffing
Closed, ResolvedPublic

Description

This feature is in the parse API, allowing you to perform a pre-save transform on the text before parsing it.
This is useful for things such as AJAX diff previews, where currently you have to do a normal page-reloading preview if you want to see PST things such as subst templates and signatures, or make two API requests.

Details

Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 1:43 AM
bzimport set Reference to bz51155.
bzimport added a subscriber: Unknown Object (MLST).

As stated, this request doesn't make any sense. The content being parsed by rvparse is what is already saved in the database, so it has already had the pre-save transform done on it before it was saved (hence the name "pre-save transform"). There's no reason to do the PST on it again.

But it seems like what you really want is an option to perform the PST on the text passed to rvdifftotext before doing the diff, which could make a sort of sense. But the option shouldn't be named "rvparsepst" or "rvparseonlypst", it should be named something like "rvdifftotextpst" to associate it with what it applies to. I've taken the liberty of changing the bug title accordingly; if you disagree, feel free to revert and we'll go from there.

Actually doing the PST then should be easy enough, you just need to call $difftocontent->preSaveTransform( ... ) in between creating $difftocontent and handing it off to the difference engine. All this is currently around line 600 of ApiQueryRevisions.php.

Sorry, I was misinterpreting the API docs, difftotext is what I meant. Thanks!

Since no one else has done this yet, I had a go at it and submitted the patch through the uploader.

https://gerrit.wikimedia.org/r/#/c/122327/

Change 122327 had a related patch set uploaded (by Anomie):
Add pst option to API difftotext

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

Patch-For-Review

This would also be convenient for the live preview in MediaWiki (resources/src/mediawiki.action/mediawiki.action.edit.preview.js), where we currently need two API requests to display the diff (first to PST, second to actually diff).

Rebased and updated patch to add release notes and get parser options in a better way.

A review before this gets outdated and needs rebasing again would be nice.

Majr set Security to None.

Change 122327 merged by jenkins-bot:
Add pst option to API difftotext

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

Should go out to WMF wikis with 1.27.0-wmf.4, see https://www.mediawiki.org/wiki/MediaWiki_1.27/Roadmap for the schedule.