2015-07-18 22:40:42 +00:00
|
|
|
<?php
|
|
|
|
|
2022-02-06 18:54:47 +00:00
|
|
|
namespace MediaWiki\Extension\Gadgets;
|
|
|
|
|
|
|
|
use InvalidArgumentException;
|
2017-11-07 19:36:44 +00:00
|
|
|
use MediaWiki\Linker\LinkTarget;
|
2021-12-28 21:29:05 +00:00
|
|
|
use MediaWiki\MediaWikiServices;
|
2023-08-19 04:15:51 +00:00
|
|
|
use MediaWiki\Title\Title;
|
2021-12-28 21:29:05 +00:00
|
|
|
use Message;
|
2017-11-07 19:36:44 +00:00
|
|
|
|
2015-07-18 22:40:42 +00:00
|
|
|
abstract class GadgetRepo {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var GadgetRepo|null
|
|
|
|
*/
|
|
|
|
private static $instance;
|
|
|
|
|
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
|
|
|
/** @internal */
|
|
|
|
public const RESOURCE_TITLE_PREFIX = 'MediaWiki:Gadget-';
|
2021-10-17 13:05:15 +00:00
|
|
|
|
2015-07-18 22:40:42 +00:00
|
|
|
/**
|
|
|
|
* Get the ids of the gadgets provided by this repository
|
|
|
|
*
|
2015-08-03 06:37:32 +00:00
|
|
|
* It's possible this could be out of sync with what
|
|
|
|
* getGadget() will return due to caching
|
|
|
|
*
|
2015-07-18 22:40:42 +00:00
|
|
|
* @return string[]
|
|
|
|
*/
|
2022-04-05 17:47:47 +00:00
|
|
|
abstract public function getGadgetIds(): array;
|
2015-07-18 22:40:42 +00:00
|
|
|
|
|
|
|
/**
|
2022-04-05 17:47:47 +00:00
|
|
|
* Get the Gadget object for a given gadget ID
|
2015-07-18 22:40:42 +00:00
|
|
|
*
|
|
|
|
* @param string $id
|
|
|
|
* @return Gadget
|
2022-04-05 17:47:47 +00:00
|
|
|
* @throws InvalidArgumentException For unregistered ID, used by getStructuredList()
|
2015-07-18 22:40:42 +00:00
|
|
|
*/
|
2022-04-05 17:47:47 +00:00
|
|
|
abstract public function getGadget( string $id ): Gadget;
|
2015-07-18 22:40:42 +00:00
|
|
|
|
2017-11-07 19:36:44 +00:00
|
|
|
/**
|
GadgetRepo: Fix missing purging on delete and simplify hook handling
== Motivation ==
On a local dev wiki and in CI, where no gadgets are defined yet,
fetchStructuredList() is called on every load.php request and doing
uncached database look ups. This is because T39228 (stale cache
after Gadgets-definition was empty or created) was fixed by disabling
the cache until the page exists. This seems like a poor solution,
and commit I3092bcb162d032 recognises that the problem was not
understood at the time. I propose to instead cache it always and
purge it when the page is modified in any way.
Cold calling fetchStructuredList() accounted for ~170ms of ~400ms
when trying out debug v2 (T85805), thus making it significantly
slower and causing a chain of dozens of requests to pile up.
== Previously ==
* Legacy repo (MediaWikiGadgetsDefinitionRepo) only implemented
handlePageUpdate.
* handlePageUpdate was called from onPageSaveComplete for both
any page edit, and for creations in the experimental namespace.
* The experimental GadgetDefinitionNamespaceRepo is based on
ContentHandler rather than global hooks. This system does not
have a create-specific callback. It called update for edit/create,
and delete for delete. The experimental repo relied on create being
called from the global hook for the legacy repo, and update was
then called twice.
* There was no global hook for onPageDeleteComplete, thus the
legacy repo did not get purges.
== Changes ==
* Add onPageDeleteComplete hook to fix purges after deletion,
with the legacy repo now implementing handlePageDeletion() and doing
the same as handlePageUpdate().
* Fix handlePageUpdate() docs to reflect that it covers page create,
since onPageSaveComplete() called it either way.
* Fix experimental repo to include its namespace purge in
its handlePageUpdate() method.
* Get rid of now-redundant handlePageCreation().
* Get rid of handlePageDeletion() since its implementations would
now be identical to handlePageUpdate().
All these hooks and handle*() methods are just for a memc key
holding gadget metadata. We don't need to microoptimise this
on a per-page basis. Gadget edits are rare enough that purging them
as a whole each time is fine. We do the same in MediaWiki core
with ResourceLoaderGadgetsModule already.
Bug: T85805
Change-Id: Ib27fd34fbfe7a75c851602c8a93a2e3e1f2c38a0
2022-04-05 18:10:38 +00:00
|
|
|
* Invalidate any caches based on the provided page (after create, edit, or delete).
|
2017-11-07 19:36:44 +00:00
|
|
|
*
|
GadgetRepo: Fix missing purging on delete and simplify hook handling
== Motivation ==
On a local dev wiki and in CI, where no gadgets are defined yet,
fetchStructuredList() is called on every load.php request and doing
uncached database look ups. This is because T39228 (stale cache
after Gadgets-definition was empty or created) was fixed by disabling
the cache until the page exists. This seems like a poor solution,
and commit I3092bcb162d032 recognises that the problem was not
understood at the time. I propose to instead cache it always and
purge it when the page is modified in any way.
Cold calling fetchStructuredList() accounted for ~170ms of ~400ms
when trying out debug v2 (T85805), thus making it significantly
slower and causing a chain of dozens of requests to pile up.
== Previously ==
* Legacy repo (MediaWikiGadgetsDefinitionRepo) only implemented
handlePageUpdate.
* handlePageUpdate was called from onPageSaveComplete for both
any page edit, and for creations in the experimental namespace.
* The experimental GadgetDefinitionNamespaceRepo is based on
ContentHandler rather than global hooks. This system does not
have a create-specific callback. It called update for edit/create,
and delete for delete. The experimental repo relied on create being
called from the global hook for the legacy repo, and update was
then called twice.
* There was no global hook for onPageDeleteComplete, thus the
legacy repo did not get purges.
== Changes ==
* Add onPageDeleteComplete hook to fix purges after deletion,
with the legacy repo now implementing handlePageDeletion() and doing
the same as handlePageUpdate().
* Fix handlePageUpdate() docs to reflect that it covers page create,
since onPageSaveComplete() called it either way.
* Fix experimental repo to include its namespace purge in
its handlePageUpdate() method.
* Get rid of now-redundant handlePageCreation().
* Get rid of handlePageDeletion() since its implementations would
now be identical to handlePageUpdate().
All these hooks and handle*() methods are just for a memc key
holding gadget metadata. We don't need to microoptimise this
on a per-page basis. Gadget edits are rare enough that purging them
as a whole each time is fine. We do the same in MediaWiki core
with ResourceLoaderGadgetsModule already.
Bug: T85805
Change-Id: Ib27fd34fbfe7a75c851602c8a93a2e3e1f2c38a0
2022-04-05 18:10:38 +00:00
|
|
|
* This must be called on create and delete as well (T39228).
|
2017-11-07 19:36:44 +00:00
|
|
|
*
|
|
|
|
* @param LinkTarget $target
|
|
|
|
* @return void
|
|
|
|
*/
|
GadgetRepo: Fix missing purging on delete and simplify hook handling
== Motivation ==
On a local dev wiki and in CI, where no gadgets are defined yet,
fetchStructuredList() is called on every load.php request and doing
uncached database look ups. This is because T39228 (stale cache
after Gadgets-definition was empty or created) was fixed by disabling
the cache until the page exists. This seems like a poor solution,
and commit I3092bcb162d032 recognises that the problem was not
understood at the time. I propose to instead cache it always and
purge it when the page is modified in any way.
Cold calling fetchStructuredList() accounted for ~170ms of ~400ms
when trying out debug v2 (T85805), thus making it significantly
slower and causing a chain of dozens of requests to pile up.
== Previously ==
* Legacy repo (MediaWikiGadgetsDefinitionRepo) only implemented
handlePageUpdate.
* handlePageUpdate was called from onPageSaveComplete for both
any page edit, and for creations in the experimental namespace.
* The experimental GadgetDefinitionNamespaceRepo is based on
ContentHandler rather than global hooks. This system does not
have a create-specific callback. It called update for edit/create,
and delete for delete. The experimental repo relied on create being
called from the global hook for the legacy repo, and update was
then called twice.
* There was no global hook for onPageDeleteComplete, thus the
legacy repo did not get purges.
== Changes ==
* Add onPageDeleteComplete hook to fix purges after deletion,
with the legacy repo now implementing handlePageDeletion() and doing
the same as handlePageUpdate().
* Fix handlePageUpdate() docs to reflect that it covers page create,
since onPageSaveComplete() called it either way.
* Fix experimental repo to include its namespace purge in
its handlePageUpdate() method.
* Get rid of now-redundant handlePageCreation().
* Get rid of handlePageDeletion() since its implementations would
now be identical to handlePageUpdate().
All these hooks and handle*() methods are just for a memc key
holding gadget metadata. We don't need to microoptimise this
on a per-page basis. Gadget edits are rare enough that purging them
as a whole each time is fine. We do the same in MediaWiki core
with ResourceLoaderGadgetsModule already.
Bug: T85805
Change-Id: Ib27fd34fbfe7a75c851602c8a93a2e3e1f2c38a0
2022-04-05 18:10:38 +00:00
|
|
|
public function handlePageUpdate( LinkTarget $target ): void {
|
2017-11-07 19:36:44 +00:00
|
|
|
}
|
|
|
|
|
2021-12-26 21:23:06 +00:00
|
|
|
/**
|
|
|
|
* Given a gadget ID, return the title of the page where the gadget is
|
|
|
|
* defined (or null if the given repo does not have per-gadget definition
|
|
|
|
* pages).
|
|
|
|
*
|
|
|
|
* @param string $id
|
|
|
|
* @return Title|null
|
|
|
|
*/
|
|
|
|
public function getGadgetDefinitionTitle( string $id ): ?Title {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2015-07-18 22:40:42 +00:00
|
|
|
/**
|
2022-04-05 17:47:47 +00:00
|
|
|
* Get a lists of Gadget objects by category
|
2015-07-18 22:40:42 +00:00
|
|
|
*
|
2022-04-05 17:47:47 +00:00
|
|
|
* @return array<string,Gadget[]> `[ 'category' => [ 'name' => $gadget ] ]`
|
2015-07-18 22:40:42 +00:00
|
|
|
*/
|
|
|
|
public function getStructuredList() {
|
2016-12-28 10:25:47 +00:00
|
|
|
$list = [];
|
2015-07-18 22:40:42 +00:00
|
|
|
foreach ( $this->getGadgetIds() as $id ) {
|
2015-08-03 06:37:32 +00:00
|
|
|
try {
|
|
|
|
$gadget = $this->getGadget( $id );
|
|
|
|
} catch ( InvalidArgumentException $e ) {
|
|
|
|
continue;
|
|
|
|
}
|
2015-07-18 22:40:42 +00:00
|
|
|
$list[$gadget->getCategory()][$gadget->getName()] = $gadget;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $list;
|
|
|
|
}
|
|
|
|
|
2021-10-17 13:05:15 +00:00
|
|
|
/**
|
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
|
|
|
* Get the page name without "MediaWiki:Gadget-" prefix.
|
|
|
|
*
|
|
|
|
* This name is used by `mw.loader.require()` so that `require("./example.json")` resolves
|
|
|
|
* to `MediaWiki:Gadget-example.json`.
|
2021-10-17 13:05:15 +00:00
|
|
|
*
|
|
|
|
* @param string $titleText
|
2023-12-08 21:33:19 +00:00
|
|
|
* @param string $gadgetId
|
2021-10-17 13:05:15 +00:00
|
|
|
* @return string
|
|
|
|
*/
|
2023-12-08 21:33:19 +00:00
|
|
|
public function titleWithoutPrefix( string $titleText, string $gadgetId ): string {
|
2021-10-17 13:05:15 +00:00
|
|
|
$numReplaces = 1; // there will only one occurrence of the prefix
|
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
|
|
|
return str_replace( self::RESOURCE_TITLE_PREFIX, '', $titleText, $numReplaces );
|
2021-10-17 13:05:15 +00:00
|
|
|
}
|
|
|
|
|
2021-12-28 21:29:05 +00:00
|
|
|
/**
|
|
|
|
* @param Gadget $gadget
|
|
|
|
* @return Message[]
|
|
|
|
*/
|
|
|
|
public function validationWarnings( Gadget $gadget ): array {
|
|
|
|
// Basic checks local to the gadget definition
|
|
|
|
$warningMsgKeys = $gadget->getValidationWarnings();
|
|
|
|
$warnings = array_map( static function ( $warningMsgKey ) {
|
|
|
|
return wfMessage( $warningMsgKey );
|
|
|
|
}, $warningMsgKeys );
|
|
|
|
|
2024-01-24 17:11:20 +00:00
|
|
|
// Check for invalid values in skins, rights, namespaces, and contentModels
|
2023-12-16 15:08:57 +00:00
|
|
|
$this->checkInvalidLoadConditions( $gadget, 'skins', $warnings );
|
|
|
|
$this->checkInvalidLoadConditions( $gadget, 'rights', $warnings );
|
2021-12-28 21:29:05 +00:00
|
|
|
$this->checkInvalidLoadConditions( $gadget, 'namespaces', $warnings );
|
|
|
|
$this->checkInvalidLoadConditions( $gadget, 'contentModels', $warnings );
|
|
|
|
|
|
|
|
// Peer gadgets not being styles-only gadgets, or not being defined at all
|
|
|
|
foreach ( $gadget->getPeers() as $peer ) {
|
|
|
|
try {
|
|
|
|
$peerGadget = $this->getGadget( $peer );
|
|
|
|
if ( $peerGadget->getType() !== 'styles' ) {
|
|
|
|
$warnings[] = wfMessage( "gadgets-validate-invalidpeer", $peer );
|
|
|
|
}
|
|
|
|
} catch ( InvalidArgumentException $ex ) {
|
|
|
|
$warnings[] = wfMessage( "gadgets-validate-nopeer", $peer );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check that the gadget pages exist and are of the right content model
|
|
|
|
$warnings = array_merge(
|
|
|
|
$warnings,
|
|
|
|
$this->checkTitles( $gadget->getScripts(), CONTENT_MODEL_JAVASCRIPT,
|
|
|
|
"gadgets-validate-invalidjs" ),
|
|
|
|
$this->checkTitles( $gadget->getStyles(), CONTENT_MODEL_CSS,
|
|
|
|
"gadgets-validate-invalidcss" ),
|
|
|
|
$this->checkTitles( $gadget->getJSONs(), CONTENT_MODEL_JSON,
|
|
|
|
"gadgets-validate-invalidjson" )
|
|
|
|
);
|
|
|
|
|
|
|
|
return $warnings;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check titles used in gadget to verify existence and correct content model.
|
|
|
|
* @param array $pages
|
|
|
|
* @param string $expectedContentModel
|
|
|
|
* @param string $msg
|
|
|
|
* @return Message[]
|
|
|
|
*/
|
|
|
|
private function checkTitles( array $pages, string $expectedContentModel, string $msg ): array {
|
|
|
|
$warnings = [];
|
|
|
|
foreach ( $pages as $pageName ) {
|
|
|
|
$title = Title::newFromText( $pageName );
|
|
|
|
if ( !$title ) {
|
|
|
|
$warnings[] = wfMessage( "gadgets-validate-invalidtitle", $pageName );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if ( !$title->exists() ) {
|
|
|
|
$warnings[] = wfMessage( "gadgets-validate-nopage", $pageName );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$contentModel = $title->getContentModel();
|
|
|
|
if ( $contentModel !== $expectedContentModel ) {
|
|
|
|
$warnings[] = wfMessage( $msg, $pageName, $contentModel );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $warnings;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param Gadget $gadget
|
|
|
|
* @param string $condition
|
|
|
|
* @param Message[] &$warnings
|
|
|
|
*/
|
|
|
|
private function checkInvalidLoadConditions( Gadget $gadget, string $condition, array &$warnings ) {
|
|
|
|
switch ( $condition ) {
|
2023-12-16 15:08:57 +00:00
|
|
|
case 'skins':
|
|
|
|
$allSkins = array_keys( MediaWikiServices::getInstance()->getSkinFactory()->getInstalledSkins() );
|
|
|
|
$this->maybeAddWarnings( $gadget->getRequiredSkins(),
|
|
|
|
static function ( $skin ) use ( $allSkins ) {
|
|
|
|
return !in_array( $skin, $allSkins, true );
|
|
|
|
}, $warnings, "gadgets-validate-invalidskins" );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'rights':
|
|
|
|
$allPerms = MediaWikiServices::getInstance()->getPermissionManager()->getAllPermissions();
|
|
|
|
$this->maybeAddWarnings( $gadget->getRequiredRights(),
|
|
|
|
static function ( $right ) use ( $allPerms ) {
|
|
|
|
return !in_array( $right, $allPerms, true );
|
|
|
|
}, $warnings, "gadgets-validate-invalidrights" );
|
|
|
|
break;
|
|
|
|
|
2021-12-28 21:29:05 +00:00
|
|
|
case 'namespaces':
|
|
|
|
$nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
|
|
|
|
$this->maybeAddWarnings( $gadget->getRequiredNamespaces(),
|
|
|
|
static function ( $ns ) use ( $nsInfo ) {
|
|
|
|
return !$nsInfo->exists( $ns );
|
|
|
|
}, $warnings, "gadgets-validate-invalidnamespaces"
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'contentModels':
|
|
|
|
$contentHandlerFactory = MediaWikiServices::getInstance()->getContentHandlerFactory();
|
|
|
|
$this->maybeAddWarnings( $gadget->getRequiredContentModels(),
|
|
|
|
static function ( $model ) use ( $contentHandlerFactory ) {
|
|
|
|
return !$contentHandlerFactory->isDefinedModel( $model );
|
|
|
|
}, $warnings, "gadgets-validate-invalidcontentmodels"
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Iterate over the given $entries, for each check if it is invalid using $isInvalid predicate,
|
|
|
|
* and if so add the $message to $warnings.
|
|
|
|
*
|
|
|
|
* @param array $entries
|
|
|
|
* @param callable $isInvalid
|
|
|
|
* @param array &$warnings
|
|
|
|
* @param string $message
|
|
|
|
*/
|
|
|
|
private function maybeAddWarnings( array $entries, callable $isInvalid, array &$warnings, string $message ) {
|
|
|
|
$invalidEntries = [];
|
|
|
|
foreach ( $entries as $entry ) {
|
|
|
|
if ( $isInvalid( $entry ) ) {
|
|
|
|
$invalidEntries[] = $entry;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( count( $invalidEntries ) ) {
|
2024-01-09 20:02:52 +00:00
|
|
|
$warnings[] = wfMessage( $message,
|
|
|
|
Message::listParam( $invalidEntries, 'comma' ),
|
|
|
|
count( $invalidEntries ) );
|
2021-12-28 21:29:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-18 22:40:42 +00:00
|
|
|
/**
|
2015-08-03 06:37:32 +00:00
|
|
|
* Get the configured default GadgetRepo.
|
2015-07-18 22:40:42 +00:00
|
|
|
*
|
2022-08-16 15:24:01 +00:00
|
|
|
* @deprecated Use the GadgetsRepo service instead
|
2015-07-18 22:40:42 +00:00
|
|
|
* @return GadgetRepo
|
|
|
|
*/
|
|
|
|
public static function singleton() {
|
|
|
|
if ( self::$instance === null ) {
|
2022-08-16 15:24:01 +00:00
|
|
|
return MediaWikiServices::getInstance()->getService( 'GadgetsRepo' );
|
2015-07-18 22:40:42 +00:00
|
|
|
}
|
|
|
|
return self::$instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Should only be used by unit tests
|
|
|
|
*
|
2022-08-16 15:24:01 +00:00
|
|
|
* @deprecated Use the GadgetsRepo service instead
|
2015-07-18 22:40:42 +00:00
|
|
|
* @param GadgetRepo|null $repo
|
|
|
|
*/
|
|
|
|
public static function setSingleton( $repo = null ) {
|
|
|
|
self::$instance = $repo;
|
|
|
|
}
|
|
|
|
}
|