23 if ( !
isset( $gadgets[$id] ) ) {
24 throw new InvalidArgumentException(
"No gadget registered for '$id'" );
40 if ( $target->
getNamespace() == NS_MEDIAWIKI && $target->
getText() ==
'Gadgets-definition' ) {
50 $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
55 $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
71 if ( $this->definitionCache !==
null ) {
76 $t1Cache = ObjectCache::getLocalServerInstance(
'hash' );
77 $wanCache = MediaWikiServices::getInstance()->getMainWANObjectCache();
82 $value = $t1Cache->get( $key );
85 $cutoffAge =
mt_rand( 7 * 1e6, 15 * 1e6 ) / 1
e6;
88 $this->definitionCache =
$value[
'gadgets'];
92 $ckTime = $wanCache->getCheckKeyTime( $key ) + WANObjectCache::HOLDOFF_TTL;
94 $this->definitionCache =
$value[
'gadgets'];
101 $value = $wanCache->getWithSetCallback(
104 function ( $old, &$ttl, &$setOpts ) use ( $us ) {
108 $gadgets = $us->fetchStructuredList();
109 if ( $gadgets ===
false ) {
110 $ttl = WANObjectCache::TTL_UNCACHEABLE;
115 [
'checkKeys' => [ $key ],
'lockTSE' => 300 ]
119 if (
$value[
'gadgets'] !==
false &&
$value[
'time'] > $ckTime ) {
124 $this->definitionCache =
$value[
'gadgets'];
136 if ( $forceNewText ===
null ) {
138 $title = Title::makeTitle( NS_MEDIAWIKI,
'Gadgets-definition' );
140 if ( !
$rev || !
$rev->getContent() ||
$rev->getContent()->isEmpty() ) {
144 $g =
$rev->getContent()->getNativeData();
150 if ( !count( $gadgets ) ) {
154 $source = $forceNewText !==
null ?
'input text' :
'MediaWiki:Gadgets-definition';
155 wfDebug( __METHOD__ .
": $source parsed, cache entry should be updated\n" );
167 $definition =
preg_replace(
'/<!--.*?-->/s',
'', $definition );
180 $gadgets[$gadget->getName()] = $gadget;
197 '/^\*+ *([a-zA-Z](?:[-_:.\w\d ]*[a-zA-Z0-9])?)(\s*\[.*?\])?\s*((\|[^|]*)+)\s*$/',
206 $info = [
'category' => $category ];
213 $info[
'definition'] = $definition;
216 foreach (
preg_split(
'/\s*\|\s*/',
$options, -1, PREG_SPLIT_NO_EMPTY ) as $option ) {
219 if (
isset( $arr[1] ) ) {
220 $params = explode(
',', $arr[1] );
227 case 'ResourceLoader':
228 $info[
'resourceLoaded'] =
true;
231 $info[
'dependencies'] =
$params;
237 $info[
'requiredRights'] =
$params;
240 $info[
'hidden'] =
true;
243 $info[
'requiredSkins'] =
$params;
246 $info[
'onByDefault'] =
true;
253 $info[
'type'] =
$params[0] ??
'';
258 foreach (
preg_split(
'/\s*\|\s*/', $m[3], -1, PREG_SPLIT_NO_EMPTY ) as $page ) {
259 $page =
"MediaWiki:Gadget-$page";
262 $info[
'scripts'][] = $page;
264 $info[
'styles'][] = $page;
268 return new Gadget( $info );
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
const GADGET_CLASS_VERSION
Increment this when changing class structure.
static isValidGadgetID( $id)
Whether the provided gadget id is valid.
static newFromTitle(LinkTarget $linkTarget, $id=0, $flags=0)
Load either the current, or a specified, revision that's attached to a given link target.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
usually copyright or history_copyright This message must be in HTML not wikitext if the section is included from a template $section
presenting them properly to the user as errors is done by the caller return true use this to change the list i e etc $rev