Use RevisionRecordCallback in ParserOptions, require MW 1.35+

Bug: T249384
Change-Id: I36b7a57278f9c32040180fc885827731a2d94098
This commit is contained in:
DannyS712 2020-04-17 16:59:59 +00:00
parent f1d183cc18
commit c74a26d111
2 changed files with 14 additions and 12 deletions

View file

@ -13,7 +13,7 @@
"manifest_version": 2,
"load_composer_autoloader": true,
"requires": {
"MediaWiki": ">= 1.31.0"
"MediaWiki": ">= 1.35.0"
},
"MessagesDirs": {
"TemplateStyles": [

View file

@ -1,6 +1,8 @@
<?php
use MediaWiki\MediaWikiServices;
use MediaWiki\Revision\MutableRevisionRecord;
use MediaWiki\Revision\SlotRecord;
/**
* @group TemplateStyles
@ -162,20 +164,20 @@ class TemplateStylesHooksTest extends MediaWikiLangTestCase {
'wgArticlePath' => '/wiki/$1',
] );
$oldCurrentRevisionCallback = $popt->setCurrentRevisionCallback(
function ( Title $title, $parser = false ) use ( &$oldCurrentRevisionCallback ) {
$oldCurrentRevisionRecordCallback = $popt->setCurrentRevisionRecordCallback(
function ( Title $title, $parser = null ) use ( &$oldCurrentRevisionRecordCallback ) {
if ( $title->getPrefixedText() === 'Template:Test replacement' ) {
$user = RequestContext::getMain()->getUser();
return new Revision( [
'page' => $title->getArticleID(),
'user_text' => $user->getName(),
'user' => $user->getId(),
'parent_id' => $title->getLatestRevID(),
'title' => $title,
'content' => new TemplateStylesContent( '.baz { color:orange; bogus:bogus; }' )
] );
$revRecord = new MutableRevisionRecord( $title );
$revRecord->setUser( $user );
$revRecord->setContent(
SlotRecord::MAIN,
new TemplateStylesContent( '.baz { color:orange; bogus:bogus; }' )
);
$revRecord->setParentId( $title->getLatestRevID() );
return $revRecord;
}
return call_user_func( $oldCurrentRevisionCallback, $title, $parser );
return call_user_func( $oldCurrentRevisionRecordCallback, $title, $parser );
}
);