mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-23 22:13:34 +00:00
VisualEditorEdit diffs should only compare the main slot
We diff only on provided wikitext. This was causing inaccurate diffs on pages with slotted content (e.g. File: pages on commons), which would claim the edit would delete all the slot contents other than the wikitext in main. Also, remove the very old backwards compatibility params that were being passed to getResultData in this method. Bug: T351235 Change-Id: I135082162b96503e8d896aa4014abc9f4b936580
This commit is contained in:
parent
e880db34a0
commit
b71a34cce5
|
@ -24,6 +24,7 @@ use IDBAccessObject;
|
|||
use MediaWiki\Logger\LoggerFactory;
|
||||
use MediaWiki\Page\WikiPageFactory;
|
||||
use MediaWiki\Request\DerivativeRequest;
|
||||
use MediaWiki\Revision\SlotRecord;
|
||||
use MediaWiki\SpecialPage\SpecialPageFactory;
|
||||
use MediaWiki\Storage\PageEditStash;
|
||||
use MediaWiki\Title\Title;
|
||||
|
@ -338,10 +339,13 @@ class ApiVisualEditorEdit extends ApiBase {
|
|||
$apiParams = [
|
||||
'action' => 'compare',
|
||||
'prop' => 'diff',
|
||||
// Because we're just providing wikitext, we only care about the main slot
|
||||
'slots' => SlotRecord::MAIN,
|
||||
'fromtitle' => $title->getPrefixedDBkey(),
|
||||
'fromrev' => $fromId,
|
||||
'fromsection' => $section,
|
||||
'totext' => $wikitext,
|
||||
'toslots' => SlotRecord::MAIN,
|
||||
'totext-main' => $wikitext,
|
||||
'topst' => true,
|
||||
];
|
||||
|
||||
|
@ -358,15 +362,12 @@ class ApiVisualEditorEdit extends ApiBase {
|
|||
/* enable write? */ false
|
||||
);
|
||||
$api->execute();
|
||||
$result = $api->getResult()->getResultData( null, [
|
||||
/* Transform content nodes to '*' */ 'BC' => [],
|
||||
/* Add back-compat subelements */ 'Types' => [],
|
||||
] );
|
||||
$result = $api->getResult()->getResultData();
|
||||
|
||||
if ( !isset( $result['compare']['*'] ) ) {
|
||||
if ( !isset( $result['compare']['bodies'][SlotRecord::MAIN] ) ) {
|
||||
$this->dieWithError( 'apierror-visualeditor-difffailed', 'difffailed' );
|
||||
}
|
||||
$diffRows = $result['compare']['*'];
|
||||
$diffRows = $result['compare']['bodies'][SlotRecord::MAIN];
|
||||
|
||||
$context = new DerivativeContext( $this->getContext() );
|
||||
$context->setTitle( $title );
|
||||
|
|
Loading…
Reference in a new issue