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 );
84 if (
$value && ( microtime(
true ) -
$value[
'time'] ) < 10 ) {
85 $this->definitionCache =
$value[
'gadgets'];
91 $this->definitionCache =
$value[
'gadgets'];
98 $value = $wanCache->getWithSetCallback(
101 function ( $old, &$ttl, &$setOpts )
use ( $us ) {
104 $now = microtime(
true );
105 $gadgets = $us->fetchStructuredList();
106 if ( $gadgets ===
false ) {
110 return [
'gadgets' => $gadgets,
'time' => $now ];
112 [
'checkKeys' => [ $key ],
'lockTSE' => 300 ]
116 if (
$value[
'gadgets'] !==
false &&
$value[
'time'] > $ckTime ) {
118 $t1Cache->set( $key,
$value, mt_rand( 300, 600 ) );
121 $this->definitionCache =
$value[
'gadgets'];
133 if ( $forceNewText ===
null ) {
137 if ( !
$rev || !
$rev->getContent() ||
$rev->getContent()->isEmpty() ) {
141 $g =
$rev->getContent()->getNativeData();
147 if ( !
count( $gadgets ) ) {
151 $source = $forceNewText !==
null ?
'input text' :
'MediaWiki:Gadgets-definition';
152 wfDebug( __METHOD__ .
": $source parsed, cache entry should be updated\n" );
164 $definition = preg_replace(
'/<!--.*?-->/s',
'', $definition );
165 $lines = preg_split(
'/(\r\n|\r|\n)+/', $definition );
172 if ( preg_match(
'/^==+ *([^*:\s|]+?)\s*==+\s*$/',
$line, $m ) ) {
177 $gadgets[$gadget->getName()] = $gadget;
194 '/^\*+ *([a-zA-Z](?:[-_:.\w\d ]*[a-zA-Z0-9])?)(\s*\[.*?\])?\s*((\|[^|]*)+)\s*$/',
203 $info = [
'category' => $category ];
204 $info[
'name'] = trim( str_replace(
' ',
'_', $m[1] ) );
210 $info[
'definition'] = $definition;
213 foreach ( preg_split(
'/\s*\|\s*/',
$options, -1, PREG_SPLIT_NO_EMPTY )
as $option ) {
214 $arr = preg_split(
'/\s*=\s*/', $option, 2 );
216 if ( isset( $arr[1] ) ) {
217 $params = explode(
',', $arr[1] );
224 case 'ResourceLoader':
225 $info[
'resourceLoaded'] =
true;
228 $info[
'dependencies'] =
$params;
234 $info[
'requiredRights'] =
$params;
237 $info[
'hidden'] =
true;
240 $info[
'requiredSkins'] =
$params;
243 $info[
'onByDefault'] =
true;
255 foreach ( preg_split(
'/\s*\|\s*/', $m[3], -1, PREG_SPLIT_NO_EMPTY )
as $page ) {
256 $page =
"MediaWiki:Gadget-$page";
258 if ( preg_match(
'/\.js/', $page ) ) {
259 $info[
'scripts'][] = $page;
260 } elseif ( preg_match(
'/\.css/', $page ) ) {
261 $info[
'styles'][] = $page;
265 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)