2022-08-16 15:24:01 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use MediaWiki\Extension\Gadgets\GadgetRepo;
|
2023-12-12 11:48:04 +00:00
|
|
|
use MediaWiki\Extension\Gadgets\MediaWikiGadgetsDefinitionRepo;
|
Goodbye Gadget/Gadget_definition namespaces!
== What ==
* Remove the empty Gadget and Gadget_definition namespaces.
* Remove the "gadgets-definition-edit" user right.
* Remove need for custom namespace permissions that previously
had to extend editsitejs to apply to NS_GADGET.
== Why ==
Simplify the (unused) "GadgetDefinitionNamespaceRepo" backend for
Gadgets 2.0 by making it less radically different from the status quo.
The experimental 2.0 branch will now make use of the "gadget definition"
content model via "MediaWiki:Gadgets/<id>.json" pages, instead of
through a dedicated namespace.
When I first worked the Gadgets 2.0 branch, content models
were not a thing in MediaWiki, and interface-admin wasn't a thing yet
either. Now that we have per-page permissions and per-page content
models, we don't really need a separate namespace.
This follows the principle of least surprise, and fits well with other
interface admin and site configuration tools such as:
- Citoid, MediaWiki:Citoid-template-type-map.json,
- VisualEditor, MediaWiki:Visualeditor-template-tools-definition.json,
- AbuseFilter, MediaWiki:BlockedExternalDomains.json,
- the upcoming "Community Config" initiative.
If/when we develop the SpecialPage GUI for editing gadget definitions,
this can save its data to these pages the same as it would in
any other namespace. Similar to how Special:BlockedExternalDomains
operates on MediaWiki:BlockedExternalDomains.json.
See also bf1d6b3e93 (I6ffd5e9467), which recently removed the
gadgets-edit user right in favour of the editsite{css,js,json} rights.
Change-Id: I5b04ab251552e839087d0a8a6923d205adc7f771
2023-12-05 23:28:45 +00:00
|
|
|
use MediaWiki\Extension\Gadgets\MediaWikiGadgetsJsonRepo;
|
2023-12-08 21:33:19 +00:00
|
|
|
use MediaWiki\Extension\Gadgets\MultiGadgetRepo;
|
2022-08-16 15:24:01 +00:00
|
|
|
use MediaWiki\MediaWikiServices;
|
|
|
|
|
|
|
|
return [
|
|
|
|
'GadgetsRepo' => static function ( MediaWikiServices $services ): GadgetRepo {
|
2023-12-12 11:48:04 +00:00
|
|
|
$wanCache = $services->getMainWANObjectCache();
|
|
|
|
$revisionLookup = $services->getRevisionLookup();
|
2024-02-25 02:49:56 +00:00
|
|
|
$dbProvider = $services->getConnectionProvider();
|
2023-12-12 11:48:04 +00:00
|
|
|
switch ( $services->getMainConfig()->get( 'GadgetsRepo' ) ) {
|
|
|
|
case 'definition':
|
2024-02-25 02:49:56 +00:00
|
|
|
return new MediaWikiGadgetsDefinitionRepo( $dbProvider, $wanCache, $revisionLookup );
|
2023-12-12 11:48:04 +00:00
|
|
|
case 'json':
|
2024-02-25 02:49:56 +00:00
|
|
|
return new MediaWikiGadgetsJsonRepo( $dbProvider, $wanCache, $revisionLookup );
|
2023-12-08 21:33:19 +00:00
|
|
|
case 'json+definition':
|
|
|
|
return new MultiGadgetRepo( [
|
2024-02-25 02:49:56 +00:00
|
|
|
new MediaWikiGadgetsJsonRepo( $dbProvider, $wanCache, $revisionLookup ),
|
|
|
|
new MediaWikiGadgetsDefinitionRepo( $dbProvider, $wanCache, $revisionLookup )
|
2023-12-08 21:33:19 +00:00
|
|
|
] );
|
2023-12-12 11:48:04 +00:00
|
|
|
default:
|
|
|
|
throw new InvalidArgumentException( 'Unexpected value for $wgGadgetsRepo' );
|
|
|
|
}
|
2022-08-16 15:24:01 +00:00
|
|
|
},
|
|
|
|
];
|