Get WikiPageFactory and LanguageNameUtils from services

The bump to 1.36 was overdue because the PageProps are used from
services already.

Change-Id: Ic4b42f58290e15123b281d48be396e8b7e8eeab0
This commit is contained in:
WMDE-Fisch 2020-12-15 12:06:18 +01:00 committed by Thiemo Kreuz
parent 4bb17c89f0
commit ae0dd0e094
2 changed files with 6 additions and 3 deletions

View file

@ -15,7 +15,7 @@
"license-name": "GPL-2.0-or-later",
"type": "parserhook",
"requires": {
"MediaWiki": ">= 1.33.0"
"MediaWiki": ">= 1.36.0"
},
"APIModules": {
"templatedata": "ApiTemplateData"

View file

@ -6,6 +6,7 @@
* @file
*/
use MediaWiki\MediaWikiServices;
use MediaWiki\Revision\RevisionRecord;
/**
@ -49,6 +50,7 @@ class ApiTemplateData extends ApiBase {
* @inheritDoc
*/
public function execute() {
$services = MediaWikiServices::getInstance();
$params = $this->extractRequestParams();
$result = $this->getResult();
@ -57,7 +59,7 @@ class ApiTemplateData extends ApiBase {
if ( $params['lang'] === null ) {
$langCode = false;
} elseif ( !Language::isValidCode( $params['lang'] ) ) {
} elseif ( !$services->getLanguageNameUtils()->isValidCode( $params['lang'] ) ) {
$this->dieWithError( [ 'apierror-invalidlang', 'lang' ] );
throw new LogicException();
} else {
@ -153,7 +155,8 @@ class ApiTemplateData extends ApiBase {
// Ignore pages that already have templatedata or that don't exist.
continue;
}
$content = WikiPage::factory( $pageInfo['title'] )
$content = $services->getWikiPageFactory()
->newFromTitle( $pageInfo['title'] )
->getContent( RevisionRecord::FOR_PUBLIC )
->getNativeData();
$resp[ $pageId ][ 'params' ] = TemplateDataBlob::getRawParams( $content );