26use Wikimedia\Assert\Assert;
54 protected $origin = self::ORIGIN_USER_SITEWIDE;
95 $this->{$member} = $option;
124 $pages[$script] = [
'type' =>
'script' ];
129 foreach ( $this->styles
as $style ) {
130 $pages[$style] = [
'type' =>
'style' ];
168 $title = Title::newFromText( $titleText );
187 return $content->serialize( $format );
202 wfDeprecated( __METHOD__ .
' without a ResourceLoader context',
'1.32' );
205 $overrideCallback =
$context ?
$context->getContentOverrideCallback() :
null;
206 $content = $overrideCallback ? call_user_func( $overrideCallback,
$title ) :
null;
210 'Bad content override for "{title}" in ' . __METHOD__,
211 [
'title' =>
$title->getPrefixedText() ]
224 'Failed to load content of JS/CSS page "{title}" in ' . __METHOD__,
225 [
'title' =>
$title->getPrefixedText() ]
232 if ( $maxRedirects ===
null ) {
233 $maxRedirects = $this->
getConfig()->get(
'MaxRedirects' ) ?: 0;
235 if ( $maxRedirects > 0 ) {
236 $newTitle =
$content->getRedirectTarget();
249 $overrideCallback =
$context->getContentOverrideCallback();
250 if ( $overrideCallback && $this->
getSource() ===
'local' ) {
252 $title = Title::newFromText( $page );
253 if (
$title && call_user_func( $overrideCallback,
$title ) !==
null ) {
259 return parent::shouldEmbedModule(
$context );
269 if (
$options[
'type'] !==
'script' ) {
273 if ( strval( $script ) !==
'' ) {
275 $scripts .= ResourceLoader::makeComment( $titleText ) . $script .
"\n";
288 if (
$options[
'type'] !==
'style' ) {
291 $media =
$options[
'media'] ??
'all';
293 if ( strval( $style ) ===
'' ) {
297 $style = CSSJanus::transform( $style,
true,
false );
300 [ $style,
false, $this->
getConfig()->
get(
'ScriptPath' ),
true ] );
301 if ( !isset(
$styles[$media] ) ) {
304 $style = ResourceLoader::makeComment( $titleText ) . $style;
329 $summary = parent::getDefinitionSummary(
$context );
350 if ( $this->
getGroup() ===
'user' ) {
351 foreach ( $revisions
as $revision ) {
352 if ( $revision[
'page_len'] > 0 ) {
363 return count( $revisions ) === 0;
367 $this->titleInfo[$batchKey] = $titleInfo;
372 return "{$title->getNamespace()}:{$title->getDBkey()}";
389 $batchKey = implode(
'|', $pageNames );
390 if ( !isset( $this->titleInfo[$batchKey] ) ) {
391 $this->titleInfo[$batchKey] = static::fetchTitleInfo(
$dbr, $pageNames, __METHOD__ );
397 $overrideCallback =
$context->getContentOverrideCallback();
398 if ( $overrideCallback ) {
399 foreach ( $pageNames
as $page ) {
400 $title = Title::newFromText( $page );
405 'page_latest' =>
'TBD',
418 foreach ( $pages
as $titleText ) {
419 $title = Title::newFromText( $titleText );
425 if ( !
$batch->isEmpty() ) {
428 [
'page_namespace',
'page_title',
'page_touched',
'page_len',
'page_latest' ],
429 $batch->constructSet(
'page', $db ),
432 foreach (
$res as $row ) {
437 'page_len' => $row->page_len,
438 'page_latest' => $row->page_latest,
439 'page_touched' => $row->page_touched,
455 $rl =
$context->getResourceLoader();
461 foreach ( $moduleNames
as $name ) {
462 $module = $rl->getModule(
$name );
463 if ( $module instanceof
self ) {
464 $mDB = $module->getDB();
466 if ( $mDB && $mDB->getDomainID() === $db->
getDomainID() ) {
467 $wikiModules[] = $module;
468 $allPages += $module->getPages(
$context );
473 if ( !$wikiModules ) {
478 $pageNames = array_keys( $allPages );
480 $hash = sha1( implode(
'|', $pageNames ) );
483 $func = [ static::class,
'fetchTitleInfo' ];
486 $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
487 $allInfo =
$cache->getWithSetCallback(
488 $cache->makeGlobalKey(
'resourceloader',
'titleinfo', $db->
getDomainID(), $hash ),
491 $setOpts += Database::getCacheSetOptions( $db );
493 return call_user_func( $func, $db, $pageNames,
$fname );
501 foreach ( $wikiModules
as $wikiModule ) {
502 $pages = $wikiModule->getPages(
$context );
505 foreach ( $pages
as $pageName => $unused ) {
506 $title = Title::newFromText( $pageName );
508 $intersect[ self::makeTitleKey(
$title ) ] = 1;
511 $rl->getLogger()->info(
512 'Invalid wiki page title "{title}" in ' . __METHOD__,
513 [
'title' => $pageName ]
517 $info = array_intersect_key( $allInfo, $intersect );
518 $pageNames = array_keys( $pages );
520 $batchKey = implode(
'|', $pageNames );
521 $wikiModule->setTitleInfo( $batchKey, $info );
540 Assert::parameterType(
'string', $domain,
'$domain' );
544 if ( $old && in_array( $old->getContentFormat(), $formats ) ) {
546 } elseif ( $new && in_array( $new->getContentFormat(), $formats ) ) {
549 $purge = (
$title->isSiteConfigPage() ||
$title->isUserConfigPage() );
553 $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
554 $key =
$cache->makeGlobalKey(
'resourceloader',
'titleinfo', $domain );
555 $cache->touchCheckKey( $key );
567 return ( $this->styles && !$this->
scripts ) ? self::LOAD_STYLES : self::LOAD_GENERAL;
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
if(defined( 'MW_SETUP_CALLBACK')) $fname
Customization point after all loading (constants, functions, classes, DefaultSettings,...
Class representing a list of titles The execute() method checks them all for existence and adds them ...
static call( $callable, array $args=[], $ttl=3600)
Shortcut method for creating a MemoizedCallable and invoking it with the specified arguments.
Object passed around to modules which contains information about the state of a specific loader reque...
Abstraction for ResourceLoader modules, with name registration and maxage functionality.
getDependencies(ResourceLoaderContext $context=null)
Get a list of modules this module depends on.
validateScriptFile( $fileName, $contents)
Validate a given script file; if valid returns the original source.
getSource()
Get the source of this module.
Abstraction for ResourceLoader modules which pull from wiki pages.
getContentObj(Title $title, ResourceLoaderContext $context=null, $maxRedirects=null)
getTitleInfo(ResourceLoaderContext $context)
Get the information about the wiki pages for a given context.
getDB()
Get the Database object used in getTitleInfo().
__construct(array $options=null)
static preloadTitleInfo(ResourceLoaderContext $context, IDatabase $db, array $moduleNames)
enableModuleContentVersion()
Disable module content versioning.
getPages(ResourceLoaderContext $context)
Subclasses should return an associative array of resources in the module.
shouldEmbedModule(ResourceLoaderContext $context)
static fetchTitleInfo(IDatabase $db, array $pages, $fname=__METHOD__)
static makeTitleKey(LinkTarget $title)
getDefinitionSummary(ResourceLoaderContext $context)
setTitleInfo( $batchKey, array $titleInfo)
getStyles(ResourceLoaderContext $context)
isKnownEmpty(ResourceLoaderContext $context)
getContent( $titleText, ResourceLoaderContext $context=null)
getGroup()
Get group name.
getScript(ResourceLoaderContext $context)
static invalidateModuleCache(Title $title, Revision $old=null, Revision $new=null, $domain)
Clear the preloadTitleInfo() cache for all wiki modules on this wiki on page change if it was a JS or...
static newKnownCurrent(IDatabase $db, $pageIdOrTitle, $revId=0)
Load a revision based on a known page ID and current revision ID from the DB.
Represents a page (or page fragment) title within MediaWiki.
Represents a title within MediaWiki.
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
const CONTENT_FORMAT_JAVASCRIPT
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable modifiable after all normalizations have been except for the $wgMaxImageArea check set to true or false to override the $wgMaxImageArea check result gives extension the possibility to transform it themselves $handler
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
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
namespace and then decline to actually register it file or subcat img or subcat $title
Allows to change the fields on the form that will be generated $name
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 function
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
get( $name)
Get a configuration variable such as "Sitename" or "UploadMaintenance.".
Base interface for content objects.
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))