MediaWiki REL1_39
SetupDynamicConfig.php
Go to the documentation of this file.
1<?php
8use Wikimedia\AtEase\AtEase;
9
10// For backwards compatibility, the value of wgLogos is copied to wgLogo.
11// This is because some extensions/skins may be using $config->get('Logo')
12// to access the value.
13if ( $wgLogos !== false && isset( $wgLogos['1x'] ) ) {
14 $wgLogo = $wgLogos['1x'];
15}
16
17if ( $wgMainWANCache === false ) {
18 // Create a WAN cache from $wgMainCacheType
19 $wgMainWANCache = 'mediawiki-main-default';
21 'class' => WANObjectCache::class,
22 'cacheId' => $wgMainCacheType,
23 ];
24}
25
26// Back-compat
27if ( isset( $wgFileBlacklist ) ) {
28 $wgProhibitedFileExtensions = array_merge( $wgProhibitedFileExtensions, $wgFileBlacklist );
29} else {
30 $wgFileBlacklist = $wgProhibitedFileExtensions;
31}
32if ( isset( $wgMimeTypeBlacklist ) ) {
33 $wgMimeTypeExclusions = array_merge( $wgMimeTypeExclusions, $wgMimeTypeBlacklist );
34} else {
35 $wgMimeTypeBlacklist = $wgMimeTypeExclusions;
36}
37if ( isset( $wgEnableUserEmailBlacklist ) ) {
38 $wgEnableUserEmailMuteList = $wgEnableUserEmailBlacklist;
39} else {
40 $wgEnableUserEmailBlacklist = $wgEnableUserEmailMuteList;
41}
42if ( isset( $wgShortPagesNamespaceBlacklist ) ) {
43 $wgShortPagesNamespaceExclusions = $wgShortPagesNamespaceBlacklist;
44} else {
45 $wgShortPagesNamespaceBlacklist = $wgShortPagesNamespaceExclusions;
46}
47
48// Prohibited file extensions shouldn't appear on the "allowed" list
49// @phan-suppress-next-line PhanTypeMismatchArgumentNullableInternal False positive
51
52// Fix path to icon images after they were moved in 1.24
53if ( $wgRightsIcon ) {
54 $wgRightsIcon = str_replace(
55 "{$wgStylePath}/common/images/",
56 "{$wgResourceBasePath}/resources/assets/licenses/",
58 );
59}
60
61if ( isset( $wgFooterIcons['copyright']['copyright'] )
62 && $wgFooterIcons['copyright']['copyright'] === []
63) {
65 $wgFooterIcons['copyright']['copyright'] = [
66 'url' => $wgRightsUrl,
67 'src' => $wgRightsIcon,
68 'alt' => $wgRightsText,
69 ];
70 }
71}
72
73if ( isset( $wgFooterIcons['poweredby'] )
74 && isset( $wgFooterIcons['poweredby']['mediawiki'] )
75 && $wgFooterIcons['poweredby']['mediawiki']['src'] === null
76) {
77 $wgFooterIcons['poweredby']['mediawiki']['src'] =
78 "$wgResourceBasePath/resources/assets/poweredby_mediawiki_88x31.png";
79 $wgFooterIcons['poweredby']['mediawiki']['srcset'] =
80 "$wgResourceBasePath/resources/assets/poweredby_mediawiki_132x47.png 1.5x, " .
81 "$wgResourceBasePath/resources/assets/poweredby_mediawiki_176x62.png 2x";
82}
83
92
97 'name' => 'fsLockManager',
98 'class' => FSLockManager::class,
99 'lockDirectory' => "{$wgUploadDirectory}/lockdir",
100];
101$wgLockManagers[] = [
102 'name' => 'nullLockManager',
103 'class' => NullLockManager::class,
104];
105
111 'imagesPerRow' => 0,
112 'imageWidth' => 120,
113 'imageHeight' => 120,
114 'captionLength' => true,
115 'showBytes' => true,
116 'showDimensions' => true,
117 'mode' => 'traditional',
118];
119
120if ( isset( $wgLocalFileRepo['name'] ) && !isset( $wgLocalFileRepo['backend'] ) ) {
121 // Create a default FileBackend name.
122 // FileBackendGroup will register a default, if absent from $wgFileBackends.
123 $wgLocalFileRepo['backend'] = $wgLocalFileRepo['name'] . '-backend';
124}
125
129if ( $wgUseSharedUploads ) {
130 if ( $wgSharedUploadDBname ) {
132 'class' => ForeignDBRepo::class,
133 'name' => 'shared',
134 'directory' => $wgSharedUploadDirectory,
135 'url' => $wgSharedUploadPath,
136 'hashLevels' => $wgHashedSharedUploadDirectory ? 2 : 0,
137 'thumbScriptUrl' => $wgSharedThumbnailScriptPath,
138 'transformVia404' => !$wgGenerateThumbnailOnParse,
139 'dbType' => $wgDBtype,
140 'dbServer' => $wgDBserver,
141 'dbUser' => $wgDBuser,
142 'dbPassword' => $wgDBpassword,
143 'dbName' => $wgSharedUploadDBname,
144 'dbFlags' => ( $wgDebugDumpSql ? DBO_DEBUG : 0 ) | DBO_DEFAULT,
145 'tablePrefix' => $wgSharedUploadDBprefix,
146 'hasSharedCache' => $wgCacheSharedUploads,
147 'descBaseUrl' => $wgRepositoryBaseUrl,
148 'fetchDescription' => $wgFetchCommonsDescriptions,
149 ];
150 } else {
152 'class' => FileRepo::class,
153 'name' => 'shared',
154 'directory' => $wgSharedUploadDirectory,
155 'url' => $wgSharedUploadPath,
156 'hashLevels' => $wgHashedSharedUploadDirectory ? 2 : 0,
157 'thumbScriptUrl' => $wgSharedThumbnailScriptPath,
158 'transformVia404' => !$wgGenerateThumbnailOnParse,
159 'descBaseUrl' => $wgRepositoryBaseUrl,
160 'fetchDescription' => $wgFetchCommonsDescriptions,
161 ];
162 }
163}
166 'class' => ForeignAPIRepo::class,
167 'name' => 'wikimediacommons',
168 'apibase' => 'https://commons.wikimedia.org/w/api.php',
169 'url' => 'https://upload.wikimedia.org/wikipedia/commons',
170 'thumbUrl' => 'https://upload.wikimedia.org/wikipedia/commons/thumb',
171 'hashLevels' => 2,
172 'transformVia404' => true,
173 'fetchDescription' => true,
174 'descriptionCacheExpiry' => 43200,
175 'apiThumbCacheExpiry' => 0,
176 ];
177}
178foreach ( $wgForeignFileRepos as &$repo ) {
179 if ( !isset( $repo['directory'] ) && $repo['class'] === ForeignAPIRepo::class ) {
180 $repo['directory'] = $wgUploadDirectory; // b/c
181 }
182 if ( !isset( $repo['backend'] ) ) {
183 $repo['backend'] = $repo['name'] . '-backend';
184 }
185}
186unset( $repo ); // no global pollution; destroy reference
187
188$rcMaxAgeDays = $wgRCMaxAge / ( 3600 * 24 );
189// Ensure that default user options are not invalid, since that breaks Special:Preferences
190$wgDefaultUserOptions['rcdays'] = min(
191 $wgDefaultUserOptions['rcdays'],
192 ceil( $rcMaxAgeDays )
193);
194$wgDefaultUserOptions['watchlistdays'] = min(
195 $wgDefaultUserOptions['watchlistdays'],
196 ceil( $rcMaxAgeDays )
197);
198unset( $rcMaxAgeDays );
199
200$wgCookiePrefix = strtr( $wgCookiePrefix, '=,; +."\'\\[', '__________' );
201
202if ( !$wgEnableEmail ) {
203 // Disable all other email settings automatically if $wgEnableEmail
204 // is set to false. - T65678
205 $wgAllowHTMLEmail = false;
206 $wgEmailAuthentication = false; // do not require auth if you're not sending email anyway
207 $wgEnableUserEmail = false;
208 $wgEnotifFromEditor = false;
209 $wgEnotifImpersonal = false;
211 $wgEnotifMinorEdits = false;
213 $wgEnotifUseRealName = false;
214 $wgEnotifUserTalk = false;
215 $wgEnotifWatchlist = false;
216 unset( $wgGroupPermissions['user']['sendemail'] );
219}
220
221if ( !$wgLocaltimezone ) {
222 // NOTE: The automatic dynamic default only kicks in if $wgLocaltimezone is null,
223 // but the installer writes $wgLocaltimezone into LocalSettings, and may
224 // produce (or may have produced historically) an empty string for some
225 // reason. To be compatible with existing LocalSettings.php files, we need
226 // to gracefully handle the case of $wgLocaltimezone being the empty string.
227 // See T305093#8063451.
228 $wgLocaltimezone = MainConfigSchema::getDefaultLocaltimezone();
229 $wgSettings->warning(
230 'The Localtimezone setting must a valid timezone string or null. '
231 . 'It must not be an empty string or false.'
232 );
233}
234
235// The part after the System| is ignored, but rest of MW fills it out as the local offset.
236$wgDefaultUserOptions['timecorrection'] = "System|$wgLocalTZoffset";
237
242$wgCanonicalNamespaceNames = NamespaceInfo::CANONICAL_NAMES;
243
244// Hard-deprecate setting $wgDummyLanguageCodes in LocalSettings.php
245if ( count( $wgDummyLanguageCodes ) !== 0 ) {
246 $wgSettings->warning(
247 'Do not add to DummyLanguageCodes directly, ' .
248 'add to ExtraLanguageCodes instead.'
249 );
250}
251// Merge in the legacy language codes, incorporating overrides from the config
253 // Internal language codes of the private-use area which get mapped to
254 // themselves.
255 'qqq' => 'qqq', // Used for message documentation
256 'qqx' => 'qqx', // Used for viewing message keys
257] + $wgExtraLanguageCodes + LanguageCode::getDeprecatedCodeMapping();
258// Merge in (inverted) BCP 47 mappings
259foreach ( LanguageCode::getNonstandardLanguageCodeMapping() as $code => $bcp47 ) {
260 $bcp47 = strtolower( $bcp47 ); // force case-insensitivity
261 if ( !isset( $wgDummyLanguageCodes[$bcp47] ) ) {
262 $wgDummyLanguageCodes[$bcp47] = $wgDummyLanguageCodes[$code] ?? $code;
263 }
264}
265unset( $code ); // no global pollution; destroy reference
266unset( $bcp47 ); // no global pollution; destroy reference
267
268// Temporary backwards-compatibility reading of old replica lag settings as of MediaWiki 1.36,
269// to support sysadmins who fail to update their settings immediately:
270
271if ( isset( $wgSlaveLagWarning ) ) {
272 // If the old value is set to something other than the default, use it.
273 if ( $wgDatabaseReplicaLagWarning === 10 && $wgSlaveLagWarning !== 10 ) {
274 $wgDatabaseReplicaLagWarning = $wgSlaveLagWarning;
275 $wgSettings->warning( 'SlaveLagWarning is no longer supported, ' .
276 'use DatabaseReplicaLagWarning instead!' );
277 }
278} else {
279 // Backwards-compatibility for extensions that read this value.
280 $wgSlaveLagWarning = $wgDatabaseReplicaLagWarning;
281}
282
283if ( isset( $wgSlaveLagCritical ) ) {
284 // If the old value is set to something other than the default, use it.
285 if ( $wgDatabaseReplicaLagCritical === 30 && $wgSlaveLagCritical !== 30 ) {
286 $wgDatabaseReplicaLagCritical = $wgSlaveLagCritical;
287 $wgSettings->warning( 'SlaveLagCritical is no longer supported, ' .
288 'use DatabaseReplicaLagCritical instead!' );
289 }
290} else {
291 // Backwards-compatibility for extensions that read this value.
292 $wgSlaveLagCritical = $wgDatabaseReplicaLagCritical;
293}
294
295if ( $wgInvalidateCacheOnLocalSettingsChange && defined( 'MW_CONFIG_FILE' ) ) {
296 AtEase::suppressWarnings();
297 $wgCacheEpoch = max( $wgCacheEpoch, gmdate( 'YmdHis', filemtime( MW_CONFIG_FILE ) ) );
298 AtEase::restoreWarnings();
299}
300
301if ( $wgNewUserLog ) {
302 // Add new user log type
303 $wgLogTypes[] = 'newusers';
304 $wgLogNames['newusers'] = 'newuserlogpage';
305 $wgLogHeaders['newusers'] = 'newuserlogpagetext';
306 $wgLogActionsHandlers['newusers/newusers'] = NewUsersLogFormatter::class;
307 $wgLogActionsHandlers['newusers/create'] = NewUsersLogFormatter::class;
308 $wgLogActionsHandlers['newusers/create2'] = NewUsersLogFormatter::class;
309 $wgLogActionsHandlers['newusers/byemail'] = NewUsersLogFormatter::class;
310 $wgLogActionsHandlers['newusers/autocreate'] = NewUsersLogFormatter::class;
311}
312
313if ( $wgPageCreationLog ) {
314 // Add page creation log type
315 $wgLogTypes[] = 'create';
316 $wgLogActionsHandlers['create/create'] = LogFormatter::class;
317}
318
320 $wgLogTypes[] = 'pagelang';
321 $wgLogActionsHandlers['pagelang/pagelang'] = PageLangLogFormatter::class;
322}
323
324// Backwards compatibility with old password limits
325if ( $wgMinimalPasswordLength !== false ) {
326 $wgPasswordPolicy['policies']['default']['MinimalPasswordLength'] = $wgMinimalPasswordLength;
327}
328
329if ( $wgMaximalPasswordLength !== false ) {
330 $wgPasswordPolicy['policies']['default']['MaximalPasswordLength'] = $wgMaximalPasswordLength;
331}
332
333if ( $wgPHPSessionHandling !== 'enable' &&
334 $wgPHPSessionHandling !== 'warn' &&
335 $wgPHPSessionHandling !== 'disable'
336) {
337 $wgPHPSessionHandling = 'warn';
338}
339if ( defined( 'MW_NO_SESSION' ) ) {
340 // If the entry point wants no session, force 'disable' here unless they
341 // specifically set it to the (undocumented) 'warn'.
342 $wgPHPSessionHandling = MW_NO_SESSION === 'warn' ? 'warn' : 'disable';
343}
const NS_MEDIAWIKI
Definition Defines.php:72
$wgGalleryOptions
Default parameters for the "<gallery>" tag.
$wgFileExtensions
$wgCanonicalNamespaceNames
Definitions of the NS_ constants are in Defines.php.
if( $wgRightsIcon) if(isset($wgFooterIcons[ 'copyright'][ 'copyright']) &&$wgFooterIcons[ 'copyright'][ 'copyright']===[]) if(isset( $wgFooterIcons['poweredby']) &&isset( $wgFooterIcons['poweredby']['mediawiki']) && $wgFooterIcons['poweredby']['mediawiki']['src']===null) $wgNamespaceProtection[NS_MEDIAWIKI]
Unconditional protection for NS_MEDIAWIKI since otherwise it's too easy for a sysadmin to set $wgName...
if(count( $wgDummyLanguageCodes) !==0) $wgDummyLanguageCodes
$wgLockManagers[]
Initialise $wgLockManagers to include basic FS version.
$wgDefaultUserOptions['rcdays']
$wgSettings
Definition Setup.php:143
This class contains schema declarations for all configuration variables known to MediaWiki core.
$wgProhibitedFileExtensions
Config variable stub for the ProhibitedFileExtensions setting, for use by phpdoc and IDEs.
$wgRightsIcon
Config variable stub for the RightsIcon setting, for use by phpdoc and IDEs.
$wgCacheEpoch
Config variable stub for the CacheEpoch setting, for use by phpdoc and IDEs.
$wgSharedThumbnailScriptPath
Config variable stub for the SharedThumbnailScriptPath setting, for use by phpdoc and IDEs.
$wgEnotifWatchlist
Config variable stub for the EnotifWatchlist setting, for use by phpdoc and IDEs.
$wgDBuser
Config variable stub for the DBuser setting, for use by phpdoc and IDEs.
$wgEnotifMaxRecips
Config variable stub for the EnotifMaxRecips setting, for use by phpdoc and IDEs.
$wgEnotifUserTalk
Config variable stub for the EnotifUserTalk setting, for use by phpdoc and IDEs.
$wgPageLanguageUseDB
Config variable stub for the PageLanguageUseDB setting, for use by phpdoc and IDEs.
$wgUseInstantCommons
Config variable stub for the UseInstantCommons setting, for use by phpdoc and IDEs.
$wgEnableUserEmailMuteList
Config variable stub for the EnableUserEmailMuteList setting, for use by phpdoc and IDEs.
$wgHashedSharedUploadDirectory
Config variable stub for the HashedSharedUploadDirectory setting, for use by phpdoc and IDEs.
$wgGenerateThumbnailOnParse
Config variable stub for the GenerateThumbnailOnParse setting, for use by phpdoc and IDEs.
$wgRightsUrl
Config variable stub for the RightsUrl setting, for use by phpdoc and IDEs.
$wgMainCacheType
Config variable stub for the MainCacheType setting, for use by phpdoc and IDEs.
$wgEnableUserEmail
Config variable stub for the EnableUserEmail setting, for use by phpdoc and IDEs.
$wgPasswordPolicy
Config variable stub for the PasswordPolicy setting, for use by phpdoc and IDEs.
$wgLogNames
Config variable stub for the LogNames setting, for use by phpdoc and IDEs.
$wgSharedUploadPath
Config variable stub for the SharedUploadPath setting, for use by phpdoc and IDEs.
$wgInvalidateCacheOnLocalSettingsChange
Config variable stub for the InvalidateCacheOnLocalSettingsChange setting, for use by phpdoc and IDEs...
$wgDBtype
Config variable stub for the DBtype setting, for use by phpdoc and IDEs.
$wgUploadDirectory
Config variable stub for the UploadDirectory setting, for use by phpdoc and IDEs.
$wgLogTypes
Config variable stub for the LogTypes setting, for use by phpdoc and IDEs.
$wgMaximalPasswordLength
Config variable stub for the MaximalPasswordLength setting, for use by phpdoc and IDEs.
$wgShortPagesNamespaceExclusions
Config variable stub for the ShortPagesNamespaceExclusions setting, for use by phpdoc and IDEs.
$wgSharedUploadDirectory
Config variable stub for the SharedUploadDirectory setting, for use by phpdoc and IDEs.
$wgRightsText
Config variable stub for the RightsText setting, for use by phpdoc and IDEs.
$wgEnotifFromEditor
Config variable stub for the EnotifFromEditor setting, for use by phpdoc and IDEs.
$wgPageCreationLog
Config variable stub for the PageCreationLog setting, for use by phpdoc and IDEs.
$wgDatabaseReplicaLagCritical
Config variable stub for the DatabaseReplicaLagCritical setting, for use by phpdoc and IDEs.
$wgEnotifRevealEditorAddress
Config variable stub for the EnotifRevealEditorAddress setting, for use by phpdoc and IDEs.
$wgFooterIcons
Config variable stub for the FooterIcons setting, for use by phpdoc and IDEs.
$wgCacheSharedUploads
Config variable stub for the CacheSharedUploads setting, for use by phpdoc and IDEs.
$wgEnableEmail
Config variable stub for the EnableEmail setting, for use by phpdoc and IDEs.
$wgEnotifImpersonal
Config variable stub for the EnotifImpersonal setting, for use by phpdoc and IDEs.
$wgUsersNotifiedOnAllChanges
Config variable stub for the UsersNotifiedOnAllChanges setting, for use by phpdoc and IDEs.
$wgRCMaxAge
Config variable stub for the RCMaxAge setting, for use by phpdoc and IDEs.
$wgLocaltimezone
Config variable stub for the Localtimezone setting, for use by phpdoc and IDEs.
$wgUserEmailUseReplyTo
Config variable stub for the UserEmailUseReplyTo setting, for use by phpdoc and IDEs.
$wgGroupPermissions
Config variable stub for the GroupPermissions setting, for use by phpdoc and IDEs.
$wgLocalFileRepo
Config variable stub for the LocalFileRepo setting, for use by phpdoc and IDEs.
$wgWANObjectCaches
Config variable stub for the WANObjectCaches setting, for use by phpdoc and IDEs.
$wgAllowHTMLEmail
Config variable stub for the AllowHTMLEmail setting, for use by phpdoc and IDEs.
$wgSharedUploadDBname
Config variable stub for the SharedUploadDBname setting, for use by phpdoc and IDEs.
$wgLogos
Config variable stub for the Logos setting, for use by phpdoc and IDEs.
$wgForeignFileRepos
Config variable stub for the ForeignFileRepos setting, for use by phpdoc and IDEs.
$wgRepositoryBaseUrl
Config variable stub for the RepositoryBaseUrl setting, for use by phpdoc and IDEs.
$wgLogHeaders
Config variable stub for the LogHeaders setting, for use by phpdoc and IDEs.
$wgSharedUploadDBprefix
Config variable stub for the SharedUploadDBprefix setting, for use by phpdoc and IDEs.
$wgEnotifMinorEdits
Config variable stub for the EnotifMinorEdits setting, for use by phpdoc and IDEs.
$wgDebugDumpSql
Config variable stub for the DebugDumpSql setting, for use by phpdoc and IDEs.
$wgDatabaseReplicaLagWarning
Config variable stub for the DatabaseReplicaLagWarning setting, for use by phpdoc and IDEs.
$wgFetchCommonsDescriptions
Config variable stub for the FetchCommonsDescriptions setting, for use by phpdoc and IDEs.
$wgDBserver
Config variable stub for the DBserver setting, for use by phpdoc and IDEs.
$wgMimeTypeExclusions
Config variable stub for the MimeTypeExclusions setting, for use by phpdoc and IDEs.
$wgExtraLanguageCodes
Config variable stub for the ExtraLanguageCodes setting, for use by phpdoc and IDEs.
$wgMinimalPasswordLength
Config variable stub for the MinimalPasswordLength setting, for use by phpdoc and IDEs.
$wgEmailAuthentication
Config variable stub for the EmailAuthentication setting, for use by phpdoc and IDEs.
$wgLogo
Config variable stub for the Logo setting, for use by phpdoc and IDEs.
$wgLogActionsHandlers
Config variable stub for the LogActionsHandlers setting, for use by phpdoc and IDEs.
$wgMainWANCache
Config variable stub for the MainWANCache setting, for use by phpdoc and IDEs.
$wgPHPSessionHandling
Config variable stub for the PHPSessionHandling setting, for use by phpdoc and IDEs.
$wgUseSharedUploads
Config variable stub for the UseSharedUploads setting, for use by phpdoc and IDEs.
$wgDBpassword
Config variable stub for the DBpassword setting, for use by phpdoc and IDEs.
$wgEnotifUseRealName
Config variable stub for the EnotifUseRealName setting, for use by phpdoc and IDEs.
$wgNewUserLog
Config variable stub for the NewUserLog setting, for use by phpdoc and IDEs.
const MW_NO_SESSION
Definition load.php:33
const DBO_DEFAULT
Definition defines.php:13
const DBO_DEBUG
Definition defines.php:9