1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
|
<?php
/**
* This is included by Setup.php to adjust the values of globals before services are initialized.
* It's split into a separate file so it can be tested.
*/
use MediaWiki\Language\LanguageCode;
use MediaWiki\MainConfigSchema;
use MediaWiki\Title\NamespaceInfo;
use Wikimedia\AtEase\AtEase;
// For backwards compatibility, the value of wgLogos is copied to wgLogo.
// This is because some extensions/skins may be using $config->get('Logo')
// to access the value.
if ( $wgLogos !== false && isset( $wgLogos['1x'] ) ) {
$wgLogo = $wgLogos['1x'];
}
// Back-compat
if ( isset( $wgFileBlacklist ) ) {
$wgProhibitedFileExtensions = array_merge( $wgProhibitedFileExtensions, $wgFileBlacklist );
} else {
$wgFileBlacklist = $wgProhibitedFileExtensions;
}
if ( isset( $wgMimeTypeBlacklist ) ) {
$wgMimeTypeExclusions = array_merge( $wgMimeTypeExclusions, $wgMimeTypeBlacklist );
} else {
$wgMimeTypeBlacklist = $wgMimeTypeExclusions;
}
if ( isset( $wgEnableUserEmailBlacklist ) ) {
$wgEnableUserEmailMuteList = $wgEnableUserEmailBlacklist;
} else {
$wgEnableUserEmailBlacklist = $wgEnableUserEmailMuteList;
}
if ( isset( $wgShortPagesNamespaceBlacklist ) ) {
$wgShortPagesNamespaceExclusions = $wgShortPagesNamespaceBlacklist;
} else {
$wgShortPagesNamespaceBlacklist = $wgShortPagesNamespaceExclusions;
}
// Rate limits should have the same name as the corresponding permission
if ( isset( $wgRateLimits['emailuser'] ) ) {
// If the deprecated field is set, use it.
// Note that we can't know whether the new field has been set explicitly, since it has a default value.
$wgSettings->warning(
'RateLimit: The "emailuser" limit is deprecated, use "sendemail" instead.'
);
$wgRateLimits['sendemail'] = $wgRateLimits['emailuser'];
}
// Rate limits should have the same name as the corresponding permission
if ( isset( $wgRateLimits['changetag'] ) ) {
// If the deprecated field is set, use it.
// Note that we can't know whether the new field has been set explicitly, since it has a default value.
$wgSettings->warning(
'RateLimit: The "changetag" limit is deprecated, use "changetags" instead.'
);
$wgRateLimits['changetags'] = $wgRateLimits['changetag'];
}
// Prohibited file extensions shouldn't appear on the "allowed" list
// @phan-suppress-next-line PhanTypeMismatchArgumentNullableInternal False positive
$wgFileExtensions = array_values( array_diff( $wgFileExtensions, $wgProhibitedFileExtensions ) );
// Fix path to icon images after they were moved in 1.24
if ( $wgRightsIcon ) {
$wgRightsIcon = str_replace(
"{$wgStylePath}/common/images/",
"{$wgResourceBasePath}/resources/assets/licenses/",
$wgRightsIcon
);
}
if ( isset( $wgFooterIcons['copyright']['copyright'] )
&& $wgFooterIcons['copyright']['copyright'] === []
) {
if ( $wgRightsIcon || $wgRightsText ) {
$wgFooterIcons['copyright']['copyright'] = [
'url' => $wgRightsUrl,
'src' => $wgRightsIcon,
'alt' => $wgRightsText,
];
}
}
if ( isset( $wgFooterIcons['poweredby'] )
&& isset( $wgFooterIcons['poweredby']['mediawiki'] )
&& is_array( $wgFooterIcons['poweredby']['mediawiki'] )
&& $wgFooterIcons['poweredby']['mediawiki']['src'] === null
) {
$wgFooterIcons['poweredby']['mediawiki']['src'] =
"$wgResourceBasePath/resources/assets/poweredby_mediawiki.svg";
}
// Unconditional protection for NS_MEDIAWIKI since otherwise it's too easy for a
// sysadmin to set $wgNamespaceProtection incorrectly and leave the wiki insecure.
//
// Note that this is the definition of editinterface and it can be granted to
// all users if desired.
$wgNamespaceProtection[NS_MEDIAWIKI] = 'editinterface';
// Initialise $wgLockManagers to include basic FS version
$wgLockManagers[] = [
'name' => 'fsLockManager',
'class' => FSLockManager::class,
'lockDirectory' => "{$wgUploadDirectory}/lockdir",
];
$wgLockManagers[] = [
'name' => 'nullLockManager',
'class' => NullLockManager::class,
];
// Default parameters for the "<gallery>" tag.
// See \MediaWiki\MainConfigSchema::GalleryOptions
$wgGalleryOptions += [
'imagesPerRow' => 0,
'imageWidth' => 120,
'imageHeight' => 120,
'captionLength' => true,
'showBytes' => true,
'showDimensions' => true,
'mode' => 'traditional',
];
if ( isset( $wgLocalFileRepo['name'] ) && !isset( $wgLocalFileRepo['backend'] ) ) {
// Create a default FileBackend name.
// FileBackendGroup will register a default, if absent from $wgFileBackends.
$wgLocalFileRepo['backend'] = $wgLocalFileRepo['name'] . '-backend';
}
/**
* Shortcuts for $wgForeignFileRepos
*/
if ( $wgUseSharedUploads ) {
if ( $wgSharedUploadDBname ) {
$wgForeignFileRepos[] = [
'class' => ForeignDBRepo::class,
'name' => 'shared',
'directory' => $wgSharedUploadDirectory,
'url' => $wgSharedUploadPath,
'hashLevels' => $wgHashedSharedUploadDirectory ? 2 : 0,
'thumbScriptUrl' => $wgSharedThumbnailScriptPath,
'transformVia404' => !$wgGenerateThumbnailOnParse,
'dbType' => $wgDBtype,
'dbServer' => $wgDBserver,
'dbUser' => $wgDBuser,
'dbPassword' => $wgDBpassword,
'dbName' => $wgSharedUploadDBname,
'dbFlags' => ( $wgDebugDumpSql ? DBO_DEBUG : 0 ) | DBO_DEFAULT,
'tablePrefix' => $wgSharedUploadDBprefix,
'hasSharedCache' => $wgCacheSharedUploads,
'descBaseUrl' => $wgRepositoryBaseUrl,
'fetchDescription' => $wgFetchCommonsDescriptions,
];
} else {
$wgForeignFileRepos[] = [
'class' => FileRepo::class,
'name' => 'shared',
'directory' => $wgSharedUploadDirectory,
'url' => $wgSharedUploadPath,
'hashLevels' => $wgHashedSharedUploadDirectory ? 2 : 0,
'thumbScriptUrl' => $wgSharedThumbnailScriptPath,
'transformVia404' => !$wgGenerateThumbnailOnParse,
'descBaseUrl' => $wgRepositoryBaseUrl,
'fetchDescription' => $wgFetchCommonsDescriptions,
];
}
}
if ( $wgUseInstantCommons ) {
$wgForeignFileRepos[] = [
'class' => ForeignAPIRepo::class,
'name' => 'wikimediacommons',
'apibase' => 'https://commons.wikimedia.org/w/api.php',
'url' => 'https://upload.wikimedia.org/wikipedia/commons',
'thumbUrl' => 'https://upload.wikimedia.org/wikipedia/commons/thumb',
'hashLevels' => 2,
'transformVia404' => true,
'fetchDescription' => true,
'descriptionCacheExpiry' => 43200,
'apiThumbCacheExpiry' => 0,
];
}
foreach ( $wgForeignFileRepos as &$repo ) {
if ( !isset( $repo['directory'] ) && $repo['class'] === ForeignAPIRepo::class ) {
$repo['directory'] = $wgUploadDirectory; // b/c
}
if ( !isset( $repo['backend'] ) ) {
$repo['backend'] = $repo['name'] . '-backend';
}
}
unset( $repo ); // no global pollution; destroy reference
$rcMaxAgeDays = $wgRCMaxAge / ( 3600 * 24 );
// Ensure that default user options are not invalid, since that breaks Special:Preferences
$wgDefaultUserOptions['rcdays'] = min(
$wgDefaultUserOptions['rcdays'],
ceil( $rcMaxAgeDays )
);
$wgDefaultUserOptions['watchlistdays'] = min(
$wgDefaultUserOptions['watchlistdays'],
ceil( $rcMaxAgeDays )
);
unset( $rcMaxAgeDays );
$wgCookiePrefix = strtr( $wgCookiePrefix, '=,; +."\'\\[', '__________' );
if ( !$wgEnableEmail ) {
// Disable all other email settings automatically if $wgEnableEmail
// is set to false. - T65678
$wgAllowHTMLEmail = false;
$wgEmailAuthentication = false; // do not require auth if you're not sending email anyway
$wgEnableUserEmail = false;
$wgEnotifFromEditor = false;
$wgEnotifImpersonal = false;
$wgEnotifMaxRecips = 0;
$wgEnotifMinorEdits = false;
$wgEnotifRevealEditorAddress = false;
$wgEnotifUseRealName = false;
$wgEnotifUserTalk = false;
$wgEnotifWatchlist = false;
unset( $wgGroupPermissions['user']['sendemail'] );
$wgUserEmailUseReplyTo = false;
$wgUsersNotifiedOnAllChanges = [];
}
if ( !$wgLocaltimezone ) {
// NOTE: The automatic dynamic default only kicks in if $wgLocaltimezone is null,
// but the installer writes $wgLocaltimezone into LocalSettings, and may
// produce (or may have produced historically) an empty string for some
// reason. To be compatible with existing LocalSettings.php files, we need
// to gracefully handle the case of $wgLocaltimezone being the empty string.
// See T305093#8063451.
$wgLocaltimezone = MainConfigSchema::getDefaultLocaltimezone();
$wgSettings->warning(
'The Localtimezone setting must a valid timezone string or null. '
. 'It must not be an empty string or false.'
);
}
// The part after the System| is ignored, but rest of MW fills it out as the local offset.
$wgDefaultUserOptions['timecorrection'] = "System|$wgLocalTZoffset";
/**
* Definitions of the NS_ constants are in Defines.php
* @internal
*/
$wgCanonicalNamespaceNames = NamespaceInfo::CANONICAL_NAMES;
// Hard-deprecate setting $wgDummyLanguageCodes in LocalSettings.php
if ( count( $wgDummyLanguageCodes ) !== 0 ) {
$wgSettings->warning(
'Do not add to DummyLanguageCodes directly, ' .
'add to ExtraLanguageCodes instead.'
);
}
// Merge in the legacy language codes, incorporating overrides from the config
$wgDummyLanguageCodes += [
// Internal language codes of the private-use area which get mapped to
// themselves.
'qqq' => 'qqq', // Used for message documentation
'qqx' => 'qqx', // Used for viewing message keys
] + $wgExtraLanguageCodes + LanguageCode::getDeprecatedCodeMapping();
// Merge in (inverted) BCP 47 mappings
foreach ( LanguageCode::getNonstandardLanguageCodeMapping() as $code => $bcp47 ) {
$bcp47 = strtolower( $bcp47 ); // force case-insensitivity
if ( !isset( $wgDummyLanguageCodes[$bcp47] ) ) {
$wgDummyLanguageCodes[$bcp47] = $wgDummyLanguageCodes[$code] ?? $code;
}
}
unset( $code ); // no global pollution; destroy reference
unset( $bcp47 ); // no global pollution; destroy reference
if ( $wgUseXssLanguage ) {
$wgDummyLanguageCodes['x-xss'] = 'x-xss'; // Used for testing
}
// Temporary backwards-compatibility reading of old replica lag settings as of MediaWiki 1.36,
// to support sysadmins who fail to update their settings immediately:
if ( isset( $wgSlaveLagWarning ) ) {
// If the old value is set to something other than the default, use it.
if ( $wgDatabaseReplicaLagWarning === 10 && $wgSlaveLagWarning !== 10 ) {
$wgDatabaseReplicaLagWarning = $wgSlaveLagWarning;
$wgSettings->warning( 'SlaveLagWarning is no longer supported, ' .
'use DatabaseReplicaLagWarning instead!' );
}
} else {
// Backwards-compatibility for extensions that read this value.
$wgSlaveLagWarning = $wgDatabaseReplicaLagWarning;
}
if ( isset( $wgSlaveLagCritical ) ) {
// If the old value is set to something other than the default, use it.
if ( $wgDatabaseReplicaLagCritical === 30 && $wgSlaveLagCritical !== 30 ) {
$wgDatabaseReplicaLagCritical = $wgSlaveLagCritical;
$wgSettings->warning( 'SlaveLagCritical is no longer supported, ' .
'use DatabaseReplicaLagCritical instead!' );
}
} else {
// Backwards-compatibility for extensions that read this value.
$wgSlaveLagCritical = $wgDatabaseReplicaLagCritical;
}
if ( $wgInvalidateCacheOnLocalSettingsChange && defined( 'MW_CONFIG_FILE' ) ) {
AtEase::suppressWarnings();
$wgCacheEpoch = max( $wgCacheEpoch, gmdate( 'YmdHis', filemtime( MW_CONFIG_FILE ) ) );
AtEase::restoreWarnings();
}
if ( $wgNewUserLog ) {
// Add new user log type
$wgLogTypes[] = 'newusers';
$wgLogNames['newusers'] = 'newuserlogpage';
$wgLogHeaders['newusers'] = 'newuserlogpagetext';
$wgLogActionsHandlers['newusers/newusers'] = NewUsersLogFormatter::class;
$wgLogActionsHandlers['newusers/create'] = NewUsersLogFormatter::class;
$wgLogActionsHandlers['newusers/create2'] = NewUsersLogFormatter::class;
$wgLogActionsHandlers['newusers/byemail'] = NewUsersLogFormatter::class;
$wgLogActionsHandlers['newusers/autocreate'] = NewUsersLogFormatter::class;
}
if ( $wgPageCreationLog ) {
// Add page creation log type
$wgLogTypes[] = 'create';
$wgLogActionsHandlers['create/create'] = LogFormatter::class;
}
if ( $wgPageLanguageUseDB ) {
$wgLogTypes[] = 'pagelang';
$wgLogActionsHandlers['pagelang/pagelang'] = [
'class' => PageLangLogFormatter::class,
'services' => [
'LanguageNameUtils',
]
];
}
if ( $wgPHPSessionHandling !== 'enable' &&
$wgPHPSessionHandling !== 'warn' &&
$wgPHPSessionHandling !== 'disable'
) {
$wgPHPSessionHandling = 'warn';
}
if ( defined( 'MW_NO_SESSION' ) ) {
// If the entry point wants no session, force 'disable' here unless they
// specifically set it to the (undocumented) 'warn'.
$wgPHPSessionHandling = MW_NO_SESSION === 'warn' ? 'warn' : 'disable';
}
// Backwards compatibility with old bot passwords storage configs
if ( !$wgVirtualDomainsMapping ) {
$wgVirtualDomainsMapping = [];
}
if ( $wgBotPasswordsCluster ) {
$wgVirtualDomainsMapping['virtual-botpasswords']['cluster'] = $wgBotPasswordsCluster;
}
if ( $wgBotPasswordsDatabase ) {
$wgVirtualDomainsMapping['virtual-botpasswords']['db'] = $wgBotPasswordsDatabase;
}
|