Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
18.92% |
14 / 74 |
|
0.00% |
0 / 26 |
CRAP | |
0.00% |
0 / 1 |
MainConfigSchema | |
18.92% |
14 / 74 |
|
0.00% |
0 / 26 |
1224.48 | |
0.00% |
0 / 1 |
listDefaultValues | |
81.82% |
9 / 11 |
|
0.00% |
0 / 1 |
5.15 | |||
getDefaultValue | |
71.43% |
5 / 7 |
|
0.00% |
0 / 1 |
3.21 | |||
getDefaultUsePathInfo | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
12 | |||
getDefaultScript | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getDefaultLoadScript | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getDefaultRestPath | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getDefaultStylePath | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getDefaultLocalStylePath | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getDefaultExtensionAssetsPath | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getDefaultArticlePath | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
getDefaultUploadPath | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getDefaultFileCacheDirectory | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getDefaultLogo | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getDefaultDeletedDirectory | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getDefaultLocalFileRepo | |
0.00% |
0 / 15 |
|
0.00% |
0 / 1 |
20 | |||
getDefaultShowEXIF | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getDefaultSharedPrefix | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getDefaultSharedSchema | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getDefaultDBerrorLogTZ | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
6 | |||
getDefaultLocaltimezone | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
getDefaultLocalTZoffset | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
12 | |||
getDefaultResourceBasePath | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getDefaultMetaNamespace | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getDefaultCookieSecure | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
6 | |||
getDefaultCookiePrefix | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
30 | |||
getDefaultReadOnlyFile | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | /** |
3 | * This file contains schema declarations for all configuration variables |
4 | * known to MediaWiki core. |
5 | * |
6 | * @file |
7 | * @ingroup Config |
8 | */ |
9 | |
10 | // phpcs:disable Generic.NamingConventions.UpperCaseConstantName.ClassConstantNotUpperCase |
11 | // phpcs:disable Generic.Files.LineLength.TooLong |
12 | namespace MediaWiki; |
13 | |
14 | use AssembleUploadChunksJob; |
15 | use BlockLogFormatter; |
16 | use CategoryMembershipChangeJob; |
17 | use CdnPurgeJob; |
18 | use ContentModelLogFormatter; |
19 | use DateTime; |
20 | use DateTimeZone; |
21 | use DeleteLinksJob; |
22 | use DeleteLogFormatter; |
23 | use DeletePageJob; |
24 | use DoubleRedirectJob; |
25 | use EmaillingJob; |
26 | use EnotifNotifyJob; |
27 | use Generator; |
28 | use HTMLCacheUpdateJob; |
29 | use ImportLogFormatter; |
30 | use InterwikiLogFormatter; |
31 | use InvalidArgumentException; |
32 | use JobQueueDB; |
33 | use LocalisationCache; |
34 | use LocalRepo; |
35 | use LogFormatter; |
36 | use MediaWiki\Auth\CheckBlocksSecondaryAuthenticationProvider; |
37 | use MediaWiki\Auth\EmailNotificationSecondaryAuthenticationProvider; |
38 | use MediaWiki\Auth\LocalPasswordPrimaryAuthenticationProvider; |
39 | use MediaWiki\Auth\PasswordAuthenticationRequest; |
40 | use MediaWiki\Auth\ResetPasswordSecondaryAuthenticationProvider; |
41 | use MediaWiki\Auth\TemporaryPasswordAuthenticationRequest; |
42 | use MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProvider; |
43 | use MediaWiki\Auth\ThrottlePreAuthenticationProvider; |
44 | use MediaWiki\Config\ConfigException; |
45 | use MediaWiki\Content\CssContentHandler; |
46 | use MediaWiki\Content\FallbackContentHandler; |
47 | use MediaWiki\Content\JavaScriptContentHandler; |
48 | use MediaWiki\Content\JsonContentHandler; |
49 | use MediaWiki\Content\TextContentHandler; |
50 | use MediaWiki\Content\WikitextContentHandler; |
51 | use MediaWiki\Deferred\SiteStatsUpdate; |
52 | use MediaWiki\Password\Argon2Password; |
53 | use MediaWiki\Password\BcryptPassword; |
54 | use MediaWiki\Password\LayeredParameterizedPassword; |
55 | use MediaWiki\Password\MWOldPassword; |
56 | use MediaWiki\Password\MWSaltedPassword; |
57 | use MediaWiki\Password\PasswordPolicyChecks; |
58 | use MediaWiki\Password\Pbkdf2PasswordUsingOpenSSL; |
59 | use MediaWiki\Permissions\GrantsInfo; |
60 | use MediaWiki\RCFeed\RedisPubSubFeedEngine; |
61 | use MediaWiki\RCFeed\UDPRCFeedEngine; |
62 | use MediaWiki\RenameUser\Job\RenameUserDerivedJob; |
63 | use MediaWiki\RenameUser\Job\RenameUserTableJob; |
64 | use MediaWiki\Request\WebRequest; |
65 | use MediaWiki\Settings\Source\JsonSchemaTrait; |
66 | use MediaWiki\Site\MediaWikiSite; |
67 | use MediaWiki\Storage\SqlBlobStore; |
68 | use MediaWiki\Title\NamespaceInfo; |
69 | use MediaWiki\User\CentralId\LocalIdLookup; |
70 | use MediaWiki\User\Registration\LocalUserRegistrationProvider; |
71 | use MediaWiki\Watchlist\ActivityUpdateJob; |
72 | use MediaWiki\Watchlist\ClearUserWatchlistJob; |
73 | use MediaWiki\Watchlist\ClearWatchlistNotificationsJob; |
74 | use MediaWiki\Watchlist\WatchlistExpiryJob; |
75 | use MergeLogFormatter; |
76 | use MoveLogFormatter; |
77 | use NullJob; |
78 | use ParsoidCachePrewarmJob; |
79 | use PatrolLogFormatter; |
80 | use ProtectLogFormatter; |
81 | use PublishStashedFileJob; |
82 | use RecentChangesUpdateJob; |
83 | use ReflectionClass; |
84 | use RefreshLinksJob; |
85 | use RenameuserLogFormatter; |
86 | use RevertedTagUpdateJob; |
87 | use RightsLogFormatter; |
88 | use SqlBagOStuff; |
89 | use TagLogFormatter; |
90 | use ThumbnailRenderJob; |
91 | use UploadFromUrlJob; |
92 | use UploadLogFormatter; |
93 | use UserEditCountInitJob; |
94 | use UserGroupExpiryJob; |
95 | use UserOptionsUpdateJob; |
96 | use Wikimedia\EventRelayer\EventRelayerNull; |
97 | use Wikimedia\ObjectCache\APCUBagOStuff; |
98 | use Wikimedia\ObjectCache\BagOStuff; |
99 | use Wikimedia\ObjectCache\EmptyBagOStuff; |
100 | use Wikimedia\ObjectCache\HashBagOStuff; |
101 | use Wikimedia\ObjectCache\MemcachedPeclBagOStuff; |
102 | use Wikimedia\ObjectCache\MemcachedPhpBagOStuff; |
103 | |
104 | /** |
105 | * This class contains schema declarations for all configuration variables |
106 | * known to MediaWiki core. The schema definitions follow the JSON Schema |
107 | * specification. |
108 | * |
109 | * @see https://json-schema.org/learn/getting-started-step-by-step.html |
110 | * @see https://json-schema.org/understanding-json-schema/ |
111 | * |
112 | * The following JSON schema keys are used by MediaWiki: |
113 | * - default: the configuration variable's default value. |
114 | * - type: identifies the allowed value type or types. In addition to JSON Schema types, |
115 | * PHPDoc style type definitions are supported for convenience. |
116 | * Note that 'array' must not be used for associative arrays. |
117 | * To avoid confusion, use 'list' for sequential arrays and 'map' for associative arrays |
118 | * with uniform values. The 'object' type should be used for structures that have a known |
119 | * set of meaningful properties, especially if each property may have a different kind |
120 | * of value. |
121 | * See {@link \MediaWiki\Settings\Source\JsonTypeHelper} for details. |
122 | * |
123 | * The following additional keys are used by MediaWiki: |
124 | * - mergeStrategy: see the {@link \MediaWiki\Settings\Config\MergeStrategy}. |
125 | * - dynamicDefault: Specified a callback that computes the effective default at runtime, based |
126 | * on the value of other config variables or on the system environment. |
127 | * See {@link \MediaWiki\Settings\Source\ReflectionSchemaSource} |
128 | * and {@link \MediaWiki\Settings\DynamicDefaultValues} for details. |
129 | * |
130 | * @note After changing this file, run maintenance/generateConfigSchema.php to update |
131 | * all the files derived from the information in MainConfigSchema. |
132 | * |
133 | * @since 1.39 |
134 | */ |
135 | class MainConfigSchema { |
136 | use JsonSchemaTrait; |
137 | |
138 | /** |
139 | * Returns a generator for iterating over all config settings and their default values. |
140 | * The primary use of this method is to import default values into local scope. |
141 | * @code |
142 | * foreach ( MainConfigSchema::listDefaultValues( 'wg' ) as $var => $value ) { |
143 | * $$var = $value; |
144 | * } |
145 | * @endcode |
146 | * |
147 | * There should be no reason for application logic to do this. |
148 | * |
149 | * @note This method is relatively slow, it should not be used by |
150 | * performance critical code. Application logic should generally |
151 | * use ConfigSchema instead |
152 | * |
153 | * @param string $prefix A prefix to prepend to each setting name. |
154 | * Typically, this will be "wg" when constructing global |
155 | * variable names. |
156 | * |
157 | * @return Generator<string,mixed> $settingName => $defaultValue |
158 | */ |
159 | public static function listDefaultValues( string $prefix = '' ): Generator { |
160 | $class = new ReflectionClass( self::class ); |
161 | foreach ( $class->getReflectionConstants() as $const ) { |
162 | if ( !$const->isPublic() ) { |
163 | continue; |
164 | } |
165 | |
166 | $value = $const->getValue(); |
167 | |
168 | if ( !is_array( $value ) ) { |
169 | // Just in case we end up having some other kind of constant on this class. |
170 | continue; |
171 | } |
172 | |
173 | if ( isset( $value['obsolete'] ) ) { |
174 | continue; |
175 | } |
176 | |
177 | $name = $const->getName(); |
178 | yield "$prefix$name" => self::getDefaultFromJsonSchema( $value ); |
179 | } |
180 | } |
181 | |
182 | /** |
183 | * Returns the default value of the given config setting. |
184 | * |
185 | * @note This method is relatively slow, it should not be used by |
186 | * performance critical code. Application logic should generally |
187 | * use ConfigSchema instead |
188 | * |
189 | * @param string $name The config setting name. |
190 | * |
191 | * @return mixed The given config setting's default value, or null |
192 | * if no default value is specified in the schema. |
193 | */ |
194 | public static function getDefaultValue( string $name ) { |
195 | $class = new ReflectionClass( self::class ); |
196 | if ( !$class->hasConstant( $name ) ) { |
197 | throw new InvalidArgumentException( "Unknown setting: $name" ); |
198 | } |
199 | $value = $class->getConstant( $name ); |
200 | |
201 | if ( !is_array( $value ) ) { |
202 | // Might happen if we end up having other kinds of constants on this class. |
203 | throw new InvalidArgumentException( "Unknown setting: $name" ); |
204 | } |
205 | |
206 | return self::getDefaultFromJsonSchema( $value ); |
207 | } |
208 | |
209 | /***************************************************************************/ |
210 | /** |
211 | * Registry of factory functions to create config objects: |
212 | * The 'main' key must be set, and the value should be a valid |
213 | * callable. |
214 | * |
215 | * @since 1.23 |
216 | */ |
217 | public const ConfigRegistry = [ |
218 | 'default' => [ |
219 | 'main' => 'GlobalVarConfig::newInstance', |
220 | ], |
221 | 'type' => 'map', |
222 | ]; |
223 | |
224 | /** |
225 | * Name of the site. It must be changed in LocalSettings.php |
226 | */ |
227 | public const Sitename = [ |
228 | 'default' => 'MediaWiki', |
229 | ]; |
230 | |
231 | /***************************************************************************/ |
232 | // region Server URLs and file paths |
233 | /** @name Server URLs and file paths |
234 | * |
235 | * In this section, a "path" is usually a host-relative URL, i.e. a URL without |
236 | * the host part, that starts with a slash. In most cases a full URL is also |
237 | * acceptable. A "directory" is a local file path. |
238 | * |
239 | * In both paths and directories, trailing slashes should not be included. |
240 | */ |
241 | |
242 | /** |
243 | * URL of the server. |
244 | * |
245 | * **Example:** |
246 | * ``` |
247 | * $wgServer = 'http://example.com'; |
248 | * ``` |
249 | * |
250 | * This must be set in LocalSettings.php. The MediaWiki installer does this |
251 | * automatically since 1.18. |
252 | * |
253 | * If you want to use protocol-relative URLs on your wiki, set this to a |
254 | * protocol-relative URL like '//example.com' and set $wgCanonicalServer |
255 | * to a fully qualified URL. |
256 | */ |
257 | public const Server = [ |
258 | 'default' => false, |
259 | ]; |
260 | |
261 | /** |
262 | * Canonical URL of the server, to use in IRC feeds and notification e-mails. |
263 | * |
264 | * Must be fully qualified, even if $wgServer is protocol-relative. |
265 | * |
266 | * Defaults to $wgServer, expanded to a fully qualified http:// URL if needed. |
267 | * |
268 | * @since 1.18 |
269 | */ |
270 | public const CanonicalServer = [ |
271 | 'default' => false, |
272 | ]; |
273 | |
274 | /** |
275 | * Server name. This is automatically computed by parsing the bare |
276 | * hostname out of $wgCanonicalServer. It should not be customized. |
277 | * |
278 | * @since 1.24 |
279 | */ |
280 | public const ServerName = [ |
281 | 'default' => false, |
282 | ]; |
283 | |
284 | /** |
285 | * When the wiki is running behind a proxy and this is set to true, assumes that the proxy |
286 | * exposes the wiki on the standard ports (443 for https and 80 for http). |
287 | * |
288 | * @since 1.26 |
289 | */ |
290 | public const AssumeProxiesUseDefaultProtocolPorts = [ |
291 | 'default' => true, |
292 | 'type' => 'boolean', |
293 | ]; |
294 | |
295 | /** |
296 | * For installations where the canonical server is HTTP but HTTPS is optionally |
297 | * supported, you can specify a non-standard HTTPS port here. $wgServer should |
298 | * be a protocol-relative URL. |
299 | * |
300 | * If HTTPS is always used, just specify the port number in $wgServer. |
301 | * |
302 | * @see https://phabricator.wikimedia.org/T67184 |
303 | * @since 1.24 |
304 | */ |
305 | public const HttpsPort = [ |
306 | 'default' => 443, |
307 | ]; |
308 | |
309 | /** |
310 | * If this is true, when an insecure HTTP request is received, always redirect |
311 | * to HTTPS. This overrides and disables the preferhttps user preference, and it |
312 | * overrides $wgSecureLogin. |
313 | * |
314 | * $wgServer may be either https or protocol-relative. If $wgServer starts with |
315 | * "http://", an exception will be thrown. |
316 | * |
317 | * If a reverse proxy or CDN is used to forward requests from HTTPS to HTTP, |
318 | * the request header "X-Forwarded-Proto: https" should be sent to suppress |
319 | * the redirect. |
320 | * |
321 | * In addition to setting this to true, for optimal security, the web server |
322 | * should also be configured to send Strict-Transport-Security response headers. |
323 | * |
324 | * @since 1.35 |
325 | */ |
326 | public const ForceHTTPS = [ |
327 | 'default' => false, |
328 | 'type' => 'boolean', |
329 | ]; |
330 | |
331 | /** |
332 | * The path we should point to. |
333 | * |
334 | * It might be a virtual path in case with use apache mod_rewrite for example. |
335 | * |
336 | * This *needs* to be set correctly. |
337 | * |
338 | * Other paths will be set to defaults based on it unless they are directly |
339 | * set in LocalSettings.php |
340 | */ |
341 | public const ScriptPath = [ |
342 | 'default' => '/wiki', |
343 | ]; |
344 | |
345 | /** |
346 | * Whether to support URLs like index.php/Page_title. |
347 | * The effective default value is determined at runtime: |
348 | * it will be enabled in environments where it is expected to be safe. |
349 | * |
350 | * Override this to false if $_SERVER['PATH_INFO'] contains unexpectedly |
351 | * incorrect garbage, or to true if it is really correct. |
352 | * |
353 | * The default $wgArticlePath will be set based on this value at runtime, but if |
354 | * you have customized it, having this incorrectly set to true can cause |
355 | * redirect loops when "pretty URLs" are used. |
356 | * |
357 | * @since 1.2.1 |
358 | */ |
359 | public const UsePathInfo = [ |
360 | 'dynamicDefault' => true, |
361 | ]; |
362 | |
363 | public static function getDefaultUsePathInfo(): bool { |
364 | // These often break when PHP is set up in CGI mode. |
365 | // PATH_INFO *may* be correct if cgi.fix_pathinfo is set, but then again it may not; |
366 | // lighttpd converts incoming path data to lowercase on systems |
367 | // with case-insensitive filesystems, and there have been reports of |
368 | // problems on Apache as well. |
369 | return !str_contains( PHP_SAPI, 'cgi' ) && !str_contains( PHP_SAPI, 'apache2filter' ) && |
370 | !str_contains( PHP_SAPI, 'isapi' ); |
371 | } |
372 | |
373 | /** |
374 | * The URL path to index.php. |
375 | * |
376 | * Defaults to "{$wgScriptPath}/index.php". |
377 | */ |
378 | public const Script = [ |
379 | 'default' => false, |
380 | 'dynamicDefault' => [ 'use' => [ 'ScriptPath' ] ] |
381 | ]; |
382 | |
383 | /** |
384 | * @param mixed $scriptPath Value of ScriptPath |
385 | * @return string |
386 | */ |
387 | public static function getDefaultScript( $scriptPath ): string { |
388 | return "$scriptPath/index.php"; |
389 | } |
390 | |
391 | /** |
392 | * The URL path to load.php. |
393 | * |
394 | * Defaults to "{$wgScriptPath}/load.php". |
395 | * |
396 | * @since 1.17 |
397 | */ |
398 | public const LoadScript = [ |
399 | 'default' => false, |
400 | 'dynamicDefault' => [ 'use' => [ 'ScriptPath' ] ] |
401 | ]; |
402 | |
403 | /** |
404 | * @param mixed $scriptPath Value of ScriptPath |
405 | * @return string |
406 | */ |
407 | public static function getDefaultLoadScript( $scriptPath ): string { |
408 | return "$scriptPath/load.php"; |
409 | } |
410 | |
411 | /** |
412 | * The URL path to the REST API. |
413 | * Defaults to "{$wgScriptPath}/rest.php" |
414 | * |
415 | * @since 1.34 |
416 | */ |
417 | public const RestPath = [ |
418 | 'default' => false, |
419 | 'dynamicDefault' => [ 'use' => [ 'ScriptPath' ] ] |
420 | ]; |
421 | |
422 | /** |
423 | * @param mixed $scriptPath Value of ScriptPath |
424 | * @return string |
425 | */ |
426 | public static function getDefaultRestPath( $scriptPath ): string { |
427 | return "$scriptPath/rest.php"; |
428 | } |
429 | |
430 | /** |
431 | * The URL path of the skins directory. |
432 | * |
433 | * Defaults to "{$wgResourceBasePath}/skins". |
434 | * |
435 | * @since 1.3 |
436 | */ |
437 | public const StylePath = [ |
438 | 'default' => false, |
439 | 'dynamicDefault' => [ 'use' => [ 'ResourceBasePath' ] ] |
440 | ]; |
441 | |
442 | /** |
443 | * @param mixed $resourceBasePath Value of ResourceBasePath |
444 | * @return string |
445 | */ |
446 | public static function getDefaultStylePath( $resourceBasePath ): string { |
447 | return "$resourceBasePath/skins"; |
448 | } |
449 | |
450 | /** |
451 | * The URL path of the skins directory. Should not point to an external domain. |
452 | * |
453 | * Defaults to "{$wgScriptPath}/skins". |
454 | * |
455 | * @since 1.17 |
456 | */ |
457 | public const LocalStylePath = [ |
458 | 'default' => false, |
459 | 'dynamicDefault' => [ 'use' => [ 'ScriptPath' ] ] |
460 | ]; |
461 | |
462 | /** |
463 | * @param mixed $scriptPath Value of ScriptPath |
464 | * @return string |
465 | */ |
466 | public static function getDefaultLocalStylePath( $scriptPath ): string { |
467 | // Avoid ResourceBasePath here since that may point to a different domain (e.g. CDN) |
468 | return "$scriptPath/skins"; |
469 | } |
470 | |
471 | /** |
472 | * The URL path of the extensions directory. |
473 | * |
474 | * Defaults to "{$wgResourceBasePath}/extensions". |
475 | * |
476 | * @since 1.16 |
477 | */ |
478 | public const ExtensionAssetsPath = [ |
479 | 'default' => false, |
480 | 'dynamicDefault' => [ 'use' => [ 'ResourceBasePath' ] ] |
481 | ]; |
482 | |
483 | /** |
484 | * @param mixed $resourceBasePath Value of ResourceBasePath |
485 | * @return string |
486 | */ |
487 | public static function getDefaultExtensionAssetsPath( $resourceBasePath ): string { |
488 | return "$resourceBasePath/extensions"; |
489 | } |
490 | |
491 | /** |
492 | * Extensions directory in the file system. |
493 | * |
494 | * Defaults to "{$IP}/extensions" in Setup.php |
495 | * |
496 | * @note This configuration variable is used to locate extensions while loading settings. |
497 | * @since 1.25 |
498 | */ |
499 | public const ExtensionDirectory = [ |
500 | 'default' => null, |
501 | 'type' => '?string', |
502 | ]; |
503 | |
504 | /** |
505 | * Skins directory in the file system. |
506 | * |
507 | * Defaults to "{$IP}/skins" in Setup.php. |
508 | * |
509 | * @note This configuration variable is used to locate skins while loading settings. |
510 | * @since 1.3 |
511 | */ |
512 | public const StyleDirectory = [ |
513 | 'default' => null, |
514 | 'type' => '?string', |
515 | ]; |
516 | |
517 | /** |
518 | * The URL path for primary article page views. This path should contain $1, |
519 | * which is replaced by the article title. |
520 | * |
521 | * Defaults to "{$wgScript}/$1" or "{$wgScript}?title=$1", |
522 | * depending on $wgUsePathInfo. |
523 | */ |
524 | public const ArticlePath = [ |
525 | 'default' => false, |
526 | 'dynamicDefault' => [ 'use' => [ 'Script', 'UsePathInfo' ] ] |
527 | ]; |
528 | |
529 | /** |
530 | * @param string $script Value of Script |
531 | * @param mixed $usePathInfo Value of UsePathInfo |
532 | * @return string |
533 | */ |
534 | public static function getDefaultArticlePath( string $script, $usePathInfo ): string { |
535 | if ( $usePathInfo ) { |
536 | return "$script/$1"; |
537 | } |
538 | return "$script?title=$1"; |
539 | } |
540 | |
541 | /** |
542 | * The URL path for the images directory. |
543 | * |
544 | * Defaults to "{$wgScriptPath}/images". |
545 | */ |
546 | public const UploadPath = [ |
547 | 'default' => false, |
548 | 'dynamicDefault' => [ 'use' => [ 'ScriptPath' ] ] |
549 | ]; |
550 | |
551 | /** |
552 | * @param mixed $scriptPath Value of ScriptPath |
553 | * @return string |
554 | */ |
555 | public static function getDefaultUploadPath( $scriptPath ): string { |
556 | return "$scriptPath/images"; |
557 | } |
558 | |
559 | /** |
560 | * The base path for img_auth.php. This is used to interpret the request URL |
561 | * for requests to img_auth.php that do not match the base upload path. If |
562 | * false, "{$wgScriptPath}/img_auth.php" is used. |
563 | * |
564 | * Normally, requests to img_auth.php have a REQUEST_URI which matches |
565 | * $wgUploadPath, and in that case, setting this should not be necessary. |
566 | * This variable is used in case img_auth.php is accessed via a different path |
567 | * than $wgUploadPath. |
568 | * |
569 | * @since 1.35 |
570 | */ |
571 | public const ImgAuthPath = [ |
572 | 'default' => false, |
573 | ]; |
574 | |
575 | /** |
576 | * The base path for thumb_handler.php. This is used to interpret the request URL |
577 | * for requests to thumb_handler.php that do not match the base upload path. |
578 | * |
579 | * @since 1.36 |
580 | */ |
581 | public const ThumbPath = [ |
582 | 'default' => false, |
583 | ]; |
584 | |
585 | /** |
586 | * The filesystem path of the images directory. |
587 | * |
588 | * Defaults to "{$IP}/images" in Setup.php. |
589 | */ |
590 | public const UploadDirectory = [ |
591 | 'default' => false, |
592 | 'type' => '?string|false', |
593 | ]; |
594 | |
595 | /** |
596 | * Directory where the cached page will be saved. |
597 | * |
598 | * Defaults to "{$wgUploadDirectory}/cache". |
599 | */ |
600 | public const FileCacheDirectory = [ |
601 | 'default' => false, |
602 | 'dynamicDefault' => [ 'use' => [ 'UploadDirectory' ] ] |
603 | ]; |
604 | |
605 | /** |
606 | * @param mixed $uploadDirectory Value of UploadDirectory |
607 | * @return string |
608 | */ |
609 | public static function getDefaultFileCacheDirectory( $uploadDirectory ): string { |
610 | return "$uploadDirectory/cache"; |
611 | } |
612 | |
613 | /** |
614 | * The URL path of the wiki logo. The logo size should be 135x135 pixels. |
615 | * |
616 | * Defaults to "$wgResourceBasePath/resources/assets/change-your-logo.svg". |
617 | * Developers should retrieve this logo (and other variants) using |
618 | * the static function MediaWiki\ResourceLoader\SkinModule::getAvailableLogos |
619 | * Ignored if $wgLogos is set. |
620 | */ |
621 | public const Logo = [ |
622 | 'default' => false, |
623 | 'dynamicDefault' => [ 'use' => [ 'ResourceBasePath' ] ] |
624 | ]; |
625 | |
626 | /** |
627 | * @param mixed $resourceBasePath Value of ResourceBasePath |
628 | * @return string |
629 | */ |
630 | public static function getDefaultLogo( $resourceBasePath ): string { |
631 | return "$resourceBasePath/resources/assets/change-your-logo.svg"; |
632 | } |
633 | |
634 | /** |
635 | * Specification for different versions of the wiki logo. |
636 | * |
637 | * This is an array which should have the following k/v pairs: |
638 | * All path values can be either absolute or relative URIs |
639 | * |
640 | * The `1x` key is a path to the 1x version of square logo (should be 135x135 pixels) |
641 | * The `1.5x` key is a path to the 1.5x version of square logo |
642 | * The `2x` key is a path to the 2x version of square logo |
643 | * The `svg` key is a path to the svg version of square logo |
644 | * The `icon` key is a path to the version of the logo without wordmark and tagline |
645 | * The `wordmark` key may be null or an array with the following fields |
646 | * - `src` path to wordmark version |
647 | * - `1x` path to svg wordmark version (if you want to |
648 | * support browsers with SVG support with an SVG logo) |
649 | * - `width` width of the logo in pixels |
650 | * - `height` height of the logo in pixels |
651 | * The `tagline` key may be null or array with the following fields |
652 | * - `src` path to tagline image |
653 | * - `width` width of the tagline in pixels |
654 | * - `height` height of the tagline in pixels |
655 | * |
656 | * |
657 | * @par Example: |
658 | * @code |
659 | * $wgLogos = [ |
660 | * '1x' => 'path/to/1x_version.png', |
661 | * '1.5x' => 'path/to/1.5x_version.png', |
662 | * '2x' => 'path/to/2x_version.png', |
663 | * 'svg' => 'path/to/svg_version.svg', |
664 | * 'icon' => 'path/to/icon.png', |
665 | * 'wordmark' => [ |
666 | * 'src' => 'path/to/wordmark_version.png', |
667 | * '1x' => 'path/to/wordmark_version.svg', |
668 | * 'width' => 135, |
669 | * 'height' => 20, |
670 | * ], |
671 | * 'tagline' => [ |
672 | * 'src' => 'path/to/tagline_version.png', |
673 | * 'width' => 135, |
674 | * 'height' => 15, |
675 | * ] |
676 | * ]; |
677 | * @endcode |
678 | * |
679 | * Defaults to [ "1x" => $wgLogo ], |
680 | * or [ "1x" => "$wgResourceBasePath/resources/assets/change-your-logo.svg" ] if $wgLogo is not set. |
681 | * @since 1.35 |
682 | */ |
683 | public const Logos = [ |
684 | 'default' => false, |
685 | 'type' => 'map|false', |
686 | ]; |
687 | |
688 | /** |
689 | * The URL path of the icon. |
690 | * |
691 | * @since 1.6 |
692 | */ |
693 | public const Favicon = [ |
694 | 'default' => '/favicon.ico', |
695 | ]; |
696 | |
697 | /** |
698 | * The URL path of the icon for iPhone and iPod Touch web app bookmarks. |
699 | * |
700 | * Defaults to no icon. |
701 | * |
702 | * @since 1.12 |
703 | */ |
704 | public const AppleTouchIcon = [ |
705 | 'default' => false, |
706 | ]; |
707 | |
708 | /** |
709 | * Value for the referrer policy meta tag. |
710 | * |
711 | * One or more of the values defined in the Referrer Policy specification: |
712 | * https://w3c.github.io/webappsec-referrer-policy/ |
713 | * ('no-referrer', 'no-referrer-when-downgrade', 'same-origin', |
714 | * 'origin', 'strict-origin', 'origin-when-cross-origin', |
715 | * 'strict-origin-when-cross-origin', or 'unsafe-url') |
716 | * Setting it to false prevents the meta tag from being output |
717 | * (which results in falling back to the Referrer-Policy header, |
718 | * or 'no-referrer-when-downgrade' if that's not set either.) |
719 | * Setting it to an array (supported since 1.31) will create a meta tag for |
720 | * each value, in the reverse of the order (meaning that the first array element |
721 | * will be the default and the others used as fallbacks for browsers which do not |
722 | * understand it). |
723 | * |
724 | * @since 1.25 |
725 | */ |
726 | public const ReferrerPolicy = [ |
727 | 'default' => false, |
728 | 'type' => 'list|string|false', |
729 | ]; |
730 | |
731 | /** |
732 | * The local filesystem path to a temporary directory. This must not be web-accessible. |
733 | * |
734 | * When this setting is set to false, its value will automatically be decided |
735 | * through the first call to wfTempDir(). See that method's implementation for |
736 | * the actual detection logic. |
737 | * |
738 | * To find the temporary path for the current wiki, developers must not use |
739 | * this variable directly. Use the global function wfTempDir() instead. |
740 | * |
741 | * The temporary directory is expected to be shared with other applications, |
742 | * including other MediaWiki instances (which might not run the same version |
743 | * or configuration). When storing files here, take care to avoid conflicts |
744 | * with other instances of MediaWiki. For example, when caching the result |
745 | * of a computation, the file name should incorporate the input of the |
746 | * computation so that it cannot be confused for the result of a similar |
747 | * computation by another MediaWiki instance. |
748 | * |
749 | * @see \wfTempDir() |
750 | * @note Default changed to false in MediaWiki 1.20. |
751 | */ |
752 | public const TmpDirectory = [ |
753 | 'default' => false, |
754 | ]; |
755 | |
756 | /** |
757 | * If set, this URL is added to the start of $wgUploadPath to form a complete |
758 | * upload URL. |
759 | * |
760 | * @since 1.4 |
761 | */ |
762 | public const UploadBaseUrl = [ |
763 | 'default' => '', |
764 | ]; |
765 | |
766 | /** |
767 | * To enable remote on-demand scaling, set this to the thumbnail base URL. |
768 | * |
769 | * Full thumbnail URL will be like $wgUploadStashScalerBaseUrl/e/e6/Foo.jpg/123px-Foo.jpg |
770 | * where 'e6' are the first two characters of the MD5 hash of the file name. |
771 | * |
772 | * @deprecated since 1.36 Use thumbProxyUrl in $wgLocalFileRepo |
773 | * |
774 | * If $wgUploadStashScalerBaseUrl and thumbProxyUrl are both false, thumbs are |
775 | * rendered locally as needed. |
776 | * @since 1.17 |
777 | */ |
778 | public const UploadStashScalerBaseUrl = [ |
779 | 'default' => false, |
780 | 'deprecated' => 'since 1.36 Use thumbProxyUrl in $wgLocalFileRepo', |
781 | ]; |
782 | |
783 | /** |
784 | * To set 'pretty' URL paths for actions other than |
785 | * plain page views, add to this array. |
786 | * |
787 | * **Example:** |
788 | * Set pretty URL for the edit action: |
789 | * |
790 | * ``` |
791 | * 'edit' => "$wgScriptPath/edit/$1" |
792 | * ``` |
793 | * There must be an appropriate script or rewrite rule in place to handle these URLs. |
794 | * |
795 | * @since 1.5 |
796 | */ |
797 | public const ActionPaths = [ |
798 | 'default' => [], |
799 | 'type' => 'map', |
800 | ]; |
801 | |
802 | /** |
803 | * When enabled, the domain root will show the wiki's main page, |
804 | * instead of redirecting to the main page. |
805 | * |
806 | * @since 1.34 |
807 | */ |
808 | public const MainPageIsDomainRoot = [ |
809 | 'default' => false, |
810 | 'type' => 'boolean', |
811 | ]; |
812 | |
813 | // endregion -- end of server URLs and file paths |
814 | |
815 | /***************************************************************************/ |
816 | // region Files and file uploads |
817 | /** @name Files and file uploads */ |
818 | |
819 | /** |
820 | * Allow users to upload files. |
821 | * |
822 | * Use $wgLocalFileRepo to control how and where uploads are stored. |
823 | * Disabled by default as for security reasons. |
824 | * See <https://www.mediawiki.org/wiki/Manual:Configuring_file_uploads>. |
825 | * |
826 | * @since 1.5 |
827 | */ |
828 | public const EnableUploads = [ |
829 | 'default' => false, |
830 | ]; |
831 | |
832 | /** |
833 | * The maximum age of temporary (incomplete) uploaded files |
834 | */ |
835 | public const UploadStashMaxAge = [ |
836 | 'default' => 6 * 3600, // 6 hours |
837 | ]; |
838 | |
839 | /** |
840 | * Enable deferred upload tasks that use the job queue. |
841 | * |
842 | * Only enable this if job runners are set up for both the |
843 | * 'AssembleUploadChunks','PublishStashedFile' and 'UploadFromUrl' job types. |
844 | */ |
845 | public const EnableAsyncUploads = [ |
846 | 'default' => false, |
847 | ]; |
848 | |
849 | /** |
850 | * Enable the async processing of upload by url in Special:Upload. |
851 | * |
852 | * Only works if EnableAsyncUploads is also enabled |
853 | */ |
854 | public const EnableAsyncUploadsByURL = [ |
855 | 'default' => false, |
856 | ]; |
857 | |
858 | /** |
859 | * To disable file delete/restore temporarily |
860 | */ |
861 | public const UploadMaintenance = [ |
862 | 'default' => false, |
863 | ]; |
864 | |
865 | /** |
866 | * Additional characters that are not allowed in filenames. They are replaced with '-' when |
867 | * uploading. Like $wgLegalTitleChars, this is a regexp character class. |
868 | * |
869 | * Slashes and backslashes are disallowed regardless of this setting, but included here for |
870 | * completeness. |
871 | * |
872 | * @deprecated since 1.41; no longer customizable |
873 | */ |
874 | public const IllegalFileChars = [ |
875 | 'default' => ':\\/\\\\', |
876 | 'deprecated' => 'since 1.41; no longer customizable', |
877 | ]; |
878 | |
879 | /** |
880 | * What directory to place deleted uploads in. |
881 | * |
882 | * Defaults to "{$wgUploadDirectory}/deleted". |
883 | */ |
884 | public const DeletedDirectory = [ |
885 | 'default' => false, |
886 | 'dynamicDefault' => [ 'use' => [ 'UploadDirectory' ] ] |
887 | ]; |
888 | |
889 | /** |
890 | * @param mixed $uploadDirectory Value of UploadDirectory |
891 | * @return string |
892 | */ |
893 | public static function getDefaultDeletedDirectory( $uploadDirectory ): string { |
894 | return "$uploadDirectory/deleted"; |
895 | } |
896 | |
897 | /** |
898 | * Set this to true if you use img_auth and want the user to see details on why access failed. |
899 | */ |
900 | public const ImgAuthDetails = [ |
901 | 'default' => false, |
902 | ]; |
903 | |
904 | /** |
905 | * Map of relative URL directories to match to internal mwstore:// base storage paths. |
906 | * |
907 | * For img_auth.php requests, everything after "img_auth.php/" is checked to see |
908 | * if starts with any of the prefixes defined here. The prefixes should not overlap. |
909 | * The prefix that matches has a corresponding storage path, which the rest of the URL |
910 | * is assumed to be relative to. The file at that path (or a 404) is send to the client. |
911 | * |
912 | * Example: |
913 | * $wgImgAuthUrlPathMap['/timeline/'] = 'mwstore://local-fs/timeline-render/'; |
914 | * The above maps ".../img_auth.php/timeline/X" to "mwstore://local-fs/timeline-render/". |
915 | * The name "local-fs" should correspond by name to an entry in $wgFileBackends. |
916 | * |
917 | * @see self::FileBackends |
918 | */ |
919 | public const ImgAuthUrlPathMap = [ |
920 | 'default' => [], |
921 | 'type' => 'map', |
922 | ]; |
923 | |
924 | /** |
925 | * File repository structures |
926 | * |
927 | * $wgLocalFileRepo is a single repository structure, and $wgForeignFileRepos is |
928 | * an array of such structures. Each repository structure is an associative |
929 | * array of properties configuring the repository. |
930 | * |
931 | * Properties required for all repos: |
932 | * - class The class name for the repository. May come from the core or an extension. |
933 | * The core repository classes are FileRepo, LocalRepo, ForeignDBRepo. |
934 | * |
935 | * - name A unique name for the repository (but $wgLocalFileRepo should be 'local'). |
936 | * The name should consist of alpha-numeric characters. |
937 | * |
938 | * Optional common properties: |
939 | * - backend A file backend name (see $wgFileBackends). If not specified, or |
940 | * if the name is not present in $wgFileBackends, an FSFileBackend |
941 | * will automatically be configured. |
942 | * - lockManager If a file backend is automatically configured, this will be lock |
943 | * manager name used. A lock manager named in $wgLockManagers, or one of |
944 | * the default lock managers "fsLockManager" or "nullLockManager". Default |
945 | * "fsLockManager". |
946 | * - favicon URL to a favicon. This is exposed via FileRepo::getInfo and |
947 | * ApiQueryFileRepoInfo. Originally for use by MediaViewer (T77093). |
948 | * |
949 | * For most core repos: |
950 | * - zones Associative array of zone names that each map to an array with: |
951 | * container : backend container name the zone is in |
952 | * directory : root path within container for the zone |
953 | * url : base URL to the root of the zone |
954 | * urlsByExt : map of file extension types to base URLs |
955 | * (useful for using a different cache for videos) |
956 | * Zones default to using "<repo name>-<zone name>" as the container name |
957 | * and default to using the container root as the zone's root directory. |
958 | * Nesting of zone locations within other zones should be avoided. |
959 | * - url Public zone URL. The 'zones' settings take precedence. |
960 | * - hashLevels The number of directory levels for hash-based division of files. |
961 | * |
962 | * Set this to 0 if you do not want MediaWiki to divide your images |
963 | * directory into many subdirectories. |
964 | * |
965 | * It is recommended to leave this enabled. In previous versions of |
966 | * MediaWiki, some users set this to false to allow images to be added to |
967 | * the wiki by copying them into $wgUploadDirectory and then running |
968 | * maintenance/rebuildImages.php to register them in the database. |
969 | * This is no longer supported, use maintenance/importImages.php instead. |
970 | * |
971 | * Default: 2. |
972 | * - deletedHashLevels |
973 | * Optional 'hashLevels' override for the 'deleted' zone. |
974 | * - thumbScriptUrl The URL for thumb.php (optional, not recommended) |
975 | * - transformVia404 Whether to skip media file transformation on parse and rely on a 404 |
976 | * handler instead. |
977 | * - thumbProxyUrl Optional. URL of where to proxy thumb.php requests to. This is |
978 | * also used internally for remote thumbnailing of upload stash files. |
979 | * Example: http://127.0.0.1:8888/wiki/dev/thumb/ |
980 | * - thumbProxySecret Optional value of the X-Swift-Secret header to use in requests to |
981 | * thumbProxyUrl |
982 | * - disableLocalTransform |
983 | * If present and true, local image scaling will be disabled. If attempted, |
984 | * it will show an error to the user and log an error message. To avoid an |
985 | * error, thumbProxyUrl must be set, as well as either transformVia404 |
986 | * (preferred) or thumbScriptUrl. |
987 | * - initialCapital Equivalent to $wgCapitalLinks (or $wgCapitalLinkOverrides[NS_FILE], |
988 | * determines whether filenames implicitly start with a capital letter. |
989 | * The current implementation may give incorrect description page links |
990 | * when the local $wgCapitalLinks and initialCapital are mismatched. |
991 | * - pathDisclosureProtection |
992 | * May be 'paranoid' to remove all parameters from error messages, 'none' to |
993 | * leave the paths in unchanged, or 'simple' to replace paths with |
994 | * placeholders. Default for LocalRepo is 'simple'. |
995 | * - fileMode This allows wikis to set the file mode when uploading/moving files. Default |
996 | * is 0644. |
997 | * - directory The local filesystem directory where public files are stored. Not used for |
998 | * some remote repos. |
999 | * - thumbDir The base thumbnail directory. Defaults to "<directory>/thumb". |
1000 | * - thumbUrl The base thumbnail URL. Defaults to "<url>/thumb". |
1001 | * - isPrivate Set this if measures should always be taken to keep the files private. |
1002 | * One should not trust this to assure that the files are not web readable; |
1003 | * the server configuration should be done manually depending on the backend. |
1004 | * - useJsonMetadata Whether handler metadata should be stored in JSON format. Default: true. |
1005 | * - useSplitMetadata Whether handler metadata should be split up and stored in the text table. |
1006 | * Default: false. |
1007 | * - splitMetadataThreshold |
1008 | * If the media handler opts in, large metadata items will be split into a |
1009 | * separate blob in the database if the item is larger than this threshold. |
1010 | * Default: 1000 |
1011 | * - updateCompatibleMetadata |
1012 | * When true, image metadata will be upgraded by reloading it from the original |
1013 | * file, if the handler indicates that it is out of date. |
1014 | * |
1015 | * By default, when purging a file or otherwise refreshing file metadata, it |
1016 | * is only reloaded when the metadata is invalid. Valid data originally loaded |
1017 | * by a current or older compatible version is left unchanged. Enable this |
1018 | * to also reload and upgrade metadata that was stored by an older compatible |
1019 | * version. See also MediaHandler::isMetadataValid, and RefreshImageMetadata. |
1020 | * |
1021 | * Default: false. |
1022 | * |
1023 | * - reserializeMetadata |
1024 | * If true, image metadata will be automatically rewritten to the database |
1025 | * if its serialization format is out of date. Default: false |
1026 | * |
1027 | * These settings describe a foreign MediaWiki installation. They are optional, and will be ignored |
1028 | * for local repositories: |
1029 | * - descBaseUrl URL of image description pages, e.g. https://en.wikipedia.org/wiki/File: |
1030 | * - scriptDirUrl URL of the MediaWiki installation, equivalent to $wgScriptPath, e.g. |
1031 | * https://en.wikipedia.org/w |
1032 | * - articleUrl Equivalent to $wgArticlePath, e.g. https://en.wikipedia.org/wiki/$1 |
1033 | * - fetchDescription Fetch the text of the remote file description page and display them |
1034 | * on the local wiki. |
1035 | * - abbrvThreshold File names over this size will use the short form of thumbnail names. |
1036 | * Short thumbnail names only have the width, parameters, and the extension. |
1037 | * |
1038 | * ForeignDBRepo: |
1039 | * - dbType, dbServer, dbUser, dbPassword, dbName, dbFlags |
1040 | * equivalent to the corresponding member of $wgDBservers |
1041 | * - tablePrefix Table prefix, the foreign wiki's $wgDBprefix |
1042 | * - hasSharedCache Set to true if the foreign wiki's $wgMainCacheType is identical to, |
1043 | * and accessible from, this wiki. |
1044 | * |
1045 | * ForeignAPIRepo: |
1046 | * - apibase Use for the foreign API's URL |
1047 | * - apiThumbCacheExpiry How long to locally cache thumbs for |
1048 | * |
1049 | * If you leave $wgLocalFileRepo set to false, Setup will fill in appropriate values. |
1050 | * Otherwise, set $wgLocalFileRepo to a repository structure as described above. |
1051 | * If you set $wgUseInstantCommons to true, it will add an entry for Commons. |
1052 | * If you set $wgForeignFileRepos to an array of repository structures, those will |
1053 | * be searched after the local file repo. |
1054 | * Otherwise, you will only have access to local media files. |
1055 | * |
1056 | * @see \FileRepo::__construct for the default options. |
1057 | * @see Setup.php for an example usage and default initialization. |
1058 | */ |
1059 | public const LocalFileRepo = [ |
1060 | 'default' => false, |
1061 | 'type' => 'map|false', |
1062 | 'dynamicDefault' => [ 'use' => [ 'UploadDirectory', 'ScriptPath', 'Favicon', 'UploadBaseUrl', |
1063 | 'UploadPath', 'HashedUploadDirectory', 'ThumbnailScriptPath', |
1064 | 'GenerateThumbnailOnParse', 'DeletedDirectory', 'UpdateCompatibleMetadata' ] ], |
1065 | ]; |
1066 | |
1067 | public static function getDefaultLocalFileRepo( |
1068 | $uploadDirectory, $scriptPath, $favicon, $uploadBaseUrl, $uploadPath, |
1069 | $hashedUploadDirectory, $thumbnailScriptPath, $generateThumbnailOnParse, $deletedDirectory, |
1070 | $updateCompatibleMetadata |
1071 | ) { |
1072 | return [ |
1073 | 'class' => LocalRepo::class, |
1074 | 'name' => 'local', |
1075 | 'directory' => $uploadDirectory, |
1076 | 'scriptDirUrl' => $scriptPath, |
1077 | 'favicon' => $favicon, |
1078 | 'url' => $uploadBaseUrl ? $uploadBaseUrl . $uploadPath : $uploadPath, |
1079 | 'hashLevels' => $hashedUploadDirectory ? 2 : 0, |
1080 | 'thumbScriptUrl' => $thumbnailScriptPath, |
1081 | 'transformVia404' => !$generateThumbnailOnParse, |
1082 | 'deletedDir' => $deletedDirectory, |
1083 | 'deletedHashLevels' => $hashedUploadDirectory ? 3 : 0, |
1084 | 'updateCompatibleMetadata' => $updateCompatibleMetadata, |
1085 | 'reserializeMetadata' => $updateCompatibleMetadata, |
1086 | ]; |
1087 | } |
1088 | |
1089 | /** |
1090 | * Enable the use of files from one or more other wikis. |
1091 | * |
1092 | * If you operate multiple wikis, you can declare a shared upload path here. |
1093 | * Uploads to the local wiki will NOT be stored here - See $wgLocalFileRepo |
1094 | * and $wgUploadDirectory for that. |
1095 | * |
1096 | * The wiki will only consider the foreign repository if no file of the given name |
1097 | * is found in the local repository (e.g. via `[[File:..]]` syntax). |
1098 | * |
1099 | * @since 1.11 |
1100 | * @see self::LocalFileRepo |
1101 | */ |
1102 | public const ForeignFileRepos = [ |
1103 | 'default' => [], |
1104 | 'type' => 'list', |
1105 | ]; |
1106 | |
1107 | /** |
1108 | * Use Wikimedia Commons as a foreign file repository. |
1109 | * |
1110 | * This is a shortcut for adding an entry to $wgForeignFileRepos |
1111 | * for https://commons.wikimedia.org, using ForeignAPIRepo with the |
1112 | * default settings. |
1113 | * |
1114 | * @since 1.16 |
1115 | */ |
1116 | public const UseInstantCommons = [ |
1117 | 'default' => false, |
1118 | ]; |
1119 | |
1120 | /** |
1121 | * Shortcut for adding an entry to $wgForeignFileRepos. |
1122 | * |
1123 | * Uses the following variables: |
1124 | * |
1125 | * - directory: $wgSharedUploadDirectory. |
1126 | * - url: $wgSharedUploadPath. |
1127 | * - hashLevels: Based on $wgHashedSharedUploadDirectory. |
1128 | * - thumbScriptUrl: $wgSharedThumbnailScriptPath. |
1129 | * - transformVia404: Based on $wgGenerateThumbnailOnParse. |
1130 | * - descBaseUrl: $wgRepositoryBaseUrl. |
1131 | * - fetchDescription: $wgFetchCommonsDescriptions. |
1132 | * |
1133 | * If $wgSharedUploadDBname is set, it uses the ForeignDBRepo |
1134 | * class, with also the following variables: |
1135 | * |
1136 | * - dbName: $wgSharedUploadDBname. |
1137 | * - dbType: $wgDBtype. |
1138 | * - dbServer: $wgDBserver. |
1139 | * - dbUser: $wgDBuser. |
1140 | * - dbPassword: $wgDBpassword. |
1141 | * - dbFlags: Based on $wgDebugDumpSql. |
1142 | * - tablePrefix: $wgSharedUploadDBprefix, |
1143 | * - hasSharedCache: $wgCacheSharedUploads. |
1144 | * |
1145 | * @since 1.3 |
1146 | */ |
1147 | public const UseSharedUploads = [ |
1148 | 'default' => false, |
1149 | 'type' => 'boolean', |
1150 | ]; |
1151 | |
1152 | /** |
1153 | * Shortcut for the 'directory' setting of $wgForeignFileRepos. |
1154 | * |
1155 | * Only used if $wgUseSharedUploads is enabled. |
1156 | * |
1157 | * @since 1.3 |
1158 | */ |
1159 | public const SharedUploadDirectory = [ |
1160 | 'default' => null, |
1161 | 'type' => '?string', |
1162 | ]; |
1163 | |
1164 | /** |
1165 | * Shortcut for the 'url' setting of $wgForeignFileRepos. |
1166 | * |
1167 | * Only used if $wgUseSharedUploads is enabled. |
1168 | * |
1169 | * @since 1.3 |
1170 | */ |
1171 | public const SharedUploadPath = [ |
1172 | 'default' => null, |
1173 | 'type' => '?string', |
1174 | ]; |
1175 | |
1176 | /** |
1177 | * Shortcut for the 'hashLevels' setting of $wgForeignFileRepos. |
1178 | * |
1179 | * Only used if $wgUseSharedUploads is enabled. |
1180 | * |
1181 | * @since 1.3 |
1182 | */ |
1183 | public const HashedSharedUploadDirectory = [ |
1184 | 'default' => true, |
1185 | 'type' => 'boolean', |
1186 | ]; |
1187 | |
1188 | /** |
1189 | * Shortcut for the 'descBaseUrl' setting of $wgForeignFileRepos. |
1190 | * |
1191 | * Only used if $wgUseSharedUploads is enabled. |
1192 | * |
1193 | * @since 1.5 |
1194 | */ |
1195 | public const RepositoryBaseUrl = [ |
1196 | 'default' => 'https://commons.wikimedia.org/wiki/File:', |
1197 | ]; |
1198 | |
1199 | /** |
1200 | * Shortcut for the 'fetchDescription' setting of $wgForeignFileRepos. |
1201 | * |
1202 | * Only used if $wgUseSharedUploads is enabled. |
1203 | * |
1204 | * @since 1.5 |
1205 | */ |
1206 | public const FetchCommonsDescriptions = [ |
1207 | 'default' => false, |
1208 | 'type' => 'boolean', |
1209 | ]; |
1210 | |
1211 | /** |
1212 | * Shortcut for the ForeignDBRepo 'dbName' setting in $wgForeignFileRepos. |
1213 | * |
1214 | * Set this to false if the uploads do not come from a wiki. |
1215 | * Only used if $wgUseSharedUploads is enabled. |
1216 | * |
1217 | * @since 1.4 |
1218 | */ |
1219 | public const SharedUploadDBname = [ |
1220 | 'default' => false, |
1221 | 'type' => 'false|string', |
1222 | ]; |
1223 | |
1224 | /** |
1225 | * Shortcut for the ForeignDBRepo 'tablePrefix' setting in $wgForeignFileRepos. |
1226 | * |
1227 | * Only used if $wgUseSharedUploads is enabled. |
1228 | * |
1229 | * @since 1.5 |
1230 | */ |
1231 | public const SharedUploadDBprefix = [ |
1232 | 'default' => '', |
1233 | 'type' => 'string', |
1234 | ]; |
1235 | |
1236 | /** |
1237 | * Shortcut for the ForeignDBRepo 'hasSharedCache' setting in $wgForeignFileRepos. |
1238 | * |
1239 | * Only used if $wgUseSharedUploads is enabled. |
1240 | * |
1241 | * @since 1.5 |
1242 | */ |
1243 | public const CacheSharedUploads = [ |
1244 | 'default' => true, |
1245 | 'type' => 'boolean', |
1246 | ]; |
1247 | |
1248 | /** |
1249 | * Array of foreign file repo names (set in $wgForeignFileRepos above) that |
1250 | * are allowable upload targets. These wikis must have some method of |
1251 | * authentication (i.e. CentralAuth), and be CORS-enabled for this wiki. |
1252 | * |
1253 | * The string 'local' signifies the default local file repository. |
1254 | * |
1255 | * Example: |
1256 | * $wgForeignUploadTargets = [ 'shared' ]; |
1257 | */ |
1258 | public const ForeignUploadTargets = [ |
1259 | 'default' => [ 'local', ], |
1260 | 'type' => 'list', |
1261 | ]; |
1262 | |
1263 | /** |
1264 | * Configuration for file uploads using the embeddable upload dialog |
1265 | * (https://www.mediawiki.org/wiki/Upload_dialog). |
1266 | * |
1267 | * This applies also to foreign uploads to this wiki (the configuration is loaded by remote |
1268 | * wikis using the action=query&meta=siteinfo API). |
1269 | * |
1270 | * See below for documentation of each property. None of the properties may be omitted. |
1271 | */ |
1272 | public const UploadDialog = [ |
1273 | 'default' => |
1274 | [ |
1275 | 'fields' => |
1276 | [ |
1277 | 'description' => true, |
1278 | 'date' => false, |
1279 | 'categories' => false, |
1280 | ], |
1281 | 'licensemessages' => |
1282 | [ |
1283 | 'local' => 'generic-local', |
1284 | 'foreign' => 'generic-foreign', |
1285 | ], |
1286 | 'comment' => |
1287 | [ |
1288 | 'local' => '', |
1289 | 'foreign' => '', |
1290 | ], |
1291 | 'format' => |
1292 | [ |
1293 | 'filepage' => '$DESCRIPTION', |
1294 | 'description' => '$TEXT', |
1295 | 'ownwork' => '', |
1296 | 'license' => '', |
1297 | 'uncategorized' => '', |
1298 | ], |
1299 | ], |
1300 | 'type' => 'map', |
1301 | ]; |
1302 | |
1303 | /** |
1304 | * File backend structure configuration. |
1305 | * |
1306 | * This is an array of file backend configuration arrays. |
1307 | * Each backend configuration has the following parameters: |
1308 | * - name : A unique name for the backend |
1309 | * - class : The file backend class to use |
1310 | * - wikiId : A unique string that identifies the wiki (container prefix) |
1311 | * - lockManager : The name of a lock manager (see $wgLockManagers) [optional] |
1312 | * |
1313 | * See FileBackend::__construct() for more details. |
1314 | * Additional parameters are specific to the file backend class used. |
1315 | * These settings should be global to all wikis when possible. |
1316 | * |
1317 | * FileBackendMultiWrite::__construct() is augmented with a 'template' option that |
1318 | * can be used in any of the values of the 'backends' array. Its value is the name of |
1319 | * another backend in $wgFileBackends. When set, it pre-fills the array with all of the |
1320 | * configuration of the named backend. Explicitly set values in the array take precedence. |
1321 | * |
1322 | * There are two particularly important aspects about each backend: |
1323 | * - a) Whether it is fully qualified or wiki-relative. |
1324 | * By default, the paths of files are relative to the current wiki, |
1325 | * which works via prefixing them with the current wiki ID when accessed. |
1326 | * Setting 'domainId' forces the backend to be fully qualified by prefixing |
1327 | * all paths with the specified value instead. This can be useful if |
1328 | * multiple wikis need to share the same data. Note that 'name' is *not* |
1329 | * part of any prefix and thus should not be relied upon for namespacing. |
1330 | * - b) Whether it is only defined for some wikis or is defined on all |
1331 | * wikis in the wiki farm. Defining a backend globally is useful |
1332 | * if multiple wikis need to share the same data. |
1333 | * One should be aware of these aspects when configuring a backend for use with |
1334 | * any basic feature or plugin. For example, suppose an extension stores data for |
1335 | * different wikis in different directories and sometimes needs to access data from |
1336 | * a foreign wiki's directory in order to render a page on given wiki. The extension |
1337 | * would need a fully qualified backend that is defined on all wikis in the wiki farm. |
1338 | */ |
1339 | public const FileBackends = [ |
1340 | 'default' => [], |
1341 | 'type' => 'map', |
1342 | ]; |
1343 | |
1344 | /** |
1345 | * List of lock manager backend configurations. |
1346 | * |
1347 | * Each backend configuration has the following parameters: |
1348 | * - name : A unique name for the lock manager |
1349 | * - class : The lock manager class to use |
1350 | * |
1351 | * See LockManager::__construct() for more details. |
1352 | * Additional parameters are specific to the lock manager class used. |
1353 | * These settings should be global to all wikis. |
1354 | */ |
1355 | public const LockManagers = [ |
1356 | 'default' => [], |
1357 | 'type' => 'list', |
1358 | ]; |
1359 | |
1360 | /** |
1361 | * Whether to show Exif data. |
1362 | * The effective default value is determined at runtime: |
1363 | * enabled if PHP's EXIF extension module is loaded. |
1364 | * |
1365 | * Requires PHP's Exif extension: https://www.php.net/manual/en/ref.exif.php |
1366 | * |
1367 | * @note FOR WINDOWS USERS: |
1368 | * To enable Exif functions, add the following line to the "Windows |
1369 | * extensions" section of php.ini: |
1370 | * |
1371 | * ```{.ini} |
1372 | * extension=extensions/php_exif.dll |
1373 | * ``` |
1374 | */ |
1375 | public const ShowEXIF = [ |
1376 | 'dynamicDefault' => [ 'callback' => [ self::class, 'getDefaultShowEXIF' ] ], |
1377 | ]; |
1378 | |
1379 | public static function getDefaultShowEXIF(): bool { |
1380 | return function_exists( 'exif_read_data' ); |
1381 | } |
1382 | |
1383 | /** |
1384 | * Shortcut for the 'updateCompatibleMetadata' setting of $wgLocalFileRepo. |
1385 | */ |
1386 | public const UpdateCompatibleMetadata = [ |
1387 | 'default' => false, |
1388 | ]; |
1389 | |
1390 | /** |
1391 | * Allow for upload to be copied from an URL. |
1392 | * |
1393 | * The timeout for copy uploads is set by $wgCopyUploadTimeout. |
1394 | * You have to assign the user right 'upload_by_url' to a user group, to use this. |
1395 | */ |
1396 | public const AllowCopyUploads = [ |
1397 | 'default' => false, |
1398 | ]; |
1399 | |
1400 | /** |
1401 | * A list of domains copy uploads can come from |
1402 | * |
1403 | * @since 1.20 |
1404 | */ |
1405 | public const CopyUploadsDomains = [ |
1406 | 'default' => [], |
1407 | 'type' => 'list', |
1408 | ]; |
1409 | |
1410 | /** |
1411 | * Enable copy uploads from Special:Upload. $wgAllowCopyUploads must also be |
1412 | * true. If $wgAllowCopyUploads is true, but this is false, you will only be |
1413 | * able to perform copy uploads from the API or extensions (e.g. UploadWizard). |
1414 | */ |
1415 | public const CopyUploadsFromSpecialUpload = [ |
1416 | 'default' => false, |
1417 | ]; |
1418 | |
1419 | /** |
1420 | * Proxy to use for copy upload requests. |
1421 | * |
1422 | * @since 1.20 |
1423 | */ |
1424 | public const CopyUploadProxy = [ |
1425 | 'default' => false, |
1426 | ]; |
1427 | |
1428 | /** |
1429 | * Different timeout for upload by url |
1430 | * This could be useful since when fetching large files, you may want a |
1431 | * timeout longer than the default $wgHTTPTimeout. False means fallback |
1432 | * to default. |
1433 | * |
1434 | * @since 1.22 |
1435 | */ |
1436 | public const CopyUploadTimeout = [ |
1437 | 'default' => false, |
1438 | 'type' => 'false|integer', |
1439 | ]; |
1440 | |
1441 | /** |
1442 | * If true, the value of $wgCopyUploadsDomains will be merged with the |
1443 | * contents of MediaWiki:Copyupload-allowed-domains. |
1444 | * |
1445 | * @since 1.39 |
1446 | */ |
1447 | public const CopyUploadAllowOnWikiDomainConfig = [ |
1448 | 'default' => false, |
1449 | ]; |
1450 | |
1451 | /** |
1452 | * Max size for uploads, in bytes. |
1453 | * |
1454 | * If not set to an array, applies to all uploads. If set to an array, per upload |
1455 | * type maximums can be set, using the file and url keys. If the `*` key is set |
1456 | * this value will be used as maximum for non-specified types. |
1457 | * |
1458 | * The below example would set the maximum for all uploads to 250 KiB except, |
1459 | * for upload-by-url, which would have a maximum of 500 KiB. |
1460 | * |
1461 | * **Example:** |
1462 | * |
1463 | * ``` |
1464 | * $wgMaxUploadSize = [ |
1465 | * '*' => 250 * 1024, |
1466 | * 'url' => 500 * 1024, |
1467 | * ]; |
1468 | * ``` |
1469 | * Default: 100 MiB. |
1470 | */ |
1471 | public const MaxUploadSize = [ |
1472 | 'default' => 1024 * 1024 * 100, |
1473 | ]; |
1474 | |
1475 | /** |
1476 | * Minimum upload chunk size, in bytes. |
1477 | * |
1478 | * When using chunked upload, non-final chunks smaller than this will be rejected. |
1479 | * |
1480 | * Note that this may be further reduced by the `upload_max_filesize` and |
1481 | * `post_max_size` PHP settings. Use ApiUpload::getMinUploadChunkSize to |
1482 | * get the effective minimum chunk size used by MediaWiki. |
1483 | * |
1484 | * Default: 1 KiB. |
1485 | * |
1486 | * @since 1.26 |
1487 | * @see \ApiUpload::getMinUploadChunkSize |
1488 | */ |
1489 | public const MinUploadChunkSize = [ |
1490 | 'default' => 1024, |
1491 | ]; |
1492 | |
1493 | /** |
1494 | * Point the upload navigation link to an external URL |
1495 | * Useful if you want to use a shared repository by default |
1496 | * without disabling local uploads (use $wgEnableUploads = false for that). |
1497 | * |
1498 | * **Example:** |
1499 | * |
1500 | * ``` |
1501 | * $wgUploadNavigationUrl = 'https://commons.wikimedia.org/wiki/Special:Upload'; |
1502 | * ``` |
1503 | */ |
1504 | public const UploadNavigationUrl = [ |
1505 | 'default' => false, |
1506 | ]; |
1507 | |
1508 | /** |
1509 | * Point the upload link for missing files to an external URL, as with |
1510 | * $wgUploadNavigationUrl. The URL will get "(?|&)wpDestFile=<filename>" |
1511 | * appended to it as appropriate. |
1512 | */ |
1513 | public const UploadMissingFileUrl = [ |
1514 | 'default' => false, |
1515 | ]; |
1516 | |
1517 | /** |
1518 | * Give a path here to use thumb.php for thumbnail generation on client |
1519 | * request, instead of generating them on render and outputting a static URL. |
1520 | * |
1521 | * This is necessary if some of your apache servers don't have read/write |
1522 | * access to the thumbnail path. |
1523 | * |
1524 | * **Example:** |
1525 | * |
1526 | * ``` |
1527 | * $wgThumbnailScriptPath = "{$wgScriptPath}/thumb.php"; |
1528 | * ``` |
1529 | */ |
1530 | public const ThumbnailScriptPath = [ |
1531 | 'default' => false, |
1532 | ]; |
1533 | |
1534 | /** |
1535 | * Shortcut for the 'thumbScriptUrl' setting of $wgForeignFileRepos. |
1536 | * |
1537 | * Only used if $wgUseSharedUploads is enabled. |
1538 | * |
1539 | * @since 1.3 |
1540 | */ |
1541 | public const SharedThumbnailScriptPath = [ |
1542 | 'default' => false, |
1543 | 'type' => 'string|false', |
1544 | ]; |
1545 | |
1546 | /** |
1547 | * Shortcut for setting `hashLevels=2` in $wgLocalFileRepo. |
1548 | * |
1549 | * @note Only used if $wgLocalFileRepo is not set. |
1550 | */ |
1551 | public const HashedUploadDirectory = [ |
1552 | 'default' => true, |
1553 | 'type' => 'boolean', |
1554 | ]; |
1555 | |
1556 | /** |
1557 | * This is the list of preferred extensions for uploading files. Uploading files |
1558 | * with extensions not in this list will trigger a warning. |
1559 | * |
1560 | * @warning If you add any OpenOffice or Microsoft Office file formats here, |
1561 | * such as odt or doc, and untrusted users are allowed to upload files, then |
1562 | * your wiki will be vulnerable to cross-site request forgery (CSRF). |
1563 | */ |
1564 | public const FileExtensions = [ |
1565 | 'default' => [ 'png', 'gif', 'jpg', 'jpeg', 'webp', ], |
1566 | 'type' => 'list', |
1567 | ]; |
1568 | |
1569 | /** |
1570 | * Files with these extensions will never be allowed as uploads. |
1571 | * |
1572 | * An array of file extensions to prevent being uploaded. You should |
1573 | * append to this array if you want to prevent additional file extensions. |
1574 | * |
1575 | * @since 1.37; previously $wgFileBlacklist |
1576 | */ |
1577 | public const ProhibitedFileExtensions = [ |
1578 | 'default' => [ |
1579 | # HTML may contain cookie-stealing JavaScript and web bugs |
1580 | 'html', 'htm', 'js', 'jsb', 'mhtml', 'mht', 'xhtml', 'xht', |
1581 | # PHP scripts may execute arbitrary code on the server |
1582 | 'php', 'phtml', 'php3', 'php4', 'php5', 'phps', 'phar', |
1583 | # Other types that may be interpreted by some servers |
1584 | 'shtml', 'jhtml', 'pl', 'py', 'cgi', |
1585 | # May contain harmful executables for Windows victims |
1586 | 'exe', 'scr', 'dll', 'msi', 'vbs', 'bat', 'com', 'pif', 'cmd', 'vxd', 'cpl', |
1587 | # T341565 |
1588 | 'xml', |
1589 | ], |
1590 | 'type' => 'list', |
1591 | ]; |
1592 | |
1593 | /** |
1594 | * Files with these MIME types will never be allowed as uploads |
1595 | * if $wgVerifyMimeType is enabled. |
1596 | * |
1597 | * @since 1.37; previously $wgMimeTypeBlacklist |
1598 | */ |
1599 | public const MimeTypeExclusions = [ |
1600 | 'default' => [ |
1601 | # HTML may contain cookie-stealing JavaScript and web bugs |
1602 | 'text/html', |
1603 | # Similarly with JavaScript itself |
1604 | 'application/javascript', 'text/javascript', 'text/x-javascript', 'application/x-shellscript', |
1605 | # PHP scripts may execute arbitrary code on the server |
1606 | 'application/x-php', 'text/x-php', |
1607 | # Other types that may be interpreted by some servers |
1608 | 'text/x-python', 'text/x-perl', 'text/x-bash', 'text/x-sh', 'text/x-csh', |
1609 | # Client-side hazards on Internet Explorer |
1610 | 'text/scriptlet', 'application/x-msdownload', |
1611 | # Windows metafile, client-side vulnerability on some systems |
1612 | 'application/x-msmetafile', |
1613 | # Files that look like java files |
1614 | 'application/java', |
1615 | # XML files generally - T341565 |
1616 | 'application/xml', 'text/xml', |
1617 | ], |
1618 | 'type' => 'list', |
1619 | ]; |
1620 | |
1621 | /** |
1622 | * This is a flag to determine whether or not to check file extensions on upload. |
1623 | * |
1624 | * @warning Setting this to false is insecure for public wikis. |
1625 | */ |
1626 | public const CheckFileExtensions = [ |
1627 | 'default' => true, |
1628 | ]; |
1629 | |
1630 | /** |
1631 | * If this is turned off, users may override the warning for files not covered |
1632 | * by $wgFileExtensions. |
1633 | * |
1634 | * @warning Setting this to false is insecure for public wikis. |
1635 | */ |
1636 | public const StrictFileExtensions = [ |
1637 | 'default' => true, |
1638 | ]; |
1639 | |
1640 | /** |
1641 | * Setting this to true will disable the upload system's checks for HTML/JavaScript. |
1642 | * |
1643 | * @warning THIS IS VERY DANGEROUS on a publicly editable site, so USE |
1644 | * $wgGroupPermissions TO RESTRICT UPLOADING to only those that you trust |
1645 | */ |
1646 | public const DisableUploadScriptChecks = [ |
1647 | 'default' => false, |
1648 | ]; |
1649 | |
1650 | /** |
1651 | * Warn if uploaded files are larger than this (in bytes), or false to disable |
1652 | */ |
1653 | public const UploadSizeWarning = [ |
1654 | 'default' => false, |
1655 | ]; |
1656 | |
1657 | /** |
1658 | * list of trusted media-types and MIME types. |
1659 | * |
1660 | * Use the MEDIATYPE_xxx constants to represent media types. |
1661 | * This list is used by File::isSafeFile |
1662 | * |
1663 | * Types not listed here will have a warning about unsafe content |
1664 | * displayed on the images description page. It would also be possible |
1665 | * to use this for further restrictions, like disabling direct |
1666 | * [[media:...]] links for non-trusted formats. |
1667 | */ |
1668 | public const TrustedMediaFormats = [ |
1669 | 'default' => [ |
1670 | MEDIATYPE_BITMAP, // all bitmap formats |
1671 | MEDIATYPE_AUDIO, // all audio formats |
1672 | MEDIATYPE_VIDEO, // all plain video formats |
1673 | "image/svg+xml", // svg (only needed if inline rendering of svg is not supported) |
1674 | "application/pdf", // PDF files |
1675 | # "application/x-shockwave-flash", //flash/shockwave movie |
1676 | ], |
1677 | 'type' => 'list', |
1678 | ]; |
1679 | |
1680 | /** |
1681 | * Plugins for media file type handling. |
1682 | * |
1683 | * Each entry in the array maps a MIME type to a class name |
1684 | * |
1685 | * Core media handlers are listed in MediaHandlerFactory, |
1686 | * and extensions should use extension.json. |
1687 | */ |
1688 | public const MediaHandlers = [ |
1689 | 'default' => [], |
1690 | 'type' => 'map', |
1691 | ]; |
1692 | |
1693 | /** |
1694 | * Toggles native image lazy loading, via the "loading" attribute. |
1695 | * |
1696 | * @unstable EXPERIMENTAL |
1697 | * @since 1.34 |
1698 | */ |
1699 | public const NativeImageLazyLoading = [ |
1700 | 'default' => false, |
1701 | 'type' => 'boolean', |
1702 | ]; |
1703 | |
1704 | /** |
1705 | * Media handler overrides for parser tests (they don't need to generate actual |
1706 | * thumbnails, so a mock will do) |
1707 | */ |
1708 | public const ParserTestMediaHandlers = [ |
1709 | 'default' => [ |
1710 | 'image/jpeg' => 'MockBitmapHandler', |
1711 | 'image/png' => 'MockBitmapHandler', |
1712 | 'image/gif' => 'MockBitmapHandler', |
1713 | 'image/tiff' => 'MockBitmapHandler', |
1714 | 'image/webp' => 'MockBitmapHandler', |
1715 | 'image/x-ms-bmp' => 'MockBitmapHandler', |
1716 | 'image/x-bmp' => 'MockBitmapHandler', |
1717 | 'image/x-xcf' => 'MockBitmapHandler', |
1718 | 'image/svg+xml' => 'MockSvgHandler', |
1719 | 'image/vnd.djvu' => 'MockDjVuHandler', |
1720 | ], |
1721 | 'type' => 'map', |
1722 | ]; |
1723 | |
1724 | /** |
1725 | * Whether to enable server-side image thumbnailing. If false, images will |
1726 | * always be sent to the client in full resolution, with appropriate width= and |
1727 | * height= attributes on the <img> tag for the client to do its own scaling. |
1728 | */ |
1729 | public const UseImageResize = [ |
1730 | 'default' => true, |
1731 | ]; |
1732 | |
1733 | /** |
1734 | * Resizing can be done using PHP's internal image libraries or using |
1735 | * ImageMagick or another third-party converter, e.g. GraphicMagick. |
1736 | * |
1737 | * These support more file formats than PHP, which only supports PNG, |
1738 | * GIF, JPG, XBM and WBMP. |
1739 | * |
1740 | * Use Image Magick instead of PHP builtin functions. |
1741 | */ |
1742 | public const UseImageMagick = [ |
1743 | 'default' => false, |
1744 | ]; |
1745 | |
1746 | /** |
1747 | * The convert command shipped with ImageMagick |
1748 | */ |
1749 | public const ImageMagickConvertCommand = [ |
1750 | 'default' => '/usr/bin/convert', |
1751 | ]; |
1752 | |
1753 | /** |
1754 | * Array of max pixel areas for interlacing per MIME type |
1755 | * |
1756 | * @since 1.27 |
1757 | */ |
1758 | public const MaxInterlacingAreas = [ |
1759 | 'default' => [], |
1760 | 'type' => 'map', |
1761 | ]; |
1762 | |
1763 | /** |
1764 | * Sharpening parameter to ImageMagick |
1765 | */ |
1766 | public const SharpenParameter = [ |
1767 | 'default' => '0x0.4', |
1768 | ]; |
1769 | |
1770 | /** |
1771 | * Reduction in linear dimensions below which sharpening will be enabled |
1772 | */ |
1773 | public const SharpenReductionThreshold = [ |
1774 | 'default' => 0.85, |
1775 | ]; |
1776 | |
1777 | /** |
1778 | * Temporary directory used for ImageMagick. The directory must exist. Leave |
1779 | * this set to false to let ImageMagick decide for itself. |
1780 | */ |
1781 | public const ImageMagickTempDir = [ |
1782 | 'default' => false, |
1783 | ]; |
1784 | |
1785 | /** |
1786 | * Use another resizing converter, e.g. GraphicMagick |
1787 | * %s will be replaced with the source path, %d with the destination |
1788 | * %w and %h will be replaced with the width and height. |
1789 | * |
1790 | * **Example for GraphicMagick:** |
1791 | * |
1792 | * ``` |
1793 | * $wgCustomConvertCommand = "gm convert %s -resize %wx%h %d" |
1794 | * ``` |
1795 | * Leave as false to skip this. |
1796 | */ |
1797 | public const CustomConvertCommand = [ |
1798 | 'default' => false, |
1799 | ]; |
1800 | |
1801 | /** |
1802 | * used for lossless jpeg rotation |
1803 | * |
1804 | * @since 1.21 |
1805 | */ |
1806 | public const JpegTran = [ |
1807 | 'default' => '/usr/bin/jpegtran', |
1808 | ]; |
1809 | |
1810 | /** |
1811 | * At default setting of 'yuv420', JPEG thumbnails will use 4:2:0 chroma |
1812 | * subsampling to reduce file size, at the cost of possible color fringing |
1813 | * at sharp edges. |
1814 | * |
1815 | * See https://en.wikipedia.org/wiki/Chroma_subsampling |
1816 | * |
1817 | * Supported values: |
1818 | * false - use scaling system's default (same as pre-1.27 behavior) |
1819 | * 'yuv444' - luma and chroma at same resolution |
1820 | * 'yuv422' - chroma at 1/2 resolution horizontally, full vertically |
1821 | * 'yuv420' - chroma at 1/2 resolution in both dimensions |
1822 | * |
1823 | * This setting is currently supported only for the ImageMagick backend; |
1824 | * others may default to 4:2:0 or 4:4:4 or maintaining the source file's |
1825 | * sampling in the thumbnail. |
1826 | * |
1827 | * @since 1.27 |
1828 | */ |
1829 | public const JpegPixelFormat = [ |
1830 | 'default' => 'yuv420', |
1831 | ]; |
1832 | |
1833 | /** |
1834 | * When scaling a JPEG thumbnail, this is the quality we request |
1835 | * from the backend. It should be an integer between 1 and 100, |
1836 | * with 100 indicating 100% quality. |
1837 | * |
1838 | * @since 1.32 |
1839 | */ |
1840 | public const JpegQuality = [ |
1841 | 'default' => 80, |
1842 | ]; |
1843 | |
1844 | /** |
1845 | * Some tests and extensions use exiv2 to manipulate the Exif metadata in some |
1846 | * image formats. |
1847 | */ |
1848 | public const Exiv2Command = [ |
1849 | 'default' => '/usr/bin/exiv2', |
1850 | ]; |
1851 | |
1852 | /** |
1853 | * Path to exiftool binary. Used for lossless ICC profile swapping. |
1854 | * |
1855 | * @since 1.26 |
1856 | */ |
1857 | public const Exiftool = [ |
1858 | 'default' => '/usr/bin/exiftool', |
1859 | ]; |
1860 | |
1861 | /** |
1862 | * Scalable Vector Graphics (SVG) may be uploaded as images. |
1863 | * |
1864 | * Since SVG support is not yet standard in browsers, it is |
1865 | * necessary to rasterize SVGs to PNG as a fallback format. |
1866 | * |
1867 | * An external program is required to perform this conversion. |
1868 | * If set to an array, the first item is a PHP callable and any further items |
1869 | * are passed as parameters after $srcPath, $dstPath, $width, $height |
1870 | */ |
1871 | public const SVGConverters = [ |
1872 | 'default' => [ |
1873 | 'ImageMagick' => '$path/convert -background "#ffffff00" -thumbnail $widthx$height\\! $input PNG:$output', |
1874 | 'sodipodi' => '$path/sodipodi -z -w $width -f $input -e $output', |
1875 | 'inkscape' => '$path/inkscape -z -w $width -f $input -e $output', |
1876 | 'batik' => 'java -Djava.awt.headless=true -jar $path/batik-rasterizer.jar -w $width -d $output $input', |
1877 | 'rsvg' => '$path/rsvg-convert -w $width -h $height -o $output $input', |
1878 | 'imgserv' => '$path/imgserv-wrapper -i svg -o png -w$width $input $output', |
1879 | 'ImagickExt' => [ 'SvgHandler::rasterizeImagickExt', ], |
1880 | ], |
1881 | 'type' => 'map', |
1882 | ]; |
1883 | |
1884 | /** |
1885 | * Pick a converter defined in $wgSVGConverters |
1886 | */ |
1887 | public const SVGConverter = [ |
1888 | 'default' => 'ImageMagick', |
1889 | ]; |
1890 | |
1891 | /** |
1892 | * If not in the executable PATH, specify the SVG converter path. |
1893 | */ |
1894 | public const SVGConverterPath = [ |
1895 | 'default' => '', |
1896 | ]; |
1897 | |
1898 | /** |
1899 | * Don't scale a SVG larger than this |
1900 | */ |
1901 | public const SVGMaxSize = [ |
1902 | 'default' => 5120, |
1903 | ]; |
1904 | |
1905 | /** |
1906 | * Don't read SVG metadata beyond this point. |
1907 | * |
1908 | * Default is 5 MiB |
1909 | */ |
1910 | public const SVGMetadataCutoff = [ |
1911 | 'default' => 1024 * 1024 * 5, |
1912 | ]; |
1913 | |
1914 | /** |
1915 | * Whether native rendering by the browser agent is allowed |
1916 | * |
1917 | * Default is false. Setting it to true disables all SVG conversion. |
1918 | * Setting to the string 'partial' will only allow native rendering |
1919 | * when the filesize is below SVGNativeRenderingSizeLimit and if the |
1920 | * file contains at most 1 language. |
1921 | * |
1922 | * @since 1.41 |
1923 | */ |
1924 | public const SVGNativeRendering = [ |
1925 | 'default' => false, |
1926 | 'type' => 'string|boolean', |
1927 | ]; |
1928 | |
1929 | /** |
1930 | * Filesize limit for allowing SVGs to render natively by the browser agent |
1931 | * |
1932 | * Default is 50kB. |
1933 | * |
1934 | * @since 1.41 |
1935 | */ |
1936 | public const SVGNativeRenderingSizeLimit = [ |
1937 | 'default' => 50 * 1024, |
1938 | ]; |
1939 | |
1940 | /** |
1941 | * Whether thumbnails should be generated in target language (usually, same as |
1942 | * page language), if available. |
1943 | * |
1944 | * Currently, applies only to SVG images that use the systemLanguage attribute |
1945 | * to specify text language. |
1946 | * |
1947 | * @since 1.33 |
1948 | */ |
1949 | public const MediaInTargetLanguage = [ |
1950 | 'default' => true, |
1951 | ]; |
1952 | |
1953 | /** |
1954 | * The maximum number of pixels a source image can have if it is to be scaled |
1955 | * down by a scaler that requires the full source image to be decompressed |
1956 | * and stored in decompressed form, before the thumbnail is generated. |
1957 | * |
1958 | * This provides a limit on memory usage for the decompression side of the |
1959 | * image scaler. The limit is used when scaling PNGs with any of the |
1960 | * built-in image scalers, such as ImageMagick or GD. It is ignored for |
1961 | * JPEGs with ImageMagick, and when using the VipsScaler extension. |
1962 | * |
1963 | * If set to false, MediaWiki will not check the size of the image before |
1964 | * attempting to scale it. Extensions may still override this setting by |
1965 | * using the BitmapHandlerCheckImageArea hook. |
1966 | * |
1967 | * The default is 50 MB if decompressed to RGBA form, which corresponds to |
1968 | * 12.5 million pixels or 3500x3500. |
1969 | */ |
1970 | public const MaxImageArea = [ |
1971 | 'default' => 12_500_000, |
1972 | 'type' => 'string|integer|false', |
1973 | ]; |
1974 | |
1975 | /** |
1976 | * Force thumbnailing of animated GIFs above this size to a single |
1977 | * frame instead of an animated thumbnail. As of MW 1.17 this limit |
1978 | * is checked against the total size of all frames in the animation. |
1979 | * |
1980 | * |
1981 | * It probably makes sense to keep this equal to $wgMaxImageArea. |
1982 | */ |
1983 | public const MaxAnimatedGifArea = [ |
1984 | 'default' => 12_500_000, |
1985 | ]; |
1986 | |
1987 | /** |
1988 | * Browsers don't support TIFF inline generally... |
1989 | * For inline display, we need to convert to PNG or JPEG. |
1990 | * |
1991 | * Note scaling should work with ImageMagick, but may not with GD scaling. |
1992 | * |
1993 | * **Example:** |
1994 | * |
1995 | * ``` |
1996 | * // PNG is lossless, but inefficient for photos |
1997 | * $wgTiffThumbnailType = [ 'png', 'image/png' ]; |
1998 | * // JPEG is good for photos, but has no transparency support. Bad for diagrams. |
1999 | * $wgTiffThumbnailType = [ 'jpg', 'image/jpeg' ]; |
2000 | * ``` |
2001 | */ |
2002 | public const TiffThumbnailType = [ |
2003 | 'default' => [], |
2004 | 'type' => 'list', |
2005 | 'mergeStrategy' => 'replace', |
2006 | ]; |
2007 | |
2008 | /** |
2009 | * If rendered thumbnail files are older than this timestamp, they |
2010 | * will be rerendered on demand as if the file didn't already exist. |
2011 | * |
2012 | * Update if there is some need to force thumbs and SVG rasterizations |
2013 | * to rerender, such as fixes to rendering bugs. |
2014 | */ |
2015 | public const ThumbnailEpoch = [ |
2016 | 'default' => '20030516000000', |
2017 | ]; |
2018 | |
2019 | /** |
2020 | * Certain operations are avoided if there were too many recent failures, |
2021 | * for example, thumbnail generation. Bump this value to invalidate all |
2022 | * memory of failed operations and thus allow further attempts to resume. |
2023 | * |
2024 | * This is useful when a cause for the failures has been found and fixed. |
2025 | */ |
2026 | public const AttemptFailureEpoch = [ |
2027 | 'default' => 1, |
2028 | ]; |
2029 | |
2030 | /** |
2031 | * If set, inline scaled images will still produce "<img>" tags ready for |
2032 | * output instead of showing an error message. |
2033 | * |
2034 | * This may be useful if errors are transitory, especially if the site |
2035 | * is configured to automatically render thumbnails on request. |
2036 | * |
2037 | * On the other hand, it may obscure error conditions from debugging. |
2038 | * Enable the debug log or the 'thumbnail' log group to make sure errors |
2039 | * are logged to a file for review. |
2040 | */ |
2041 | public const IgnoreImageErrors = [ |
2042 | 'default' => false, |
2043 | ]; |
2044 | |
2045 | /** |
2046 | * Render thumbnails while parsing wikitext. |
2047 | * |
2048 | * If set to false, then the Parser will output valid thumbnail URLs without |
2049 | * generating or storing the thumbnail files. This can significantly speed up |
2050 | * processing on the web server. The site admin needs to configure a 404 handler |
2051 | * in order for the URLs in question to regenerate the thumbnails in question |
2052 | * on-demand. This can enable concurrency and also save computing resources |
2053 | * as not every resolution of every image on every page is accessed between |
2054 | * re-parses of the article. For example, re-parses triggered by bot edits, |
2055 | * or cascading updates from template edits. |
2056 | * |
2057 | * If you use $wgLocalFileRepo, then you will also need to set the following: |
2058 | * |
2059 | * ``` |
2060 | * $wgLocalFileRepo['transformVia404'] = true; |
2061 | * ``` |
2062 | * |
2063 | * @since 1.7.0 |
2064 | */ |
2065 | public const GenerateThumbnailOnParse = [ |
2066 | 'default' => true, |
2067 | 'type' => 'boolean', |
2068 | ]; |
2069 | |
2070 | /** |
2071 | * Show thumbnails for old images on the image description page |
2072 | */ |
2073 | public const ShowArchiveThumbnails = [ |
2074 | 'default' => true, |
2075 | ]; |
2076 | |
2077 | /** |
2078 | * If set to true, images that contain certain the exif orientation tag will |
2079 | * be rotated accordingly. If set to null, try to auto-detect whether a scaler |
2080 | * is available that can rotate. |
2081 | */ |
2082 | public const EnableAutoRotation = [ |
2083 | 'default' => null, |
2084 | 'type' => '?boolean', |
2085 | ]; |
2086 | |
2087 | /** |
2088 | * Internal name of virus scanner. This serves as a key to the |
2089 | * $wgAntivirusSetup array. Set this to NULL to disable virus scanning. If not |
2090 | * null, every file uploaded will be scanned for viruses. |
2091 | */ |
2092 | public const Antivirus = [ |
2093 | 'default' => null, |
2094 | 'type' => '?string', |
2095 | ]; |
2096 | |
2097 | /** |
2098 | * Configuration for different virus scanners. This an associative array of |
2099 | * associative arrays. It contains one setup array per known scanner type. |
2100 | * |
2101 | * The entry is selected by $wgAntivirus, i.e. |
2102 | * valid values for $wgAntivirus are the keys defined in this array. |
2103 | * |
2104 | * The configuration array for each scanner contains the following keys: |
2105 | * "command", "codemap", "messagepattern": |
2106 | * |
2107 | * "command" is the full command to call the virus scanner - %f will be |
2108 | * replaced with the name of the file to scan. If not present, the filename |
2109 | * will be appended to the command. Note that this must be overwritten if the |
2110 | * scanner is not in the system path; in that case, please set |
2111 | * $wgAntivirusSetup[$wgAntivirus]['command'] to the desired command with full |
2112 | * path. |
2113 | * |
2114 | * "codemap" is a mapping of exit code to return codes of the detectVirus |
2115 | * function in SpecialUpload. |
2116 | * - An exit code mapped to AV_SCAN_FAILED causes the function to consider |
2117 | * the scan to be failed. This will pass the file if $wgAntivirusRequired |
2118 | * is not set. |
2119 | * - An exit code mapped to AV_SCAN_ABORTED causes the function to consider |
2120 | * the file to have an unsupported format, which is probably immune to |
2121 | * viruses. This causes the file to pass. |
2122 | * - An exit code mapped to AV_NO_VIRUS will cause the file to pass, meaning |
2123 | * no virus was found. |
2124 | * - All other codes (like AV_VIRUS_FOUND) will cause the function to report |
2125 | * a virus. |
2126 | * - You may use "*" as a key in the array to catch all exit codes not mapped otherwise. |
2127 | * |
2128 | * "messagepattern" is a perl regular expression to extract the meaningful part of the scanners |
2129 | * output. The relevant part should be matched as group one (\1). |
2130 | * If not defined or the pattern does not match, the full message is shown to the user. |
2131 | */ |
2132 | public const AntivirusSetup = [ |
2133 | 'default' => [ |
2134 | # setup for clamav |
2135 | 'clamav' => [ |
2136 | 'command' => 'clamscan --no-summary ', |
2137 | 'codemap' => [ |
2138 | "0" => AV_NO_VIRUS, # no virus |
2139 | "1" => AV_VIRUS_FOUND, # virus found |
2140 | "52" => AV_SCAN_ABORTED, # unsupported file format (probably immune) |
2141 | "*" => AV_SCAN_FAILED, # else scan failed |
2142 | ], |
2143 | 'messagepattern' => '/.*?:(.*)/sim', |
2144 | ], |
2145 | ], |
2146 | 'type' => 'map', |
2147 | ]; |
2148 | |
2149 | /** |
2150 | * Determines if a failed virus scan (AV_SCAN_FAILED) will cause the file to be rejected. |
2151 | */ |
2152 | public const AntivirusRequired = [ |
2153 | 'default' => true, |
2154 | ]; |
2155 | |
2156 | /** |
2157 | * Determines if the MIME type of uploaded files should be checked |
2158 | */ |
2159 | public const VerifyMimeType = [ |
2160 | 'default' => true, |
2161 | ]; |
2162 | |
2163 | /** |
2164 | * Sets the MIME type definition file to use by includes/libs/mime/MimeAnalyzer.php. |
2165 | * |
2166 | * When this is set to the path of a mime.types file, MediaWiki will use this |
2167 | * file to map MIME types to file extensions and vice versa, in lieu of its |
2168 | * internal MIME map. Note that some MIME mappings are considered "baked in" |
2169 | * and cannot be overridden. See includes/libs/mime/MimeMapMinimal.php for a |
2170 | * full list. |
2171 | * example: $wgMimeTypeFile = '/etc/mime.types'; |
2172 | */ |
2173 | public const MimeTypeFile = [ |
2174 | 'default' => 'internal', |
2175 | ]; |
2176 | |
2177 | /** |
2178 | * Sets the MIME type info file to use by includes/libs/mime/MimeAnalyzer.php. |
2179 | * |
2180 | * Set to null to use the minimum set of built-in defaults only. |
2181 | */ |
2182 | public const MimeInfoFile = [ |
2183 | 'default' => 'internal', |
2184 | ]; |
2185 | |
2186 | /** |
2187 | * Sets an external MIME detector program. The command must print only |
2188 | * the MIME type to standard output. |
2189 | * |
2190 | * The name of the file to process will be appended to the command given here. |
2191 | * If not set or NULL, PHP's mime_content_type function will be used. |
2192 | * |
2193 | * **Example:** |
2194 | * |
2195 | * ``` |
2196 | * #$wgMimeDetectorCommand = "file -bi"; // use external MIME detector (Linux) |
2197 | * ``` |
2198 | */ |
2199 | public const MimeDetectorCommand = [ |
2200 | 'default' => null, |
2201 | 'type' => '?string', |
2202 | ]; |
2203 | |
2204 | /** |
2205 | * Switch for trivial MIME detection. Used by thumb.php to disable all fancy |
2206 | * things, because only a few types of images are needed and file extensions |
2207 | * can be trusted. |
2208 | */ |
2209 | public const TrivialMimeDetection = [ |
2210 | 'default' => false, |
2211 | ]; |
2212 | |
2213 | /** |
2214 | * Additional XML types we can allow via MIME-detection. |
2215 | * |
2216 | * array = [ 'rootElement' => 'associatedMimeType' ] |
2217 | */ |
2218 | public const XMLMimeTypes = [ |
2219 | 'default' => [ |
2220 | 'http://www.w3.org/2000/svg:svg' => 'image/svg+xml', |
2221 | 'svg' => 'image/svg+xml', |
2222 | 'http://www.lysator.liu.se/~alla/dia/:diagram' => 'application/x-dia-diagram', |
2223 | 'http://www.w3.org/1999/xhtml:html' => 'text/html', |
2224 | 'html' => 'text/html', |
2225 | ], |
2226 | 'type' => 'map', |
2227 | ]; |
2228 | |
2229 | /** |
2230 | * Limit images on image description pages to a user-selectable limit. |
2231 | * |
2232 | * In order to reduce disk usage, limits can only be selected from this list. |
2233 | * The user preference is saved as an array offset in the database, by default |
2234 | * the offset is set with $wgDefaultUserOptions['imagesize']. Make sure you |
2235 | * change it if you alter the array (see T10858). |
2236 | * |
2237 | * This list is also used by ImagePage for alternate size links. |
2238 | */ |
2239 | public const ImageLimits = [ |
2240 | 'default' => [ |
2241 | [ 320, 240 ], |
2242 | [ 640, 480 ], |
2243 | [ 800, 600 ], |
2244 | [ 1024, 768 ], |
2245 | [ 1280, 1024 ], |
2246 | [ 2560, 2048 ], |
2247 | ], |
2248 | 'type' => 'list', |
2249 | ]; |
2250 | |
2251 | /** |
2252 | * Adjust thumbnails on image pages according to a user setting. In order to |
2253 | * reduce disk usage, the values can only be selected from a list. This is the |
2254 | * list of settings the user can choose from: |
2255 | */ |
2256 | public const ThumbLimits = [ |
2257 | 'default' => [ |
2258 | 120, |
2259 | 150, |
2260 | 180, |
2261 | 200, |
2262 | 250, |
2263 | 300 |
2264 | ], |
2265 | 'type' => 'list', |
2266 | ]; |
2267 | |
2268 | /** |
2269 | * Defines what namespaces thumbnails will be displayed for in Special:Search. |
2270 | * This is the list of namespaces for which thumbnails (or a placeholder in |
2271 | * the absence of a thumbnail) will be shown: |
2272 | */ |
2273 | public const ThumbnailNamespaces = [ |
2274 | 'default' => [ NS_FILE ], |
2275 | 'type' => 'list', |
2276 | 'items' => [ 'type' => 'integer', ], |
2277 | ]; |
2278 | |
2279 | /** |
2280 | * When defined, is an array of image widths used as buckets for thumbnail generation. |
2281 | * |
2282 | * The goal is to save resources by generating thumbnails based on reference buckets instead of |
2283 | * always using the original. This will incur a speed gain but cause a quality loss. |
2284 | * |
2285 | * The buckets generation is chained, with each bucket generated based on the above bucket |
2286 | * when possible. File handlers have to opt into using that feature. For now only BitmapHandler |
2287 | * supports it. |
2288 | */ |
2289 | public const ThumbnailBuckets = [ |
2290 | 'default' => null, |
2291 | 'type' => '?list', |
2292 | ]; |
2293 | |
2294 | /** |
2295 | * When using thumbnail buckets as defined above, this sets the minimum distance to the bucket |
2296 | * above the requested size. The distance represents how many extra pixels of width the bucket |
2297 | * needs in order to be used as the reference for a given thumbnail. For example, with the |
2298 | * following buckets: |
2299 | * |
2300 | * $wgThumbnailBuckets = [ 128, 256, 512 ]; |
2301 | * |
2302 | * and a distance of 50: |
2303 | * |
2304 | * $wgThumbnailMinimumBucketDistance = 50; |
2305 | * |
2306 | * If we want to render a thumbnail of width 220px, the 512px bucket will be used, |
2307 | * because 220 + 50 = 270 and the closest bucket bigger than 270px is 512. |
2308 | */ |
2309 | public const ThumbnailMinimumBucketDistance = [ |
2310 | 'default' => 50, |
2311 | ]; |
2312 | |
2313 | /** |
2314 | * When defined, is an array of thumbnail widths to be rendered at upload time. The idea is to |
2315 | * prerender common thumbnail sizes, in order to avoid the necessity to render them on demand, |
2316 | * which has a performance impact for the first client to view a certain size. |
2317 | * |
2318 | * This obviously means that more disk space is needed per upload upfront. |
2319 | * |
2320 | * @since 1.25 |
2321 | */ |
2322 | public const UploadThumbnailRenderMap = [ |
2323 | 'default' => [], |
2324 | 'type' => 'map', |
2325 | ]; |
2326 | |
2327 | /** |
2328 | * The method through which the thumbnails will be prerendered for the entries in |
2329 | * $wgUploadThumbnailRenderMap |
2330 | * |
2331 | * The method can be either "http" or "jobqueue". The former uses an http request to hit the |
2332 | * thumbnail's URL. |
2333 | * This method only works if thumbnails are configured to be rendered by a 404 handler. The |
2334 | * latter option uses the job queue to render the thumbnail. |
2335 | * |
2336 | * @since 1.25 |
2337 | */ |
2338 | public const UploadThumbnailRenderMethod = [ |
2339 | 'default' => 'jobqueue', |
2340 | ]; |
2341 | |
2342 | /** |
2343 | * When using the "http" $wgUploadThumbnailRenderMethod, lets one specify a custom Host HTTP |
2344 | * header. |
2345 | * |
2346 | * @since 1.25 |
2347 | */ |
2348 | public const UploadThumbnailRenderHttpCustomHost = [ |
2349 | 'default' => false, |
2350 | ]; |
2351 | |
2352 | /** |
2353 | * When using the "http" $wgUploadThumbnailRenderMethod, lets one specify a custom domain to |
2354 | * send the HTTP request to. |
2355 | * |
2356 | * @since 1.25 |
2357 | */ |
2358 | public const UploadThumbnailRenderHttpCustomDomain = [ |
2359 | 'default' => false, |
2360 | ]; |
2361 | |
2362 | /** |
2363 | * When this variable is true and JPGs use the sRGB ICC profile, swaps it for the more |
2364 | * lightweight |
2365 | * (and free) TinyRGB profile when generating thumbnails. |
2366 | * |
2367 | * @since 1.26 |
2368 | */ |
2369 | public const UseTinyRGBForJPGThumbnails = [ |
2370 | 'default' => false, |
2371 | ]; |
2372 | |
2373 | /** |
2374 | * Parameters for the "<gallery>" tag. |
2375 | * |
2376 | * Fields are: |
2377 | * - imagesPerRow: Default number of images per-row in the gallery. 0 -> Adapt to screensize |
2378 | * - imageWidth: Width of the cells containing images in galleries (in "px") |
2379 | * - imageHeight: Height of the cells containing images in galleries (in "px") |
2380 | * - captionLength: Length to truncate filename to in caption when using "showfilename". |
2381 | * A value of 'true' will truncate the filename to one line using CSS |
2382 | * and will be the behaviour after deprecation. |
2383 | * @deprecated since 1.28 |
2384 | * - showBytes: Show the filesize in bytes in categories |
2385 | * - showDimensions: Show the dimensions (width x height) in categories |
2386 | * - mode: Gallery mode |
2387 | */ |
2388 | public const GalleryOptions = [ |
2389 | 'default' => [], |
2390 | 'type' => 'map', |
2391 | ]; |
2392 | |
2393 | /** |
2394 | * Adjust width of upright images when parameter 'upright' is used |
2395 | * This allows a nicer look for upright images without the need to fix the width |
2396 | * by hardcoded px in wiki sourcecode. |
2397 | */ |
2398 | public const ThumbUpright = [ |
2399 | 'default' => 0.75, |
2400 | ]; |
2401 | |
2402 | /** |
2403 | * Default value for chmod-ing of new directories. |
2404 | */ |
2405 | public const DirectoryMode = [ |
2406 | 'default' => 0777, // octal! |
2407 | ]; |
2408 | |
2409 | /** |
2410 | * Generate and use thumbnails suitable for screens with 1.5 and 2.0 pixel densities. |
2411 | * |
2412 | * This means a 320x240 use of an image on the wiki will also generate 480x360 and 640x480 |
2413 | * thumbnails, output via the srcset attribute. |
2414 | */ |
2415 | public const ResponsiveImages = [ |
2416 | 'default' => true, |
2417 | ]; |
2418 | |
2419 | /** |
2420 | * Add a preconnect link for browsers to a remote FileRepo host. |
2421 | * |
2422 | * This is an optional performance enhancement designed for wiki farm where |
2423 | * $wgForeignFileRepos or $wgLocalFileRepo is set to serve thumbnails from a |
2424 | * separate hostname (e.g. not local `/w/images`). The feature expects at most |
2425 | * a single remote hostname to be used. |
2426 | * |
2427 | * If multiple foreign repos are registered that serve images from different hostnames, |
2428 | * only the first will be preconnected. |
2429 | * |
2430 | * This may cause unneeded HTTP connections in browsers on wikis where a foreign repo is |
2431 | * enabled but where a local repo is more commonly used. |
2432 | * |
2433 | * @since 1.35 |
2434 | */ |
2435 | public const ImagePreconnect = [ |
2436 | 'default' => false, |
2437 | ]; |
2438 | |
2439 | /***************************************************************************/ |
2440 | // region DJVU settings |
2441 | /** @name DJVU settings */ |
2442 | |
2443 | /** |
2444 | * Whether to use BoxedCommand or not. |
2445 | * |
2446 | * @unstable Temporary feature flag for T352515 |
2447 | * @since 1.42 |
2448 | */ |
2449 | public const DjvuUseBoxedCommand = [ |
2450 | 'default' => false, |
2451 | ]; |
2452 | |
2453 | /** |
2454 | * Path of the djvudump executable |
2455 | * Enable this and $wgDjvuRenderer to enable djvu rendering |
2456 | * example: $wgDjvuDump = 'djvudump'; |
2457 | * |
2458 | * If this is set, {@link self::ShellboxShell} must be set to the correct |
2459 | * shell path. |
2460 | */ |
2461 | public const DjvuDump = [ |
2462 | 'default' => null, |
2463 | 'type' => '?string', |
2464 | ]; |
2465 | |
2466 | /** |
2467 | * Path of the ddjvu DJVU renderer |
2468 | * Enable this and $wgDjvuDump to enable djvu rendering |
2469 | * example: $wgDjvuRenderer = 'ddjvu'; |
2470 | */ |
2471 | public const DjvuRenderer = [ |
2472 | 'default' => null, |
2473 | 'type' => '?string', |
2474 | ]; |
2475 | |
2476 | /** |
2477 | * Path of the djvutxt DJVU text extraction utility |
2478 | * Enable this and $wgDjvuDump to enable text layer extraction from djvu files |
2479 | * example: $wgDjvuTxt = 'djvutxt'; |
2480 | * |
2481 | * If this is set, {@link self::ShellboxShell} must be set to the correct |
2482 | * shell path. |
2483 | */ |
2484 | public const DjvuTxt = [ |
2485 | 'default' => null, |
2486 | 'type' => '?string', |
2487 | ]; |
2488 | |
2489 | /** |
2490 | * Shell command for the DJVU post processor |
2491 | * Default: pnmtojpeg, since ddjvu generates ppm output |
2492 | * Set this to false to output the ppm file directly. |
2493 | */ |
2494 | public const DjvuPostProcessor = [ |
2495 | 'default' => 'pnmtojpeg', |
2496 | 'type' => '?string', |
2497 | ]; |
2498 | |
2499 | /** |
2500 | * File extension for the DJVU post processor output |
2501 | */ |
2502 | public const DjvuOutputExtension = [ |
2503 | 'default' => 'jpg', |
2504 | ]; |
2505 | |
2506 | // endregion -- end of DJvu |
2507 | |
2508 | // endregion -- end of file uploads |
2509 | |
2510 | /***************************************************************************/ |
2511 | // region Email settings |
2512 | /** @name Email settings */ |
2513 | |
2514 | /** |
2515 | * Site admin email address. |
2516 | * |
2517 | * Defaults to "wikiadmin@$wgServerName" (in Setup.php). |
2518 | */ |
2519 | public const EmergencyContact = [ |
2520 | 'default' => false, |
2521 | ]; |
2522 | |
2523 | /** |
2524 | * Sender email address for e-mail notifications. |
2525 | * |
2526 | * The address we use as sender when a user requests a password reminder, |
2527 | * as well as other e-mail notifications. |
2528 | * |
2529 | * Defaults to "apache@$wgServerName" (in Setup.php). |
2530 | */ |
2531 | public const PasswordSender = [ |
2532 | 'default' => false, |
2533 | ]; |
2534 | |
2535 | /** |
2536 | * Reply-To address for e-mail notifications. |
2537 | * |
2538 | * Defaults to $wgPasswordSender (in Setup.php). |
2539 | */ |
2540 | public const NoReplyAddress = [ |
2541 | 'default' => false, |
2542 | ]; |
2543 | |
2544 | /** |
2545 | * Set to true to enable the e-mail basic features: |
2546 | * Password reminders, etc. If sending e-mail on your |
2547 | * server doesn't work, you might want to disable this. |
2548 | */ |
2549 | public const EnableEmail = [ |
2550 | 'default' => true, |
2551 | ]; |
2552 | |
2553 | /** |
2554 | * Set to true to enable user-to-user e-mail. |
2555 | * |
2556 | * This can potentially be abused, as it's hard to track. |
2557 | */ |
2558 | public const EnableUserEmail = [ |
2559 | 'default' => true, |
2560 | ]; |
2561 | |
2562 | /** |
2563 | * Set to true to enable the Special Mute page. This allows users |
2564 | * to mute unwanted communications from other users, and is linked |
2565 | * to from emails originating from Special:Email. |
2566 | * |
2567 | * @since 1.34 |
2568 | */ |
2569 | public const EnableSpecialMute = [ |
2570 | 'default' => false, |
2571 | ]; |
2572 | |
2573 | /** |
2574 | * Set to true to enable user-to-user e-mail mutelist. |
2575 | * |
2576 | * @since 1.37; previously $wgEnableUserEmailBlacklist |
2577 | */ |
2578 | public const EnableUserEmailMuteList = [ |
2579 | 'default' => false, |
2580 | ]; |
2581 | |
2582 | /** |
2583 | * If true put the sending user's email in a Reply-To header |
2584 | * instead of From (false). ($wgPasswordSender will be used as From.) |
2585 | * |
2586 | * Some mailers (eg SMTP) set the SMTP envelope sender to the From value, |
2587 | * which can cause problems with SPF validation and leak recipient addresses |
2588 | * when bounces are sent to the sender. In addition, DMARC restrictions |
2589 | * can cause emails to fail to be received when false. |
2590 | */ |
2591 | public const UserEmailUseReplyTo = [ |
2592 | 'default' => true, |
2593 | ]; |
2594 | |
2595 | /** |
2596 | * Minimum time, in hours, which must elapse between password reminder |
2597 | * emails for a given account. This is to prevent abuse by mail flooding. |
2598 | */ |
2599 | public const PasswordReminderResendTime = [ |
2600 | 'default' => 24, |
2601 | ]; |
2602 | |
2603 | /** |
2604 | * The time, in seconds, when an emailed temporary password expires. |
2605 | */ |
2606 | public const NewPasswordExpiry = [ |
2607 | 'default' => 3600 * 24 * 7, |
2608 | ]; |
2609 | |
2610 | /** |
2611 | * The time, in seconds, when an email confirmation email expires |
2612 | */ |
2613 | public const UserEmailConfirmationTokenExpiry = [ |
2614 | 'default' => 7 * 24 * 60 * 60, |
2615 | ]; |
2616 | |
2617 | /** |
2618 | * The number of days that a user's password is good for. After this number of days, the |
2619 | * user will be asked to reset their password. Set to false to disable password expiration. |
2620 | */ |
2621 | public const PasswordExpirationDays = [ |
2622 | 'default' => false, |
2623 | ]; |
2624 | |
2625 | /** |
2626 | * If a user's password is expired, the number of seconds when they can still login, |
2627 | * and cancel their password change, but are sent to the password change form on each login. |
2628 | */ |
2629 | public const PasswordExpireGrace = [ |
2630 | 'default' => 3600 * 24 * 7, |
2631 | ]; |
2632 | |
2633 | /** |
2634 | * SMTP Mode. |
2635 | * |
2636 | * For using a direct (authenticated) SMTP server connection. |
2637 | * Default to false or fill an array : |
2638 | * |
2639 | * ``` |
2640 | * $wgSMTP = [ |
2641 | * 'host' => 'SMTP domain', |
2642 | * 'IDHost' => 'domain for MessageID', |
2643 | * 'port' => '25', |
2644 | * 'auth' => [true|false], |
2645 | * 'username' => [SMTP username], |
2646 | * 'password' => [SMTP password], |
2647 | * ]; |
2648 | * ``` |
2649 | */ |
2650 | public const SMTP = [ |
2651 | 'default' => false, |
2652 | 'type' => 'false|map', |
2653 | ]; |
2654 | |
2655 | /** |
2656 | * Additional email parameters, will be passed as the last argument to mail() call. |
2657 | */ |
2658 | public const AdditionalMailParams = [ |
2659 | 'default' => null, |
2660 | ]; |
2661 | |
2662 | /** |
2663 | * For parts of the system that have been updated to provide HTML email content, send |
2664 | * both text and HTML parts as the body of the email |
2665 | */ |
2666 | public const AllowHTMLEmail = [ |
2667 | 'default' => false, |
2668 | ]; |
2669 | |
2670 | /** |
2671 | * Allow sending of e-mail notifications with the editor's address as sender. |
2672 | * |
2673 | * This setting depends on $wgEnotifRevealEditorAddress also being enabled. |
2674 | * If both are enabled, notifications for actions from users that have opted-in, |
2675 | * will be sent to other users with their address as "From" instead of "Reply-To". |
2676 | * |
2677 | * If disabled, or not opted-in, notifications come from $wgPasswordSender. |
2678 | */ |
2679 | public const EnotifFromEditor = [ |
2680 | 'default' => false, |
2681 | 'type' => 'boolean', |
2682 | ]; |
2683 | |
2684 | /** |
2685 | * Require email authentication before sending mail to an email address. |
2686 | * |
2687 | * This is highly recommended. It prevents MediaWiki from being used as an open |
2688 | * spam relay. |
2689 | */ |
2690 | public const EmailAuthentication = [ |
2691 | 'default' => true, |
2692 | ]; |
2693 | |
2694 | /** |
2695 | * Allow users to enable email notification ("enotif") on watchlist changes. |
2696 | */ |
2697 | public const EnotifWatchlist = [ |
2698 | 'default' => false, |
2699 | ]; |
2700 | |
2701 | /** |
2702 | * Allow users to enable email notification ("enotif") when someone edits their |
2703 | * user talk page. |
2704 | * |
2705 | * The owner of the user talk page must also have the 'enotifusertalkpages' user |
2706 | * preference set to true. |
2707 | */ |
2708 | public const EnotifUserTalk = [ |
2709 | 'default' => false, |
2710 | ]; |
2711 | |
2712 | /** |
2713 | * Allow sending of e-mail notifications with the editor's address in "Reply-To". |
2714 | * |
2715 | * Note, enabling this only actually uses it in notification e-mails if the user |
2716 | * opted-in to this feature. This feature flag also controls visibility of the |
2717 | * 'enotifrevealaddr' preference, which, if users opt into, will make e-mail |
2718 | * notifications about their actions use their address as "Reply-To". |
2719 | * |
2720 | * To set the address as "From" instead of "Reply-To", also enable $wgEnotifFromEditor. |
2721 | * |
2722 | * If disabled, or not opted-in, notifications come from $wgPasswordSender. |
2723 | */ |
2724 | public const EnotifRevealEditorAddress = [ |
2725 | 'default' => false, |
2726 | 'type' => 'boolean', |
2727 | ]; |
2728 | |
2729 | /** |
2730 | * Potentially send notification mails on minor edits to pages. This is enabled |
2731 | * by default. If this is false, users will never be notified on minor edits. |
2732 | * |
2733 | * If it is true, editors with the 'nominornewtalk' right (typically bots) will still not |
2734 | * trigger notifications for minor edits they make (to any page, not just user talk). |
2735 | * |
2736 | * Finally, if the watcher/recipient has the 'enotifminoredits' user preference set to |
2737 | * false, they will not receive notifications for minor edits. |
2738 | * |
2739 | * User talk notifications are also affected by $wgEnotifMinorEdits, the above settings, |
2740 | * $wgEnotifUserTalk, and the preference described there. |
2741 | */ |
2742 | public const EnotifMinorEdits = [ |
2743 | 'default' => true, |
2744 | ]; |
2745 | |
2746 | /** |
2747 | * Send a generic mail instead of a personalised mail for each user. This |
2748 | * always uses UTC as the time zone, and doesn't include the username. |
2749 | * |
2750 | * For pages with many users watching, this can significantly reduce mail load. |
2751 | * Has no effect when using sendmail rather than SMTP. |
2752 | */ |
2753 | public const EnotifImpersonal = [ |
2754 | 'default' => false, |
2755 | ]; |
2756 | |
2757 | /** |
2758 | * Maximum number of users to mail at once when using impersonal mail. Should |
2759 | * match the limit on your mail server. |
2760 | */ |
2761 | public const EnotifMaxRecips = [ |
2762 | 'default' => 500, |
2763 | ]; |
2764 | |
2765 | /** |
2766 | * Use real name instead of username in e-mail "from" field. |
2767 | */ |
2768 | public const EnotifUseRealName = [ |
2769 | 'default' => false, |
2770 | ]; |
2771 | |
2772 | /** |
2773 | * Array of usernames who will be sent a notification email for every change |
2774 | * which occurs on a wiki. Users will not be notified of their own changes. |
2775 | */ |
2776 | public const UsersNotifiedOnAllChanges = [ |
2777 | 'default' => [], |
2778 | 'type' => 'map', |
2779 | ]; |
2780 | |
2781 | // endregion -- end of email settings |
2782 | |
2783 | /***************************************************************************/ |
2784 | // region Database settings |
2785 | /** @name Database settings */ |
2786 | |
2787 | /** |
2788 | * Current wiki database name |
2789 | * |
2790 | * This should only contain alphanumeric and underscore characters ([A-Za-z0-9_]+). |
2791 | * Spaces, quotes, backticks, dots, and hyphens are likely to be problematic. |
2792 | * |
2793 | * This is used to determine the current/local wiki ID (WikiMap::getCurrentWikiDbDomain). |
2794 | * |
2795 | * This should still be set even if $wgLBFactoryConf is configured. |
2796 | */ |
2797 | public const DBname = [ |
2798 | 'default' => 'my_wiki', |
2799 | ]; |
2800 | |
2801 | /** |
2802 | * Current wiki database schema name |
2803 | * |
2804 | * This should only contain alphanumeric and underscore characters ([A-Za-z0-9_]+). |
2805 | * Spaces, quotes, backticks, dots, and hyphens are likely to be problematic. |
2806 | * |
2807 | * This is used to determine the current/local wiki ID (WikiMap::getCurrentWikiDbDomain). |
2808 | * |
2809 | * This should still be set even if $wgLBFactoryConf is configured. |
2810 | */ |
2811 | public const DBmwschema = [ |
2812 | 'default' => null, |
2813 | 'type' => '?string', |
2814 | ]; |
2815 | |
2816 | /** |
2817 | * Current wiki database table name prefix |
2818 | * |
2819 | * This should only contain alphanumeric and underscore characters ([A-Za-z0-9_]+). |
2820 | * If it's a non-empty string, then it preferably should end with an underscore. |
2821 | * Spaces, quotes, backticks, dots, and hyphens are especially likely to be problematic. |
2822 | * |
2823 | * This is used to determine the current/local wiki ID (WikiMap::getCurrentWikiDbDomain). |
2824 | * |
2825 | * This should still be set even if $wgLBFactoryConf is configured. |
2826 | */ |
2827 | public const DBprefix = [ |
2828 | 'default' => '', |
2829 | ]; |
2830 | |
2831 | /** |
2832 | * Database host name or IP address |
2833 | */ |
2834 | public const DBserver = [ |
2835 | 'default' => 'localhost', |
2836 | ]; |
2837 | |
2838 | /** |
2839 | * Database port number |
2840 | */ |
2841 | public const DBport = [ |
2842 | 'default' => 5432, |
2843 | ]; |
2844 | |
2845 | /** |
2846 | * Database username |
2847 | */ |
2848 | public const DBuser = [ |
2849 | 'default' => 'wikiuser', |
2850 | ]; |
2851 | |
2852 | /** |
2853 | * Database user's password |
2854 | */ |
2855 | public const DBpassword = [ |
2856 | 'default' => '', |
2857 | ]; |
2858 | |
2859 | /** |
2860 | * Database type |
2861 | */ |
2862 | public const DBtype = [ |
2863 | 'default' => 'mysql', |
2864 | ]; |
2865 | |
2866 | /** |
2867 | * Whether to use SSL in DB connection. |
2868 | * |
2869 | * This setting is only used if $wgLBFactoryConf['class'] is set to |
2870 | * '\Wikimedia\Rdbms\LBFactorySimple' and $wgDBservers is an empty array; otherwise |
2871 | * the 'ssl' parameter of the server array must be set to achieve the same functionality. |
2872 | */ |
2873 | public const DBssl = [ |
2874 | 'default' => false, |
2875 | ]; |
2876 | |
2877 | /** |
2878 | * Whether to use compression in DB connection. |
2879 | * |
2880 | * This setting is only used $wgLBFactoryConf['class'] is set to |
2881 | * '\Wikimedia\Rdbms\LBFactorySimple' and $wgDBservers is an empty array; otherwise |
2882 | * the DBO_COMPRESS flag must be set in the 'flags' option of the database |
2883 | * connection to achieve the same functionality. |
2884 | */ |
2885 | public const DBcompress = [ |
2886 | 'default' => false, |
2887 | ]; |
2888 | |
2889 | /** |
2890 | * Check for warnings after DB queries and throw an exception if an |
2891 | * unacceptable warning is detected. |
2892 | * |
2893 | * This setting is only used if $wgLBFactoryConf['class'] is set to |
2894 | * '\Wikimedia\Rdbms\LBFactorySimple' and $wgDBservers is an empty array. |
2895 | * Otherwise, the 'strictWarnings' parameter of the server array must be set |
2896 | * to achieve the same functionality. |
2897 | * |
2898 | * @since 1.42 |
2899 | */ |
2900 | public const DBStrictWarnings = [ |
2901 | 'default' => false, |
2902 | ]; |
2903 | |
2904 | /** |
2905 | * Separate username for maintenance tasks. Leave as null to use the default. |
2906 | */ |
2907 | public const DBadminuser = [ |
2908 | 'default' => null, |
2909 | ]; |
2910 | |
2911 | /** |
2912 | * Separate password for maintenance tasks. Leave as null to use the default. |
2913 | */ |
2914 | public const DBadminpassword = [ |
2915 | 'default' => null, |
2916 | ]; |
2917 | |
2918 | /** |
2919 | * Search type. |
2920 | * |
2921 | * Leave as null to select the default search engine for the |
2922 | * selected database type (eg SearchMySQL), or set to a class |
2923 | * name to override to a custom search engine. |
2924 | * |
2925 | * If the canonical name for the search engine doesn't match the class name |
2926 | * (because it's namespaced for example), you can add a mapping for this in |
2927 | * SearchMappings in extension.json. |
2928 | */ |
2929 | public const SearchType = [ |
2930 | 'default' => null, |
2931 | ]; |
2932 | |
2933 | /** |
2934 | * Alternative search types |
2935 | * |
2936 | * Sometimes you want to support multiple search engines for testing. This |
2937 | * allows users to select their search engine of choice via url parameters |
2938 | * to Special:Search and the action=search API. If using this, there's no |
2939 | * need to add $wgSearchType to it, that is handled automatically. |
2940 | * |
2941 | * If the canonical name for the search engine doesn't match the class name |
2942 | * (because it's namespaced for example), you can add a mapping for this in |
2943 | * SearchMappings in extension.json. |
2944 | */ |
2945 | public const SearchTypeAlternatives = [ |
2946 | 'default' => null, |
2947 | ]; |
2948 | |
2949 | /** |
2950 | * MySQL table options to use during installation or update |
2951 | */ |
2952 | public const DBTableOptions = [ |
2953 | 'default' => 'ENGINE=InnoDB, DEFAULT CHARSET=binary', |
2954 | ]; |
2955 | |
2956 | /** |
2957 | * SQL Mode - default is turning off all modes, including strict, if set. |
2958 | * |
2959 | * null can be used to skip the setting for performance reasons and assume |
2960 | * DBA has done his best job. |
2961 | * String override can be used for some additional fun :-) |
2962 | */ |
2963 | public const SQLMode = [ |
2964 | 'default' => '', |
2965 | ]; |
2966 | |
2967 | /** |
2968 | * Default group to use when getting database connections. |
2969 | * |
2970 | * Will be used as default query group in ILoadBalancer::getConnection. |
2971 | * |
2972 | * @since 1.32 |
2973 | */ |
2974 | public const DBDefaultGroup = [ |
2975 | 'default' => null, |
2976 | ]; |
2977 | |
2978 | /** |
2979 | * To override default SQLite data directory ($docroot/../data) |
2980 | */ |
2981 | public const SQLiteDataDir = [ |
2982 | 'default' => '', |
2983 | ]; |
2984 | |
2985 | /** |
2986 | * Shared database for multiple wikis. Commonly used for storing a user table |
2987 | * for single sign-on. The server for this database must be the same as for the |
2988 | * main database. |
2989 | * |
2990 | * For backwards compatibility the shared prefix is set to the same as the local |
2991 | * prefix, and the user table is listed in the default list of shared tables. |
2992 | * The user_properties table is also added so that users will continue to have their |
2993 | * preferences shared (preferences were stored in the user table prior to 1.16) |
2994 | * |
2995 | * $wgSharedTables may be customized with a list of tables to share in the shared |
2996 | * database. However it is advised to limit what tables you do share as many of |
2997 | * MediaWiki's tables may have side effects if you try to share them. |
2998 | * |
2999 | * $wgSharedPrefix is the table prefix for the shared database. It defaults to |
3000 | * $wgDBprefix. |
3001 | * |
3002 | * $wgSharedSchema is the table schema for the shared database. It defaults to |
3003 | * $wgDBmwschema. |
3004 | */ |
3005 | public const SharedDB = [ |
3006 | 'default' => null, |
3007 | ]; |
3008 | |
3009 | /** |
3010 | * @see self::SharedDB |
3011 | */ |
3012 | public const SharedPrefix = [ |
3013 | 'default' => false, |
3014 | 'dynamicDefault' => [ 'use' => [ 'DBprefix' ] ] |
3015 | ]; |
3016 | |
3017 | /** |
3018 | * @param mixed $dbPrefix Value of DBprefix |
3019 | * @return mixed |
3020 | */ |
3021 | public static function getDefaultSharedPrefix( $dbPrefix ) { |
3022 | return $dbPrefix; |
3023 | } |
3024 | |
3025 | /** |
3026 | * @see self::SharedDB |
3027 | * The installer will add 'actor' to this list for all new wikis. |
3028 | */ |
3029 | public const SharedTables = [ |
3030 | 'default' => [ |
3031 | 'user', |
3032 | 'user_properties', |
3033 | 'user_autocreate_serial', |
3034 | ], |
3035 | 'type' => 'list', |
3036 | ]; |
3037 | |
3038 | /** |
3039 | * @see self::SharedDB |
3040 | * @since 1.23 |
3041 | */ |
3042 | public const SharedSchema = [ |
3043 | 'default' => false, |
3044 | 'dynamicDefault' => [ 'use' => [ 'DBmwschema' ] ] |
3045 | ]; |
3046 | |
3047 | /** |
3048 | * @param mixed $dbMwschema Value of DBmwschema |
3049 | * @return mixed |
3050 | */ |
3051 | public static function getDefaultSharedSchema( $dbMwschema ) { |
3052 | return $dbMwschema; |
3053 | } |
3054 | |
3055 | /** |
3056 | * Database load balancer |
3057 | * This is a two-dimensional array, a list of server info structures |
3058 | * Fields are: |
3059 | * - host: Host name |
3060 | * - dbname: Default database name |
3061 | * - user: DB user |
3062 | * - password: DB password |
3063 | * - type: DB type |
3064 | * - driver: DB driver (when there are multiple drivers) |
3065 | * |
3066 | * - load: Ratio of DB_REPLICA load, must be >=0, the sum of all loads must be >0. |
3067 | * If this is zero for any given server, no normal query traffic will be |
3068 | * sent to it. It will be excluded from lag checks in maintenance scripts. |
3069 | * The only way it can receive traffic is if groupLoads is used. |
3070 | * |
3071 | * - groupLoads: (optional) Array of load ratios, the key is the query group name. A query |
3072 | * may belong to several groups, the most specific group defined here is used. |
3073 | * |
3074 | * - flags: (optional) Bit field of properties: |
3075 | * - DBO_DEFAULT: Transactional-ize web requests and use autocommit otherwise |
3076 | * - DBO_DEBUG: Equivalent of $wgDebugDumpSql |
3077 | * - DBO_SSL: Use TLS connection encryption if available (deprecated) |
3078 | * - DBO_COMPRESS: Use protocol compression with database connections |
3079 | * - DBO_PERSISTENT: Enables persistent database connections |
3080 | * |
3081 | * - ssl: (optional) Boolean, whether to use TLS encryption. Overrides DBO_SSL. |
3082 | * - max lag: (optional) Maximum replication lag before a replica DB goes out of rotation |
3083 | * - is static: (optional) Set to true if the dataset is static and no replication is used. |
3084 | * - cliMode: (optional) Connection handles will not assume that requests are short-lived |
3085 | * nor that INSERT..SELECT can be rewritten into a buffered SELECT and INSERT. |
3086 | * This is what DBO_DEFAULT uses to determine when a web request is present. |
3087 | * [Default: true if MW_ENTRY_POINT is 'cli', otherwise false] |
3088 | * |
3089 | * These and any other user-defined properties will be assigned to the mLBInfo member |
3090 | * variable of the Database object. |
3091 | * |
3092 | * Leave at false to use the single-server variables above. If you set this |
3093 | * variable, the single-server variables will generally be ignored (except |
3094 | * perhaps in some command-line scripts). |
3095 | * |
3096 | * The first server listed in this array (with key 0) will be the primary. The |
3097 | * rest of the servers will be replica DBs. To prevent writes to your replica DBs due to |
3098 | * accidental misconfiguration or MediaWiki bugs, set read_only=1 on all your |
3099 | * replica DBs in my.cnf. You can set read_only mode at runtime using: |
3100 | * |
3101 | * ``` |
3102 | * SET @@read_only=1; |
3103 | * ``` |
3104 | * |
3105 | * Since the effect of writing to a replica DB is so damaging and difficult to clean |
3106 | * up, we at Wikimedia set read_only=1 in my.cnf on all our DB servers, even |
3107 | * our primaries, and then set read_only=0 on primaries at runtime. |
3108 | */ |
3109 | public const DBservers = [ |
3110 | 'default' => false, |
3111 | 'type' => 'false|list', |
3112 | ]; |
3113 | |
3114 | /** |
3115 | * Configuration for the ILBFactory service |
3116 | * |
3117 | * The "class" setting must point to a LBFactory subclass, which is also responsible |
3118 | * for reading $wgDBservers, $wgDBserver, etc. |
3119 | * |
3120 | * To set up a wiki farm with multiple database clusters, set the "class" to |
3121 | * LBFactoryMulti. See {@link Wikimedia::Rdbms::LBFactoryMulti LBFactoryMulti} docs for |
3122 | * information on how to configure the rest of the $wgLBFactoryConf array. |
3123 | */ |
3124 | public const LBFactoryConf = [ |
3125 | 'default' => [ |
3126 | 'class' => 'Wikimedia\\Rdbms\\LBFactorySimple', |
3127 | ], |
3128 | 'type' => 'map', |
3129 | 'mergeStrategy' => 'replace', |
3130 | ]; |
3131 | |
3132 | /** |
3133 | * After a state-changing request is done by a client, this determines |
3134 | * how many seconds that client should keep using the primary datacenter. |
3135 | * |
3136 | * This avoids unexpected stale or 404 responses due to replication lag. |
3137 | * |
3138 | * This must be greater than or equal to |
3139 | * Wikimedia\Rdbms\ChronologyProtector::POSITION_COOKIE_TTL. |
3140 | * |
3141 | * @since 1.27 |
3142 | */ |
3143 | public const DataCenterUpdateStickTTL = [ |
3144 | 'default' => 10, |
3145 | ]; |
3146 | |
3147 | /** |
3148 | * File to log database errors to |
3149 | */ |
3150 | public const DBerrorLog = [ |
3151 | 'default' => false, |
3152 | ]; |
3153 | |
3154 | /** |
3155 | * Timezone to use in the error log. |
3156 | * |
3157 | * Defaults to the wiki timezone ($wgLocaltimezone). |
3158 | * |
3159 | * A list of usable timezones can found at: |
3160 | * https://www.php.net/manual/en/timezones.php |
3161 | * |
3162 | * **Examples:** |
3163 | * |
3164 | * ``` |
3165 | * $wgDBerrorLogTZ = 'UTC'; |
3166 | * $wgDBerrorLogTZ = 'GMT'; |
3167 | * $wgDBerrorLogTZ = 'PST8PDT'; |
3168 | * $wgDBerrorLogTZ = 'Europe/Sweden'; |
3169 | * $wgDBerrorLogTZ = 'CET'; |
3170 | * ``` |
3171 | * |
3172 | * @since 1.20 |
3173 | */ |
3174 | public const DBerrorLogTZ = [ |
3175 | 'default' => false, |
3176 | 'dynamicDefault' => [ 'use' => [ 'Localtimezone' ] ] |
3177 | ]; |
3178 | |
3179 | public static function getDefaultDBerrorLogTZ( $localtimezone ) { |
3180 | // NOTE: Extra fallback, in case $localtimezone is ''. |
3181 | // Many extsing LocalSettings files have $wgLocaltimezone = '' |
3182 | // in them, erroneously generated by the installer. |
3183 | return $localtimezone ?: self::getDefaultLocaltimezone(); |
3184 | } |
3185 | |
3186 | /** |
3187 | * Other wikis on this site, can be administered from a single developer account. |
3188 | * |
3189 | * List of wiki DB domain IDs; the format of each ID consist of 1-3 hyphen |
3190 | * delimited alphanumeric components (each with no hyphens nor spaces) of any of the forms: |
3191 | * - "<DB NAME>-<DB SCHEMA>-<TABLE PREFIX>" |
3192 | * - "<DB NAME>-<TABLE PREFIX>" |
3193 | * - "<DB NAME>" |
3194 | * If hyphens appear in any of the components, then the domain ID parsing may not work |
3195 | * in all cases and site functionality might be affected. If the schema ($wgDBmwschema) |
3196 | * is left to the default "mediawiki" for all wikis, then the schema should be omitted |
3197 | * from these IDs. |
3198 | */ |
3199 | public const LocalDatabases = [ |
3200 | 'default' => [], |
3201 | 'type' => 'list', |
3202 | 'items' => [ 'type' => 'string', ], |
3203 | ]; |
3204 | |
3205 | /** |
3206 | * If lag is higher than $wgDatabaseReplicaLagWarning, show a warning in some special |
3207 | * pages (like watchlist). If the lag is higher than $wgDatabaseReplicaLagCritical, |
3208 | * show a more obvious warning. |
3209 | * |
3210 | * @since 1.36 |
3211 | */ |
3212 | public const DatabaseReplicaLagWarning = [ |
3213 | 'default' => 10, |
3214 | ]; |
3215 | |
3216 | /** |
3217 | * @see self::DatabaseReplicaLagWarning |
3218 | * @since 1.36 |
3219 | */ |
3220 | public const DatabaseReplicaLagCritical = [ |
3221 | 'default' => 30, |
3222 | ]; |
3223 | |
3224 | /** |
3225 | * Max execution time for queries of several expensive special pages such as RecentChanges |
3226 | * in milliseconds. |
3227 | * |
3228 | * @since 1.38 |
3229 | */ |
3230 | public const MaxExecutionTimeForExpensiveQueries = [ |
3231 | 'default' => 0, |
3232 | ]; |
3233 | |
3234 | /** |
3235 | * Mapping of virtual domain to external cluster db. |
3236 | * |
3237 | * If no entry is set, the code assumes local database. |
3238 | * For example, for routing queries of virtual domain 'vdomain' |
3239 | * to 'wikishared' database in 'extension1' cluster. The config should be like this: |
3240 | * [ 'vdomain' => [ 'cluster' => 'extension1', 'db' => 'wikishared' ] ] |
3241 | * |
3242 | * If the database needs to be the local domain, just set the 'db' to false. |
3243 | * |
3244 | * If you want to get another db in the main cluster, just omit 'cluster'. For example: |
3245 | * [ 'centralauth' => [ 'db' => 'centralauth' ] ] |
3246 | * |
3247 | * @since 1.41 |
3248 | */ |
3249 | public const VirtualDomainsMapping = [ |
3250 | 'default' => [], |
3251 | 'type' => 'map', |
3252 | ]; |
3253 | |
3254 | /** |
3255 | * Pagelinks table schema migration stage, for normalizing pl_namespace and pl_title fields. |
3256 | * |
3257 | * Use the SCHEMA_COMPAT_XXX flags. Supported values: |
3258 | * |
3259 | * - SCHEMA_COMPAT_WRITE_NEW | SCHEMA_COMPAT_READ_NEW (SCHEMA_COMPAT_NEW) |
3260 | * |
3261 | * History: |
3262 | * - 1.41: Added |
3263 | * - 1.43: Default has changed to SCHEMA_COMPAT_NEW. |
3264 | */ |
3265 | public const PageLinksSchemaMigrationStage = [ |
3266 | 'default' => SCHEMA_COMPAT_NEW, |
3267 | 'type' => 'integer', |
3268 | ]; |
3269 | |
3270 | /** |
3271 | * Migration stage for file tables |
3272 | * |
3273 | * Use the SCHEMA_COMPAT_XXX flags. Supported values: |
3274 | * |
3275 | * - SCHEMA_COMPAT_WRITE_OLD | SCHEMA_COMPAT_READ_OLD (SCHEMA_COMPAT_OLD) |
3276 | * - SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_OLD |
3277 | * |
3278 | * History: |
3279 | * - 1.44: Added |
3280 | */ |
3281 | public const FileSchemaMigrationStage = [ |
3282 | 'default' => SCHEMA_COMPAT_OLD, |
3283 | 'type' => 'integer', |
3284 | ]; |
3285 | |
3286 | /** |
3287 | * Migration stage for categorylinks tables |
3288 | * |
3289 | * Use the SCHEMA_COMPAT_XXX flags. Supported values: |
3290 | * |
3291 | * - SCHEMA_COMPAT_WRITE_OLD | SCHEMA_COMPAT_READ_OLD (SCHEMA_COMPAT_OLD) |
3292 | * - SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_OLD |
3293 | * |
3294 | * History: |
3295 | * - 1.44: Added |
3296 | */ |
3297 | public const CategoryLinksSchemaMigrationStage = [ |
3298 | 'default' => SCHEMA_COMPAT_OLD, |
3299 | 'type' => 'integer', |
3300 | ]; |
3301 | |
3302 | /** |
3303 | * Gaps in the externallinks table for certain domains. |
3304 | * |
3305 | * If you have identified certain domains for which externallinks searches are slow, |
3306 | * you can use this setting to make MediaWiki skip large el_id ranges, |
3307 | * rather than having the database scan through them fruitlessly. |
3308 | * |
3309 | * Each key in the array is a domain name in el_to_domain_index form, |
3310 | * e.g. 'https://com.example.'. |
3311 | * The value is an array with integer keys and values, |
3312 | * where each entry is a range (from => to, both inclusive) |
3313 | * of el_id values where this domain is known to have no entries. |
3314 | * (Subdomains are included, i.e., configuring an entry here guarantees to MediaWiki |
3315 | * that there are no rows where the el_to_domain_index starts with this value.) |
3316 | * |
3317 | * History: |
3318 | * - 1.41: Added |
3319 | */ |
3320 | public const ExternalLinksDomainGaps = [ |
3321 | 'default' => [], |
3322 | 'type' => 'map', |
3323 | ]; |
3324 | |
3325 | // endregion -- End of DB settings |
3326 | |
3327 | /***************************************************************************/ |
3328 | // region Content handlers and storage |
3329 | /** @name Content handlers and storage */ |
3330 | |
3331 | /** |
3332 | * Plugins for page content model handling. |
3333 | * |
3334 | * Each entry in the array maps a model id to an ObjectFactory specification |
3335 | * that creates an instance of the appropriate ContentHandler subclass. |
3336 | * |
3337 | * @since 1.21 |
3338 | */ |
3339 | public const ContentHandlers = [ |
3340 | 'default' => |
3341 | [ |
3342 | // the usual case |
3343 | CONTENT_MODEL_WIKITEXT => [ |
3344 | 'class' => WikitextContentHandler::class, |
3345 | 'services' => [ |
3346 | 'TitleFactory', |
3347 | 'ParserFactory', |
3348 | 'GlobalIdGenerator', |
3349 | 'LanguageNameUtils', |
3350 | 'LinkRenderer', |
3351 | 'MagicWordFactory', |
3352 | 'ParsoidParserFactory', |
3353 | ], |
3354 | ], |
3355 | // dumb version, no syntax highlighting |
3356 | CONTENT_MODEL_JAVASCRIPT => JavaScriptContentHandler::class, |
3357 | // simple implementation, for use by extensions, etc. |
3358 | CONTENT_MODEL_JSON => JsonContentHandler::class, |
3359 | // dumb version, no syntax highlighting |
3360 | CONTENT_MODEL_CSS => CssContentHandler::class, |
3361 | // plain text, for use by extensions, etc. |
3362 | CONTENT_MODEL_TEXT => TextContentHandler::class, |
3363 | // fallback for unknown models, from imports or extensions that were removed |
3364 | CONTENT_MODEL_UNKNOWN => FallbackContentHandler::class, |
3365 | ], |
3366 | 'type' => 'map', |
3367 | ]; |
3368 | |
3369 | /** |
3370 | * Associative array mapping namespace IDs to the name of the content model pages in that |
3371 | * namespace should have by default (use the CONTENT_MODEL_XXX constants). If no special |
3372 | * content type is defined for a given namespace, pages in that namespace will use the |
3373 | * CONTENT_MODEL_WIKITEXT |
3374 | * (except for the special case of JS and CS pages). |
3375 | * |
3376 | * @note To determine the default model for a new page's main slot, or any slot in general, |
3377 | * use SlotRoleHandler::getDefaultModel() together with SlotRoleRegistry::getRoleHandler(). |
3378 | * @since 1.21 |
3379 | */ |
3380 | public const NamespaceContentModels = [ |
3381 | 'default' => [], |
3382 | 'type' => 'map', |
3383 | ]; |
3384 | |
3385 | /** |
3386 | * Determines which types of text are parsed as wikitext. This does not imply that these kinds |
3387 | * of texts are also rendered as wikitext, it only means that links, magic words, etc will have |
3388 | * the effect on the database they would have on a wikitext page. |
3389 | * |
3390 | * Note that table of contents information will be *suppressed* for all |
3391 | * text models in this list other than wikitext. |
3392 | * |
3393 | * @todo Make the ToC suppression configurable by the content model |
3394 | * (T313455), not a side effect of inclusion here. |
3395 | * |
3396 | * @todo On the long run, it would be nice to put categories etc into a separate structure, |
3397 | * or at least parse only the contents of comments in the scripts. |
3398 | * @since 1.21 |
3399 | */ |
3400 | public const TextModelsToParse = [ |
3401 | 'default' => [ |
3402 | CONTENT_MODEL_WIKITEXT, // Just for completeness, wikitext will always be parsed. |
3403 |