73 foreach (
$options as $member => $option ) {
79 $this->{$member} = $option;
107 foreach ( $this->
scripts as $script ) {
108 $pages[$script] = [
'type' =>
'script' ];
113 foreach ( $this->styles as $style ) {
114 $pages[$style] = [
'type' =>
'style' ];
150 $title = Title::newFromText( $titleText );
156 if ( $title->isRedirect() ) {
158 $title = $content ? $content->getUltimateRedirectTarget() :
null;
164 $handler = ContentHandler::getForTitle( $title );
178 return $content->serialize( $format );
190 $content = $revision->getContent( Revision::RAW );
192 wfDebugLog(
'resourceloader', __METHOD__ .
': failed to load content of JS/CSS page!' );
205 if (
$options[
'type'] !==
'script' ) {
209 if ( strval( $script ) !==
'' ) {
224 if (
$options[
'type'] !==
'style' ) {
229 if ( strval( $style ) ===
'' ) {
232 if ( $this->
getFlip( $context ) ) {
233 $style = CSSJanus::transform( $style,
true,
false );
236 [ $style,
false, $this->
getConfig()->
get(
'ScriptPath' ),
true ] );
237 if ( !isset(
$styles[$media] ) ) {
265 $summary = parent::getDefinitionSummary(
$context );
267 'pages' => $this->
getPages( $context ),
282 if ( $this->
getGroup() ===
'user' ) {
283 foreach ( $revisions as $revision ) {
284 if ( $revision[
'page_len'] > 0 ) {
295 return count( $revisions ) === 0;
314 $pageNames = array_keys( $this->
getPages( $context ) );
316 $key = implode(
'|', $pageNames );
317 if ( !isset( $this->titleInfo[$key] ) ) {
318 $this->titleInfo[$key] = static::fetchTitleInfo(
$dbr, $pageNames, __METHOD__ );
320 return $this->titleInfo[$key];
326 foreach ( $pages as $titleText ) {
327 $title = Title::newFromText( $titleText );
333 if ( !
$batch->isEmpty() ) {
336 [
'page_namespace',
'page_title',
'page_touched',
'page_len',
'page_latest' ],
337 $batch->constructSet(
'page', $db ),
340 foreach (
$res as $row ) {
343 $title = Title::makeTitle( $row->page_namespace, $row->page_title );
345 'page_len' => $row->page_len,
346 'page_latest' => $row->page_latest,
347 'page_touched' => $row->page_touched,
363 $rl =
$context->getResourceLoader();
369 foreach ( $moduleNames as $name ) {
370 $module = $rl->getModule( $name );
371 if ( $module instanceof
self ) {
372 $mDB = $module->getDB();
374 if ( $mDB && $mDB->getDomainID() === $db->
getDomainID() ) {
375 $wikiModules[] = $module;
376 $allPages += $module->getPages(
$context );
381 if ( !$wikiModules ) {
386 $pageNames = array_keys( $allPages );
388 $hash = sha1( implode(
'|', $pageNames ) );
391 $func = [ static::class,
'fetchTitleInfo' ];
394 $cache = ObjectCache::getMainWANInstance();
395 $allInfo =
$cache->getWithSetCallback(
396 $cache->makeGlobalKey(
'resourceloader',
'titleinfo', $db->
getDomainID(), $hash ),
398 function ( $curVal, &$ttl, array &$setOpts ) use ( $func, $pageNames, $db,
$fname ) {
399 $setOpts += Database::getCacheSetOptions( $db );
401 return call_user_func( $func, $db, $pageNames,
$fname );
409 foreach ( $wikiModules as $wikiModule ) {
410 $pages = $wikiModule->getPages(
$context );
413 foreach ( $pages as $page => $unused ) {
414 $title = Title::newFromText( $page );
416 $intersect[ $title->getPrefixedText() ] = 1;
419 $rl->getLogger()->info(
420 'Invalid wiki page title "{title}" in ' . __METHOD__,
425 $info = array_intersect_key( $allInfo, $intersect );
426 $pageNames = array_keys( $pages );
428 $key = implode(
'|', $pageNames );
429 $wikiModule->setTitleInfo( $key, $info );
448 if ( $old && in_array( $old->getContentFormat(), $formats ) ) {
450 } elseif ( $new && in_array( $new->getContentFormat(), $formats ) ) {
453 $purge = ( $title->isSiteConfigPage() || $title->isUserConfigPage() );
457 $cache = ObjectCache::getMainWANInstance();
458 $key =
$cache->makeGlobalKey(
'resourceloader',
'titleinfo', $wikiId );
459 $cache->touchCheckKey( $key );
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
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.
validateScriptFile( $fileName, $contents)
Validate a given script file; if valid returns the original source.
const ORIGIN_USER_SITEWIDE
Abstraction for ResourceLoader modules which pull from wiki pages.
setTitleInfo( $key, array $titleInfo)
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.
static fetchTitleInfo(IDatabase $db, array $pages, $fname=__METHOD__)
getDefinitionSummary(ResourceLoaderContext $context)
getStyles(ResourceLoaderContext $context)
static invalidateModuleCache(Title $title, Revision $old=null, Revision $new=null, $wikiId)
Clear the preloadTitleInfo() cache for all wiki modules on this wiki on page change if it was a JS or...
isKnownEmpty(ResourceLoaderContext $context)
getContentObj(Title $title)
getGroup()
Get group name.
getScript(ResourceLoaderContext $context)
static makeComment( $text)
Generate a CSS or JS comment block.
Represents a title within MediaWiki.
when a variable name is used in a function
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
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub 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
const CONTENT_FORMAT_JAVASCRIPT
get( $name)
Get a configuration variable such as "Sitename" or "UploadMaintenance.".