Go to the documentation of this file.
23 if ( !isset( $gadgets[$id] ) ) {
24 throw new InvalidArgumentException(
"No gadget registered for '$id'" );
33 return array_keys( $gadgets );
50 $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
55 $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
71 if ( $this->definitionCache !==
null ) {
77 $wanCache = MediaWikiServices::getInstance()->getMainWANObjectCache();
82 $value = $t1Cache->get( $key );
85 $cutoffAge = mt_rand( 7 * 1e6, 15 * 1e6 ) / 1e6;
87 if (
$value && ( microtime(
true ) -
$value[
'time'] ) < $cutoffAge ) {
88 $this->definitionCache =
$value[
'gadgets'];
94 $this->definitionCache =
$value[
'gadgets'];
101 $value = $wanCache->getWithSetCallback(
104 function ( $old, &$ttl, &$setOpts )
use ( $us ) {
107 $now = microtime(
true );
108 $gadgets = $us->fetchStructuredList();
109 if ( $gadgets ===
false ) {
113 return [
'gadgets' => $gadgets,
'time' => $now ];
115 [
'checkKeys' => [ $key ],
'lockTSE' => 300 ]
119 if (
$value[
'gadgets'] !==
false &&
$value[
'time'] > $ckTime ) {
121 $t1Cache->set( $key,
$value, mt_rand( 300, 600 ) );
124 $this->definitionCache =
$value[
'gadgets'];
136 if ( $forceNewText ===
null ) {
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 );
168 $lines = preg_split(
'/(\r\n|\r|\n)+/', $definition );
175 if ( preg_match(
'/^==+ *([^*:\s|]+?)\s*==+\s*$/',
$line, $m ) ) {
180 $gadgets[$gadget->getName()] = $gadget;
197 '/^\*+ *([a-zA-Z](?:[-_:.\w\d ]*[a-zA-Z0-9])?)(\s*\[.*?\])?\s*((\|[^|]*)+)\s*$/',
206 $info = [
'category' => $category ];
207 $info[
'name'] = trim( str_replace(
' ',
'_', $m[1] ) );
213 $info[
'definition'] = $definition;
216 foreach ( preg_split(
'/\s*\|\s*/',
$options, -1, PREG_SPLIT_NO_EMPTY )
as $option ) {
217 $arr = preg_split(
'/\s*=\s*/', $option, 2 );
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";
261 if ( preg_match(
'/\.js/', $page ) ) {
262 $info[
'scripts'][] = $page;
263 } elseif ( preg_match(
'/\.css/', $page ) ) {
264 $info[
'styles'][] = $page;
268 return new Gadget( $info );
const TTL_UNCACHEABLE
Idiom for getWithSetCallback() callbacks to avoid calling set()
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
static newFromTitle(LinkTarget $linkTarget, $id=0, $flags=0)
Load either the current, or a specified, revision that's attached to a given link target.
namespace and then decline to actually register it file or subcat img or subcat $title
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
const HOLDOFF_TTL
Seconds to tombstone keys on delete()
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
static isValidGadgetID( $id)
Whether the provided gadget id is valid.
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
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency MediaWikiServices
const GADGET_CLASS_VERSION
Increment this when changing class structure.
static getLocalServerInstance( $fallback=CACHE_NONE)
Factory function for CACHE_ACCEL (referenced from DefaultSettings.php)