mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/TemplateData
synced 2024-11-27 17:20:01 +00:00
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:
parent
4bb17c89f0
commit
ae0dd0e094
|
@ -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"
|
||||
|
|
|
@ -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 );
|
||||
|
|
Loading…
Reference in a new issue