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", "license-name": "GPL-2.0-or-later",
"type": "parserhook", "type": "parserhook",
"requires": { "requires": {
"MediaWiki": ">= 1.33.0" "MediaWiki": ">= 1.36.0"
}, },
"APIModules": { "APIModules": {
"templatedata": "ApiTemplateData" "templatedata": "ApiTemplateData"

View file

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