Merge "Namespace extension"

This commit is contained in:
jenkins-bot 2021-11-29 14:28:28 +00:00 committed by Gerrit Code Review
commit 6e4a3788b5
9 changed files with 65 additions and 21 deletions

View file

@ -1,4 +1,7 @@
{
"require": {
"ext-zlib": "*"
},
"require-dev": {
"mediawiki/mediawiki-codesniffer": "38.0.0",
"mediawiki/mediawiki-phan-config": "0.11.0",

View file

@ -18,22 +18,19 @@
"MediaWiki": ">= 1.38.0"
},
"APIModules": {
"templatedata": "ApiTemplateData"
"templatedata": "MediaWiki\\Extension\\TemplateData\\Api\\ApiTemplateData"
},
"AutoloadClasses": {
"TemplateDataHooks": "includes/TemplateDataHooks.php",
"TemplateDataBlob": "includes/TemplateDataBlob.php",
"TemplateDataCompressedBlob": "includes/TemplateDataCompressedBlob.php",
"ApiTemplateData": "includes/api/ApiTemplateData.php"
"AutoloadNamespaces": {
"MediaWiki\\Extension\\TemplateData\\": "includes/"
},
"Hooks": {
"EditPage::showEditForm:fields": "TemplateDataHooks::onEditPageShowEditFormFields",
"ParserFirstCallInit": "TemplateDataHooks::onParserFirstCallInit",
"MultiContentSave": "TemplateDataHooks::onMultiContentSave",
"ResourceLoaderRegisterModules": "TemplateDataHooks::onResourceLoaderRegisterModules",
"EditPage::showEditForm:initial": "TemplateDataHooks::onEditPage",
"ParserFetchTemplateData": "TemplateDataHooks::onParserFetchTemplateData",
"MakeGlobalVariablesScript": "TemplateDataHooks::onMakeGlobalVariablesScript"
"EditPage::showEditForm:fields": "MediaWiki\\Extension\\TemplateData\\Hooks::onEditPageShowEditFormFields",
"ParserFirstCallInit": "MediaWiki\\Extension\\TemplateData\\Hooks::onParserFirstCallInit",
"MultiContentSave": "MediaWiki\\Extension\\TemplateData\\Hooks::onMultiContentSave",
"ResourceLoaderRegisterModules": "MediaWiki\\Extension\\TemplateData\\Hooks::onResourceLoaderRegisterModules",
"EditPage::showEditForm:initial": "MediaWiki\\Extension\\TemplateData\\Hooks::onEditPage",
"ParserFetchTemplateData": "MediaWiki\\Extension\\TemplateData\\Hooks::onParserFetchTemplateData",
"MakeGlobalVariablesScript": "MediaWiki\\Extension\\TemplateData\\Hooks::onMakeGlobalVariablesScript"
},
"MessagesDirs": {
"TemplateData": [

View file

@ -6,7 +6,18 @@
* @file
*/
namespace MediaWiki\Extension\TemplateData\Api;
use ApiBase;
use ApiContinuationManager;
use ApiFormatBase;
use ApiPageSet;
use ApiResult;
use EventLogging;
use ExtensionRegistry;
use MediaWiki\Extension\TemplateData\TemplateDataBlob;
use MediaWiki\MediaWikiServices;
use TextContent;
/**
* @ingroup API

View file

@ -1,10 +1,26 @@
<?php
namespace MediaWiki\Extension\TemplateData;
use CommentStoreComment;
use EditPage;
use EventLogging;
use ExtensionRegistry;
use Html;
use MediaWiki\MediaWikiServices;
use MediaWiki\Revision\RenderedRevision;
use MediaWiki\Revision\RevisionRecord;
use MediaWiki\Revision\SlotRecord;
use MediaWiki\User\UserIdentity;
use OutputPage;
use Parser;
use ParserOutput;
use PPFrame;
use RequestContext;
use ResourceLoader;
use Status;
use Title;
use WikiPage;
/**
* Hooks for TemplateData extension
@ -13,7 +29,7 @@ use MediaWiki\User\UserIdentity;
* @ingroup Extensions
*/
class TemplateDataHooks {
class Hooks {
/**
* @param EditPage $editPage
@ -228,7 +244,7 @@ class TemplateDataHooks {
* This will be resolved separately.
*
* @param array $tplTitles
* @param stdclass[] &$tplData
* @param \stdClass[] &$tplData
*/
public static function onParserFetchTemplateData( array $tplTitles, array &$tplData ): void {
$tplData = [];

View file

@ -3,7 +3,14 @@
* @file
* @ingroup Extensions
*/
namespace MediaWiki\Extension\TemplateData;
use Html;
use Language;
use MediaWiki\MediaWikiServices;
use Status;
use stdClass;
use Wikimedia\Rdbms\IDatabase;
/**
@ -769,7 +776,7 @@ class TemplateDataBlob {
Html::rawElement(
'p',
[],
new OOUI\IconWidget( [ 'icon' => $icon ] )
new \OOUI\IconWidget( [ 'icon' => $icon ] )
. Html::element(
'span',
[ 'class' => 'mw-templatedata-format' ],

View file

@ -4,6 +4,10 @@
* @ingroup Extensions
*/
namespace MediaWiki\Extension\TemplateData;
use Status;
/**
* Represents the information about a template,
* coming from the JSON blob in the <templatedata> tags

View file

@ -6,6 +6,8 @@ if ( $IP === false ) {
}
require_once "$IP/maintenance/Maintenance.php";
use MediaWiki\Extension\TemplateData\TemplateDataBlob;
class ValidateTemplateData extends Maintenance {
public function __construct() {

View file

@ -1,8 +1,10 @@
<?php
use MediaWiki\Extension\TemplateData\Hooks as TemplateDataHooks;
/**
* @group TemplateData
* @covers \TemplateDataHooks
* @covers \MediaWiki\Extension\TemplateData\Hooks
*/
class SerializationTest extends MediaWikiIntegrationTestCase {
public function testParserOutputPersistenceForwardCompatibility() {
@ -15,7 +17,8 @@ class SerializationTest extends MediaWikiIntegrationTestCase {
// Set JSONified state. Should work before we set JSON-serializable data,
// to be robust against old code reading new data after a rollback.
$output->setExtensionData( 'TemplateDataStatus',
TemplateDataHooks::jsonSerializeStatus( $status ) );
TemplateDataHooks::jsonSerializeStatus( $status )
);
$result = TemplateDataHooks::getStatusFromParserOutput( $output );
$this->assertEquals( $status->getStatusValue(), $result->getStatusValue() );

View file

@ -1,12 +1,13 @@
<?php
use MediaWiki\Extension\TemplateData\TemplateDataBlob;
use Wikimedia\TestingAccessWrapper;
/**
* @group TemplateData
* @group Database
* @covers \TemplateDataBlob
* @covers \TemplateDataCompressedBlob
* @covers \MediaWiki\Extension\TemplateData\TemplateDataBlob
* @covers \MediaWiki\Extension\TemplateData\TemplateDataCompressedBlob
*/
class TemplateDataBlobTest extends MediaWikiIntegrationTestCase {
@ -843,7 +844,7 @@ class TemplateDataBlobTest extends MediaWikiIntegrationTestCase {
// up calling gzdecode().
$gzJson = gzencode( '{}' );
$templateData = TemplateDataBlob::newFromDatabase( $this->db, $gzJson );
$this->assertInstanceOf( 'TemplateDataBlob', $templateData );
$this->assertInstanceOf( TemplateDataBlob::class, $templateData );
}
public function provideGetDataInLanguage() {