use MediaWiki\MediaWikiServices;
use MediaWiki\Revision\MutableRevisionRecord;
use MediaWiki\Revision\RevisionRecord;
+use MediaWiki\Revision\RevisionArchiveRecord;
use MediaWiki\Revision\RevisionStore;
use MediaWiki\Revision\SlotRecord;
if ( !$fromRelRev ) {
$this->dieWithError( 'apierror-compare-relative-to-nothing' );
}
+ if ( $params['torelative'] !== 'cur' && $fromRelRev instanceof RevisionArchiveRecord ) {
+ // RevisionStore's getPreviousRevision/getNextRevision blow up
+ // when passed an RevisionArchiveRecord for a deleted page
+ $this->dieWithError( [ 'apierror-compare-relative-to-deleted', $params['torelative'] ] );
+ }
switch ( $params['torelative'] ) {
case 'prev':
// Swap 'from' and 'to'
"apierror-compare-nofromrevision": "No 'from' revision. Specify <var>fromrev</var>, <var>fromtitle</var>, or <var>fromid</var>.",
"apierror-compare-notext": "Parameter <var>$1</var> cannot be used without <var>$2</var>.",
"apierror-compare-notorevision": "No 'to' revision. Specify <var>torev</var>, <var>totitle</var>, or <var>toid</var>.",
+ "apierror-compare-relative-to-deleted": "Cannot use <kbd>torelative=$1</kbd> relative to a deleted revision.",
"apierror-compare-relative-to-nothing": "No 'from' revision for <var>torelative</var> to be relative to.",
"apierror-contentserializationexception": "Content serialization failed: $1",
"apierror-contenttoobig": "The content you supplied exceeds the article size limit of $1 {{PLURAL:$1|kilobyte|kilobytes}}.",
"apierror-compare-nofromrevision": "{{doc-apierror}}",
"apierror-compare-notext": "{{doc-apierror}}\n\nParameters:\n* $1 - Parameter that is not allowed without <var>totext-{role}</var>/<var>fromtext-{role}</var>.\n* $2 - The specific <var>totext-{role}</var>/<var>fromtext-{role}</var> parameter that must be present.",
"apierror-compare-notorevision": "{{doc-apierror}}",
+ "apierror-compare-relative-to-deleted": "{{doc-apierror}}",
"apierror-compare-relative-to-nothing": "{{doc-apierror}}",
"apierror-contentserializationexception": "{{doc-apierror}}\n\nParameters:\n* $1 - Exception text, may end with punctuation. Currently this is probably English, hopefully we'll fix that in the future.",
"apierror-contenttoobig": "{{doc-apierror}}\n\nParameters:\n* $1 - Maximum article size in kilobytes.",
[],
'nosuchrevid',
],
+ 'Error, deleted revision ID and torelative=prev' => [
+ [
+ 'fromrev' => '{{REPL:revC2}}',
+ 'torelative' => 'prev',
+ ],
+ [],
+ 'compare-relative-to-deleted', true
+ ],
+ 'Error, deleted revision ID and torelative=next' => [
+ [
+ 'fromrev' => '{{REPL:revC2}}',
+ 'torelative' => 'next',
+ ],
+ [],
+ 'compare-relative-to-deleted', true
+ ],
+ 'Deleted revision ID and torelative=cur' => [
+ [
+ 'fromrev' => '{{REPL:revC2}}',
+ 'torelative' => 'cur',
+ ],
+ [],
+ 'nosuchrevid', true
+ ],
'Error, revision-deleted content' => [
[
'fromrev' => '{{REPL:revA2}}',