MediaWiki REL1_33
ResourceLoaderModule.php
Go to the documentation of this file.
1<?php
26use Psr\Log\LoggerAwareInterface;
27use Psr\Log\LoggerInterface;
28use Psr\Log\NullLogger;
29use Wikimedia\RelPath;
30use Wikimedia\ScopedCallback;
31
35abstract class ResourceLoaderModule implements LoggerAwareInterface {
36 # Type of resource
37 const TYPE_SCRIPTS = 'scripts';
38 const TYPE_STYLES = 'styles';
39 const TYPE_COMBINED = 'combined';
40
41 # Desired load type
42 // Module only has styles (loaded via <style> or <link rel=stylesheet>)
43 const LOAD_STYLES = 'styles';
44 // Module may have other resources (loaded via mw.loader from a script)
45 const LOAD_GENERAL = 'general';
46
47 # sitewide core module like a skin file or jQuery component
49
50 # per-user module generated by the software
52
53 # sitewide module generated from user-editable files, like MediaWiki:Common.js, or
54 # modules accessible to multiple users, such as those generated by the Gadgets extension.
56
57 # per-user module generated from user-editable files, like User:Me/vector.js
59
60 # an access constant; make sure this is kept as the largest number in this group
61 const ORIGIN_ALL = 10;
62
63 # script and style modules form a hierarchy of trustworthiness, with core modules like
64 # skins and jQuery as most trustworthy, and user scripts as least trustworthy. We can
65 # limit the types of scripts and styles we allow to load on, say, sensitive special
66 # pages like Special:UserLogin and Special:Preferences
68
69 protected $name = null;
70 protected $targets = [ 'desktop' ];
71
72 // In-object cache for file dependencies
73 protected $fileDeps = [];
74 // In-object cache for message blob (keyed by language)
75 protected $msgBlobs = [];
76 // In-object cache for version hash
77 protected $versionHash = [];
78 // In-object cache for module content
79 protected $contents = [];
80
84 protected $config;
85
89 protected $deprecated = false;
90
94 protected $logger;
95
102 public function getName() {
103 return $this->name;
104 }
105
112 public function setName( $name ) {
113 $this->name = $name;
114 }
115
123 public function getOrigin() {
124 return $this->origin;
125 }
126
131 public function getFlip( $context ) {
132 return MediaWikiServices::getInstance()->getContentLanguage()->getDir() !==
133 $context->getDirection();
134 }
135
141 public function getDeprecationInformation() {
142 $deprecationInfo = $this->deprecated;
143 if ( $deprecationInfo ) {
144 $name = $this->getName();
145 $warning = 'This page is using the deprecated ResourceLoader module "' . $name . '".';
146 if ( is_string( $deprecationInfo ) ) {
147 $warning .= "\n" . $deprecationInfo;
148 }
149 return Xml::encodeJsCall(
150 'mw.log.warn',
151 [ $warning ]
152 );
153 } else {
154 return '';
155 }
156 }
157
178 // Stub, override expected
179 return '';
180 }
181
187 public function getTemplates() {
188 // Stub, override expected.
189 return [];
190 }
191
196 public function getConfig() {
197 if ( $this->config === null ) {
198 // Ugh, fall back to default
199 $this->config = MediaWikiServices::getInstance()->getMainConfig();
200 }
201
202 return $this->config;
203 }
204
209 public function setConfig( Config $config ) {
210 $this->config = $config;
211 }
212
218 public function setLogger( LoggerInterface $logger ) {
219 $this->logger = $logger;
220 }
221
226 protected function getLogger() {
227 if ( !$this->logger ) {
228 $this->logger = new NullLogger();
229 }
230 return $this->logger;
231 }
232
248 $resourceLoader = $context->getResourceLoader();
249 $derivative = new DerivativeResourceLoaderContext( $context );
250 $derivative->setModules( [ $this->getName() ] );
251 $derivative->setOnly( 'scripts' );
252 $derivative->setDebug( true );
253
254 $url = $resourceLoader->createLoaderURL(
255 $this->getSource(),
256 $derivative
257 );
258
259 return [ $url ];
260 }
261
268 public function supportsURLLoading() {
269 return true;
270 }
271
281 // Stub, override expected
282 return [];
283 }
284
295 $resourceLoader = $context->getResourceLoader();
296 $derivative = new DerivativeResourceLoaderContext( $context );
297 $derivative->setModules( [ $this->getName() ] );
298 $derivative->setOnly( 'styles' );
299 $derivative->setDebug( true );
300
301 $url = $resourceLoader->createLoaderURL(
302 $this->getSource(),
303 $derivative
304 );
305
306 return [ 'all' => [ $url ] ];
307 }
308
316 public function getMessages() {
317 // Stub, override expected
318 return [];
319 }
320
326 public function getGroup() {
327 // Stub, override expected
328 return null;
329 }
330
336 public function getSource() {
337 // Stub, override expected
338 return 'local';
339 }
340
348 public function isRaw() {
349 return false;
350 }
351
365 // Stub, override expected
366 return [];
367 }
368
374 public function getTargets() {
375 return $this->targets;
376 }
377
384 public function getType() {
385 return self::LOAD_GENERAL;
386 }
387
402 public function getSkipFunction() {
403 return null;
404 }
405
415 $vary = $context->getSkin() . '|' . $context->getLanguage();
416
417 // Try in-object cache first
418 if ( !isset( $this->fileDeps[$vary] ) ) {
420 $deps = $dbr->selectField( 'module_deps',
421 'md_deps',
422 [
423 'md_module' => $this->getName(),
424 'md_skin' => $vary,
425 ],
426 __METHOD__
427 );
428
429 if ( !is_null( $deps ) ) {
430 $this->fileDeps[$vary] = self::expandRelativePaths(
431 (array)json_decode( $deps, true )
432 );
433 } else {
434 $this->fileDeps[$vary] = [];
435 }
436 }
437 return $this->fileDeps[$vary];
438 }
439
450 $vary = $context->getSkin() . '|' . $context->getLanguage();
451 $this->fileDeps[$vary] = $files;
452 }
453
461 protected function saveFileDependencies( ResourceLoaderContext $context, $localFileRefs ) {
462 try {
463 // Related bugs and performance considerations:
464 // 1. Don't needlessly change the database value with the same list in a
465 // different order or with duplicates.
466 // 2. Use relative paths to avoid ghost entries when $IP changes. (T111481)
467 // 3. Don't needlessly replace the database with the same value
468 // just because $IP changed (e.g. when upgrading a wiki).
469 // 4. Don't create an endless replace loop on every request for this
470 // module when '../' is used anywhere. Even though both are expanded
471 // (one expanded by getFileDependencies from the DB, the other is
472 // still raw as originally read by RL), the latter has not
473 // been normalized yet.
474
475 // Normalise
476 $localFileRefs = array_values( array_unique( $localFileRefs ) );
477 sort( $localFileRefs );
478 $localPaths = self::getRelativePaths( $localFileRefs );
479 $storedPaths = self::getRelativePaths( $this->getFileDependencies( $context ) );
480
481 if ( $localPaths === $storedPaths ) {
482 // Unchanged. Avoid needless database query (especially master conn!).
483 return;
484 }
485
486 // The file deps list has changed, we want to update it.
487 $vary = $context->getSkin() . '|' . $context->getLanguage();
488 $cache = ObjectCache::getLocalClusterInstance();
489 $key = $cache->makeKey( __METHOD__, $this->getName(), $vary );
490 $scopeLock = $cache->getScopedLock( $key, 0 );
491 if ( !$scopeLock ) {
492 // Another request appears to be doing this update already.
493 // Avoid write slams (T124649).
494 return;
495 }
496
497 // No needless escaping as this isn't HTML output.
498 // Only stored in the database and parsed in PHP.
499 $deps = json_encode( $localPaths, JSON_UNESCAPED_SLASHES );
500 $dbw = wfGetDB( DB_MASTER );
501 $dbw->upsert( 'module_deps',
502 [
503 'md_module' => $this->getName(),
504 'md_skin' => $vary,
505 'md_deps' => $deps,
506 ],
507 [ [ 'md_module', 'md_skin' ] ],
508 [
509 'md_deps' => $deps,
510 ]
511 );
512
513 if ( $dbw->trxLevel() ) {
514 $dbw->onTransactionResolution(
515 function () use ( &$scopeLock ) {
516 ScopedCallback::consume( $scopeLock ); // release after commit
517 },
518 __METHOD__
519 );
520 }
521 } catch ( Exception $e ) {
522 // Probably a DB failure. Either the read query from getFileDependencies(),
523 // or the write query above.
524 wfDebugLog( 'resourceloader', __METHOD__ . ": failed to update DB: $e" );
525 }
526 }
527
538 public static function getRelativePaths( array $filePaths ) {
539 global $IP;
540 return array_map( function ( $path ) use ( $IP ) {
541 return RelPath::getRelativePath( $path, $IP );
542 }, $filePaths );
543 }
544
552 public static function expandRelativePaths( array $filePaths ) {
553 global $IP;
554 return array_map( function ( $path ) use ( $IP ) {
555 return RelPath::joinPath( $IP, $path );
556 }, $filePaths );
557 }
558
567 if ( !$this->getMessages() ) {
568 // Don't bother consulting MessageBlobStore
569 return null;
570 }
571 // Message blobs may only vary language, not by context keys
572 $lang = $context->getLanguage();
573 if ( !isset( $this->msgBlobs[$lang] ) ) {
574 $this->getLogger()->warning( 'Message blob for {module} should have been preloaded', [
575 'module' => $this->getName(),
576 ] );
577 $store = $context->getResourceLoader()->getMessageBlobStore();
578 $this->msgBlobs[$lang] = $store->getBlob( $this, $lang );
579 }
580 return $this->msgBlobs[$lang];
581 }
582
592 public function setMessageBlob( $blob, $lang ) {
593 $this->msgBlobs[$lang] = $blob;
594 }
595
610 final public function getHeaders( ResourceLoaderContext $context ) {
611 $headers = [];
612
613 $formattedLinks = [];
614 foreach ( $this->getPreloadLinks( $context ) as $url => $attribs ) {
615 $link = "<{$url}>;rel=preload";
616 foreach ( $attribs as $key => $val ) {
617 $link .= ";{$key}={$val}";
618 }
619 $formattedLinks[] = $link;
620 }
621 if ( $formattedLinks ) {
622 $headers[] = 'Link: ' . implode( ',', $formattedLinks );
623 }
624
625 return $headers;
626 }
627
668 return [];
669 }
670
679 return [];
680 }
681
690 $contextHash = $context->getHash();
691 // Cache this expensive operation. This calls builds the scripts, styles, and messages
692 // content which typically involves filesystem and/or database access.
693 if ( !array_key_exists( $contextHash, $this->contents ) ) {
694 $this->contents[$contextHash] = $this->buildContent( $context );
695 }
696 return $this->contents[$contextHash];
697 }
698
706 final protected function buildContent( ResourceLoaderContext $context ) {
707 $rl = $context->getResourceLoader();
708 $stats = MediaWikiServices::getInstance()->getStatsdDataFactory();
709 $statStart = microtime( true );
710
711 // This MUST build both scripts and styles, regardless of whether $context->getOnly()
712 // is 'scripts' or 'styles' because the result is used by getVersionHash which
713 // must be consistent regardless of the 'only' filter on the current request.
714 // Also, when introducing new module content resources (e.g. templates, headers),
715 // these should only be included in the array when they are non-empty so that
716 // existing modules not using them do not get their cache invalidated.
717 $content = [];
718
719 // Scripts
720 // If we are in debug mode, we'll want to return an array of URLs if possible
721 // However, we can't do this if the module doesn't support it.
722 // We also can't do this if there is an only= parameter, because we have to give
723 // the module a way to return a load.php URL without causing an infinite loop
724 if ( $context->getDebug() && !$context->getOnly() && $this->supportsURLLoading() ) {
725 $scripts = $this->getScriptURLsForDebug( $context );
726 } else {
727 $scripts = $this->getScript( $context );
728 // Make the script safe to concatenate by making sure there is at least one
729 // trailing new line at the end of the content. Previously, this looked for
730 // a semi-colon instead, but that breaks concatenation if the semicolon
731 // is inside a comment like "// foo();". Instead, simply use a
732 // line break as separator which matches JavaScript native logic for implicitly
733 // ending statements even if a semi-colon is missing.
734 // Bugs: T29054, T162719.
735 if ( is_string( $scripts )
736 && strlen( $scripts )
737 && substr( $scripts, -1 ) !== "\n"
738 ) {
739 $scripts .= "\n";
740 }
741 }
742 $content['scripts'] = $scripts;
743
744 $styles = [];
745 // Don't create empty stylesheets like [ '' => '' ] for modules
746 // that don't *have* any stylesheets (T40024).
747 $stylePairs = $this->getStyles( $context );
748 if ( count( $stylePairs ) ) {
749 // If we are in debug mode without &only= set, we'll want to return an array of URLs
750 // See comment near shouldIncludeScripts() for more details
751 if ( $context->getDebug() && !$context->getOnly() && $this->supportsURLLoading() ) {
752 $styles = [
753 'url' => $this->getStyleURLsForDebug( $context )
754 ];
755 } else {
756 // Minify CSS before embedding in mw.loader.implement call
757 // (unless in debug mode)
758 if ( !$context->getDebug() ) {
759 foreach ( $stylePairs as $media => $style ) {
760 // Can be either a string or an array of strings.
761 if ( is_array( $style ) ) {
762 $stylePairs[$media] = [];
763 foreach ( $style as $cssText ) {
764 if ( is_string( $cssText ) ) {
765 $stylePairs[$media][] =
766 ResourceLoader::filter( 'minify-css', $cssText );
767 }
768 }
769 } elseif ( is_string( $style ) ) {
770 $stylePairs[$media] = ResourceLoader::filter( 'minify-css', $style );
771 }
772 }
773 }
774 // Wrap styles into @media groups as needed and flatten into a numerical array
775 $styles = [
776 'css' => $rl->makeCombinedStyles( $stylePairs )
777 ];
778 }
779 }
780 $content['styles'] = $styles;
781
782 // Messages
783 $blob = $this->getMessageBlob( $context );
784 if ( $blob ) {
785 $content['messagesBlob'] = $blob;
786 }
787
788 $templates = $this->getTemplates();
789 if ( $templates ) {
790 $content['templates'] = $templates;
791 }
792
793 $headers = $this->getHeaders( $context );
794 if ( $headers ) {
795 $content['headers'] = $headers;
796 }
797
798 $statTiming = microtime( true ) - $statStart;
799 $statName = strtr( $this->getName(), '.', '_' );
800 $stats->timing( "resourceloader_build.all", 1000 * $statTiming );
801 $stats->timing( "resourceloader_build.$statName", 1000 * $statTiming );
802
803 return $content;
804 }
805
824 // Cache this somewhat expensive operation. Especially because some classes
825 // (e.g. startup module) iterate more than once over all modules to get versions.
826 $contextHash = $context->getHash();
827 if ( !array_key_exists( $contextHash, $this->versionHash ) ) {
828 if ( $this->enableModuleContentVersion() ) {
829 // Detect changes directly by hashing the module contents.
830 $str = json_encode( $this->getModuleContent( $context ) );
831 } else {
832 // Infer changes based on definition and other metrics
833 $summary = $this->getDefinitionSummary( $context );
834 if ( !isset( $summary['_class'] ) ) {
835 throw new LogicException( 'getDefinitionSummary must call parent method' );
836 }
837 $str = json_encode( $summary );
838 }
839
840 $this->versionHash[$contextHash] = ResourceLoader::makeHash( $str );
841 }
842 return $this->versionHash[$contextHash];
843 }
844
854 public function enableModuleContentVersion() {
855 return false;
856 }
857
902 return [
903 '_class' => static::class,
904 // Make sure that when filter cache for minification is invalidated,
905 // we also change the HTTP urls and mw.loader.store keys (T176884).
906 '_cacheVersion' => ResourceLoader::CACHE_VERSION,
907 ];
908 }
909
920 return false;
921 }
922
934 return $this->getGroup() === 'private';
935 }
936
938 private static $jsParser;
939 private static $parseCacheVersion = 1;
940
949 protected function validateScriptFile( $fileName, $contents ) {
950 if ( !$this->getConfig()->get( 'ResourceLoaderValidateJS' ) ) {
951 return $contents;
952 }
953 $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
954 return $cache->getWithSetCallback(
955 $cache->makeGlobalKey(
956 'resourceloader',
957 'jsparse',
958 self::$parseCacheVersion,
959 md5( $contents ),
960 $fileName
961 ),
962 $cache::TTL_WEEK,
963 function () use ( $contents, $fileName ) {
965 $err = null;
966 try {
967 Wikimedia\suppressWarnings();
968 $parser->parse( $contents, $fileName, 1 );
969 } catch ( Exception $e ) {
970 $err = $e;
971 } finally {
972 Wikimedia\restoreWarnings();
973 }
974 if ( $err ) {
975 // Send the error to the browser console client-side.
976 // By returning this as replacement for the actual script,
977 // we ensure modules are safe to load in a batch request,
978 // without causing other unrelated modules to break.
979 return 'mw.log.error(' .
980 Xml::encodeJsVar( 'JavaScript parse error: ' . $err->getMessage() ) .
981 ');';
982 }
983 return $contents;
984 }
985 );
986 }
987
991 protected static function javaScriptParser() {
992 if ( !self::$jsParser ) {
993 self::$jsParser = new JSParser();
994 }
995 return self::$jsParser;
996 }
997
1005 protected static function safeFilemtime( $filePath ) {
1006 Wikimedia\suppressWarnings();
1007 $mtime = filemtime( $filePath ) ?: 1;
1008 Wikimedia\restoreWarnings();
1009 return $mtime;
1010 }
1011
1020 protected static function safeFileHash( $filePath ) {
1021 return FileContentsHasher::getFileContentsHash( $filePath );
1022 }
1023}
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
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.
$IP
Definition WebStart.php:41
Allows changing specific properties of a context object, without changing the main one.
static getFileContentsHash( $filePaths, $algo='md4')
Get a hash of the combined contents of one or more files, either by retrieving a previously-computed ...
MediaWikiServices is the service locator for the application scope of MediaWiki.
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.
isKnownEmpty(ResourceLoaderContext $context)
Check whether this module is known to be empty.
getScript(ResourceLoaderContext $context)
Get all JS for this module for a given language and skin.
getDependencies(ResourceLoaderContext $context=null)
Get a list of modules this module depends on.
enableModuleContentVersion()
Whether to generate version hash based on module content.
getFileDependencies(ResourceLoaderContext $context)
Get the files this module depends on indirectly for a given skin.
getSkipFunction()
Get the skip function.
validateScriptFile( $fileName, $contents)
Validate a given script file; if valid returns the original source.
getMessageBlob(ResourceLoaderContext $context)
Get the hash of the message blob.
static safeFileHash( $filePath)
Compute a non-cryptographic string hash of a file's contents.
static expandRelativePaths(array $filePaths)
Expand directories relative to $IP.
getModuleContent(ResourceLoaderContext $context)
Get an array of this module's resources.
supportsURLLoading()
Whether this module supports URL loading.
getMessages()
Get the messages needed for this module.
setName( $name)
Set this module's name.
isRaw()
Whether this module's JS expects to work without the client-side ResourceLoader module.
getStyles(ResourceLoaderContext $context)
Get all CSS for this module for a given skin.
getLessVars(ResourceLoaderContext $context)
Get module-specific LESS variables, if any.
getScriptURLsForDebug(ResourceLoaderContext $context)
Get the URL or URLs to load for this module's JS in debug mode.
getVersionHash(ResourceLoaderContext $context)
Get a string identifying the current version of this module in a given context.
getGroup()
Get the group this module is in.
setLogger(LoggerInterface $logger)
getDefinitionSummary(ResourceLoaderContext $context)
Get the definition summary for this module.
static JSParser $jsParser
Lazy-initialized; use self::javaScriptParser()
getOrigin()
Get this module's origin.
getTargets()
Get target(s) for the module, eg ['desktop'] or ['desktop', 'mobile'].
getType()
Get the module's load type.
setFileDependencies(ResourceLoaderContext $context, $files)
Set in-object cache for file dependencies.
getStyleURLsForDebug(ResourceLoaderContext $context)
Get the URL or URLs to load for this module's CSS in debug mode.
setMessageBlob( $blob, $lang)
Set in-object cache for message blobs.
getPreloadLinks(ResourceLoaderContext $context)
Get a list of resources that web browsers may preload.
shouldEmbedModule(ResourceLoaderContext $context)
Check whether this module should be embeded rather than linked.
static safeFilemtime( $filePath)
Safe version of filemtime(), which doesn't throw a PHP warning if the file doesn't exist.
getSource()
Get the source of this module.
buildContent(ResourceLoaderContext $context)
Bundle all resources attached to this module into an array.
static getRelativePaths(array $filePaths)
Make file paths relative to MediaWiki directory.
getDeprecationInformation()
Get JS representing deprecation information for the current module if available.
saveFileDependencies(ResourceLoaderContext $context, $localFileRefs)
Set the files this module depends on indirectly for a given skin.
getName()
Get this module's name.
getHeaders(ResourceLoaderContext $context)
Get headers to send as part of a module web response.
getTemplates()
Takes named templates by the module and returns an array mapping.
Some information about database access in MediaWiki By Tim January Database layout For information about the MediaWiki database such as a description of the tables and their contents
Definition database.txt:9
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
see documentation in includes Linker php for Linker::makeImageLink or false for current used if you return false $parser
Definition hooks.txt:1834
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
Definition hooks.txt:2848
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition hooks.txt:3069
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 noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing & $attribs
Definition hooks.txt:2012
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 such as when responding to a resource loader request or generating HTML output & $resourceLoader
Definition hooks.txt:2859
and how to run hooks for an and one after Each event has a name
Definition hooks.txt:12
returning false will NOT prevent logging $e
Definition hooks.txt:2175
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
Definition injection.txt:37
Interface for configuration instances.
Definition Config.php:28
$cache
Definition mcc.php:33
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))
$content
const DB_REPLICA
Definition defines.php:25
const DB_MASTER
Definition defines.php:26
if(!isset( $args[0])) $lang