-
Notifications
You must be signed in to change notification settings - Fork 50
/
CommonSettings.php
4310 lines (3681 loc) · 137 KB
/
CommonSettings.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
# WARNING: This file is publicly viewable on the web. Do not put private data here.
# CommonSettings.php is the main configuration file of the WMF cluster.
# This file contains settings common to all (or many) WMF wikis.
# For per-wiki configuration, see InitialiseSettings.php.
#
# This is for PRODUCTION.
#
# Effective load order:
# - multiversion
# - mediawiki/DefaultSettings.php
# - wmf-config/InitialiseSettings.php
# - wmf-config/CommonSettings.php [THIS FILE]
#
# Full load tree:
# - multiversion
# - mediawiki/index.php (or other entry point)
# - mediawiki/WebStart.php
# - mediawiki/Setup.php
# - mediawiki/DefaultSettings.php
# - mediawiki/LocalSettings.php
# `-- wmf-config/CommonSettings.php [THIS FILE]
# |-- wmf-config/*Services.php
# |-- wmf-config/etcd.php
# |-- wmf-config/InitialiseSettings.php
# |-- private/PrivateSettings.php
# |-- wmf-config/logging.php
# |-- wmf-config/filebackend.php
# |-- wmf-config/db-*.php
# |-- wmf-config/mc.php
# |
# `-- (main stuff in CommonSettings.php)
#
// Inline comments are often used for noting the task(s) associated with specific configuration
// and requiring comments to be on their own line would reduce readability for this file
// phpcs:disable MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment
use MediaWiki\Auth\AuthenticationResponse;
use MediaWiki\Extension\ApiFeatureUsage\ApiFeatureUsageQueryEngineElastica;
use MediaWiki\Extension\CentralAuth\User\CentralAuthUser;
use MediaWiki\Extension\ExtensionDistributor\Providers\GerritExtDistProvider;
use MediaWiki\Logger\LoggerFactory;
use MediaWiki\MediaWikiServices;
use MediaWiki\User\UserIdentity;
use Wikimedia\MWConfig\ClusterConfig;
use Wikimedia\MWConfig\MWConfigCacheGenerator;
use Wikimedia\MWConfig\ServiceConfig;
use Wikimedia\MWConfig\XWikimediaDebug;
# Godforsaken hack to work around problems with the reverse proxy caching changes...
#
# To minimize damage on fatal PHP errors, output a default no-cache header
# It will be overridden in cases where we actually specify caching behavior.
#
# More modern PHP versions will send a 500 result code on fatal error,
# at least sometimes, but what we're running will send a 200.
if ( PHP_SAPI !== 'cli' ) {
header( "Cache-control: no-cache" );
}
# ----------------------------------------------------------------------
# Initialisation
require_once __DIR__ . '/../src/XWikimediaDebug.php';
require_once __DIR__ . '/../src/ServiceConfig.php';
require_once __DIR__ . '/../src/ClusterConfig.php';
require_once __DIR__ . '/etcd.php';
require_once __DIR__ . '/../multiversion/MWConfigCacheGenerator.php';
// Past this point we know:
//
// - This file must be included by MediaWiki via our LocalSettings.php file.
// Determined by MediaWiki core having initialised the $IP variable.
//
// - MediaWiki must be included via a multiversion-aware entry point
// (e.g. WMF's "w/index.php", or MWScript).
// That entry point must have initialised the MWMultiVersion singleton and
// decided which wiki we are on (based on hostname or --wiki CLI arg).
// Note that getInstance does not (and may not) lazy-create this instance,
// it returns null if it hasn't been setup yet.
//
// - The wiki ID must be determined by MWMultiVersion::getMediaWiki, as called
// in the entry point (e.g. based on server name or --wiki). MWMultiVersion
// asserts that it is known in wikiversions.json, and otherwise bails
// by rendering `missing.php`.
//
// We can naturally only reach here (wmf-config/CommonSettings.php) if the
// wiki was known, the MW version was known, and MW core then loaded
// this file via LocalSettings.php.
//
$multiVersion = class_exists( 'MWMultiVersion' ) ? MWMultiVersion::getInstance() : null;
if ( !isset( $IP ) || !$multiVersion ) {
print "No MWMultiVersion instance initialized! MWScript.php wrapper not used?\n";
exit( 1 );
}
$includePaths = [ $IP, '/usr/local/lib/php', '/usr/share/php' ];
if ( is_readable( "$IP/vendor/composer/include_paths.php" ) ) {
$includePaths = array_merge(
require "$IP/vendor/composer/include_paths.php",
$includePaths
);
}
set_include_path( implode( PATH_SEPARATOR, $includePaths ) );
### List of some service hostnames
# 'meta' : meta wiki for user editable content
# 'upload' : hostname where files are hosted
# 'wikidata': hostname for the data repository
# Whenever all realms/datacenters should use the same host, do not use
# $wmgHostnames but use the hardcoded hostname instead. A good example are the
# spam blacklists hosted on meta.wikimedia.org which you will surely want to
# reuse.
$wmgHostnames = [];
switch ( $wmgRealm ) {
case 'labs':
$wmgHostnames['meta'] = 'meta.wikimedia.beta.wmflabs.org';
$wmgHostnames['test'] = 'test.wikipedia.beta.wmflabs.org';
$wmgHostnames['upload'] = 'upload.wikimedia.beta.wmflabs.org';
$wmgHostnames['wikidata'] = 'wikidata.beta.wmflabs.org';
$wmgHostnames['wikifunctions'] = 'wikifunctions.beta.wmflabs.org';
break;
case 'production':
default:
$wmgHostnames['meta'] = 'meta.wikimedia.org';
$wmgHostnames['test'] = 'test.wikipedia.org';
$wmgHostnames['upload'] = 'upload.wikimedia.org';
$wmgHostnames['wikidata'] = 'www.wikidata.org';
$wmgHostnames['wikifunctions'] = 'www.wikifunctions.org';
break;
}
$wgDBname = $multiVersion->getDatabase();
$wgDBuser = 'wikiuser'; // Don't rely on MW default (T46251)
$wgSQLMode = null;
$wmgVersionNumber = $multiVersion->getVersionNumber();
# Used further down this file for per-wiki SiteConfiguration caching:
# - MUST be in /tmp to allow atomic rename from elsewhere in /tmp.
# - MUST vary by MediaWiki branch (aka MWMultiversion deployment version).
#
# Also used by MediaWiki core for various caching purposes, and may
# be shared between wikis (e.g. does not need to vary by wgDBname).
$wgCacheDirectory = '/tmp/mw-cache-' . $wmgVersionNumber;
# Get all the service definitions
$wmgAllServices = ServiceConfig::getInstance()->getAllServices();
# Shorthand when we have no master-replica situation to keep into account
$wmgLocalServices = $wmgAllServices[$wmgDatacenter];
# The list of datacenters known to this realm
$wmgDatacenters = ServiceConfig::getInstance()->getDatacenters();
if ( getenv( 'WMF_MAINTENANCE_OFFLINE' ) ) {
// Prepare just enough configuration to allow
// rebuildLocalisationCache.php and mergeMessageFileList.php to
// run to completion without complaints.
$wmgEtcdLastModifiedIndex = "wmgEtcdLastModifiedIndex uninitialized due to WMF_MAINTENANCE_OFFLINE";
$wgReadOnly = "In read-only mode because WMF_MAINTENANCE_OFFLINE is set";
$wmgMasterDatacenter = ServiceConfig::getInstance()->getDatacenter();
$wmgMasterServices = $wmgAllServices[$wmgMasterDatacenter];
$wmgLocalDbConfig = [
'readOnlyBySection' => null,
'groupLoadsBySection' => [
'DEFAULT' => [
'' => [
'WMF_MAINTENANCE_OFFLINE_placeholder' => 0
],
],
],
'hostsByName' => null,
'sectionLoads' => [],
'externalLoads' => [],
];
$wmgRemoteMasterDbConfig = null;
} else {
$etcdConfig = wmfSetupEtcd( $wmgLocalServices['etcd'] );
$wmgEtcdLastModifiedIndex = $etcdConfig->getModifiedIndex();
$wgReadOnly = $etcdConfig->get( "$wmgDatacenter/ReadOnly" );
$wmgMasterDatacenter = $etcdConfig->get( 'common/WMFMasterDatacenter' );
$wmgMasterServices = $wmgAllServices[$wmgMasterDatacenter];
// Database load balancer config (sectionLoads, groupLoadsBySection, …)
// This is later merged into $wgLBFactoryConf by wmfApplyEtcdDBConfig().
// See also <https://wikitech.wikimedia.org/wiki/Dbctl>
$wmgLocalDbConfig = $etcdConfig->get( "$wmgDatacenter/dbconfig" );
if ( $wmgDatacenter !== $wmgMasterDatacenter ) {
$wmgRemoteMasterDbConfig = $etcdConfig->get( "$wmgMasterDatacenter/dbconfig" );
} else {
$wmgRemoteMasterDbConfig = null;
}
// Define a callback for use by LBFactory::autoReconfigure().
// This allows long-running scripts to take into account changes to the database config (T298485).
// The callback below does not support data center switches, but does support
// read-only flags and changes to replica weights. In particular, it allows a replica
// to be taken out of rotation.
if ( PHP_SAPI === 'cli' ) {
$wmgLBFactoryConfigCallback = static function () use ( $wmgLocalServices, $wmgDatacenter ) {
// NOTE: Don't re-use the existing $etcdConfig, the entire point of this
// callback is that the we want to re-load it to see if it has changed.
$etcdConfig = wmfSetupEtcd( $wmgLocalServices['etcd'] );
$dbConfigFromEtcd = $etcdConfig->get( "$wmgDatacenter/dbconfig" );
$lbFactoryConf = [];
wmfApplyEtcdDBConfig( $dbConfigFromEtcd, $lbFactoryConf );
$lbFactoryConf['class'] = 'LBFactoryMulti';
$lbFactoryConf['groupLoadsBySection']['s11'] = [];
$lbFactoryConf['sectionLoads']['s11'] = [ 'clouddb2002-dev' => 1 ];
$lbFactoryConf['hostsByName']['clouddb2002-dev'] = '10.192.20.6';
return $lbFactoryConf;
};
} else {
$wmgLBFactoryConfigCallback = null;
}
unset( $etcdConfig );
}
$wmgUdp2logDest = $wmgLocalServices['udp2log'];
if ( $wgDBname === 'testwiki' ) {
$wgDebugLogFile = "udp://{$wmgUdp2logDest}/testwiki";
} else {
$wgDebugLogFile = '/dev/null';
}
$wgConf = new SiteConfiguration;
$wgConf->suffixes = MWMultiVersion::SUFFIXES;
$wgConf->wikis = MWWikiversions::readDbListFile( $wmgRealm === 'labs' ? 'all-labs' : 'all' );
$wgConf->settings = MWConfigCacheGenerator::getStaticConfig( $wmgRealm );
$wgLocalDatabases = $wgConf->getLocalDatabases();
// Do not add wikimedia.org, because of other non-MediaWiki sites under that domain
// Do not add wikidata.org, because of query.wikidata.org
// If a non-MediaWiki site gets into this list, MediaWiki will not be able to
// make HTTP requests to it.
// At a minimum, all SUL-linked wikis must be included here for cross-wiki HTTP
// requests to work (GlobalUserPage, cross-wiki notifications, etc.).
// TODO: add remaining MediaWiki sites
$wgLocalVirtualHosts = [
'wikipedia.org',
'wiktionary.org',
'wikiquote.org',
'wikibooks.org',
'wikiquote.org',
'wikinews.org',
'wikisource.org',
'wikiversity.org',
'wikivoyage.org',
'www.mediawiki.org',
'www.wikidata.org',
'test.wikidata.org',
'api.wikimedia.org',
'ar.wikimedia.org',
'az.wikimedia.org',
'bd.wikimedia.org',
'be.wikimedia.org',
'br.wikimedia.org',
'ca.wikimedia.org',
'co.wikimedia.org',
'commons.wikimedia.org',
'dk.wikimedia.org',
'ee.wikimedia.org',
'fi.wikimedia.org',
'foundation.wikimedia.org',
'incubator.wikimedia.org',
'login.wikimedia.org',
'meta.wikimedia.org',
'mk.wikimedia.org',
'mx.wikimedia.org',
'nl.wikimedia.org',
'no.wikimedia.org',
'nyc.wikimedia.org',
'outreach.wikimedia.org',
'pl.wikimedia.org',
'pt.wikimedia.org',
'ru.wikimedia.org',
'se.wikimedia.org',
'species.wikimedia.org',
'test-commons.wikimedia.org',
'tr.wikimedia.org',
'ua.wikimedia.org',
've.wikimedia.org',
'wikimania.wikimedia.org',
'www.wikifunctions.org',
'm.wikifunctions.org',
];
$globals = MWConfigCacheGenerator::getConfigGlobals(
$wgDBname,
$wgConf,
$wmgRealm
);
// phpcs:ignore MediaWiki.Usage.ForbiddenFunctions.extract
extract( $globals );
# Determine legacy site/lang pair for the current wiki
list( $site, $lang ) = $wgConf->siteFromDB( $wgDBname );
# -------------------------------------------------------------------------
# Settings common to all wikis
# Private settings such as passwords, that shouldn't be published
# Needs to be before db.php
require __DIR__ . '/../private/PrivateSettings.php';
require __DIR__ . '/logging.php';
require __DIR__ . '/filebackend.php';
require __DIR__ . '/mc.php';
if ( $wmgRealm === 'labs' ) {
// Beta Cluster overrides
require __DIR__ . '/mc-labs.php';
}
# db-*.php needs $wgDebugDumpSql so should be loaded after logging.php.
# Ref: db-production.php or db-labs.php
require __DIR__ . "/db-$wmgRealm.php";
# Override certain settings in command-line mode
# This must be after InitialiseSettings.php is processed (T197475)
if ( PHP_SAPI === 'cli' ) {
$wgShowExceptionDetails = true;
}
if ( XWikimediaDebug::getInstance()->hasOption( 'readonly' ) ) {
$wgReadOnly = 'X-Wikimedia-Debug';
}
$wgAllowedCorsHeaders[] = 'X-Wikimedia-Debug';
// In production, read the database loadbalancer config from etcd.
// See https://wikitech.wikimedia.org/wiki/Dbctl
// This must be called after db-{eqiad,codfw}.php has been loaded!
// It overwrites a few sections of $wgLBFactoryConf with data from etcd.
// In labs, the relevant key exists in etcd, but does not contain real data.
// Only do this in production.
if ( $wmgRealm === 'production' ) {
wmfApplyEtcdDBConfig( $wmgLocalDbConfig, $wgLBFactoryConf );
// Add the config callback
$wgLBFactoryConf['configCallback'] = $wmgLBFactoryConfigCallback;
// labtestwiki is a one-off test server, using a wmcs-managed database. Cut
// etcd out of the loop entirely for this one.
$wgLBFactoryConf['groupLoadsBySection']['s11'] = [];
$wgLBFactoryConf['sectionLoads']['s11'] = [ 'clouddb2002-dev' => 1 ];
$wgLBFactoryConf['hostsByName']['clouddb2002-dev'] = '10.192.20.6';
// Disable LoadMonitor in CLI, it doesn't provide much value in CLI.
if ( PHP_SAPI === 'cli' ) {
$wgLBFactoryConf['loadMonitorClass'] = '\Wikimedia\Rdbms\LoadMonitorNull';
}
}
// Set $wgProfiler to the value provided by PhpAutoPrepend.php
if ( isset( $wmgProfiler ) ) {
$wgProfiler = $wmgProfiler;
}
# Disallow web request DB transactions slower than this
$wgMaxUserDBWriteDuration = 3;
# Activate read-only mode for bots when lag is getting high.
# This should be lower than 'max lag' in the LBFactory conf.
$wgAPIMaxLagThreshold = 3;
# Set the max memory used.
ini_set( 'memory_limit', $wmgMemoryLimit );
# Change calls to wfShellWikiCmd() to use MWScript.php wrapper
$wgHooks['wfShellWikiCmd'][] = 'MWMultiVersion::onWfShellMaintenanceCmd';
setlocale( LC_ALL, 'en_US.UTF-8' );
# ######################################################################
# Revision backend settings
# ######################################################################
$wgCompressRevisions = true;
$wgExternalStores = [ 'DB' ];
# ######################################################################
# Performance settings and restrictions
# ######################################################################
// Replicas aren't fast enough to generate all special pages all the time.
$wgMiserMode = true;
$wgQueryCacheLimit = 5000;
// ParserCache expire time temporarily reduced to 21 days (T280605)
$wgParserCacheExpireTime = 86400 * 21;
// Override talk pages to have 10 days only (T280605)
$wgDiscussionToolsTalkPageParserCacheExpiry = 86400 * 10;
// Old revision parser cache expire in 1 hour
$wgOldRevisionParserCacheExpireTime = 3600;
// This feature would vastly increase the size of the CDN cache, and increase
// MW appserver load.
$wgULSLanguageDetection = false;
/**
* Configure PHP request timeouts. These should be slightly less than the Apache
* timeouts, so that the slightly more informative PHP error message is
* delivered to the user, and so that we can verify that PHP timeouts actually
* exist (T97192).
*/
if ( PHP_SAPI === 'cli' ) {
// Should always be unlimited, this is probably redundant
$wgRequestTimeLimit = 0;
} elseif ( XWikimediaDebug::getInstance()->hasOption( 'shorttimeout' ) ) {
// To probe for excimer-related memory corruption e.g. T293568
$wgRequestTimeLimit = 2;
} else {
switch ( $_SERVER['HTTP_HOST'] ?? '' ) {
case 'videoscaler.svc.eqiad.wmnet':
case 'videoscaler.svc.codfw.wmnet':
case 'videoscaler.discovery.wmnet':
$wgRequestTimeLimit = 86400;
break;
case 'jobrunner.svc.eqiad.wmnet':
case 'jobrunner.svc.codfw.wmnet':
case 'jobrunner.discovery.wmnet':
$wgRequestTimeLimit = 1200;
break;
default:
if ( $_SERVER['REQUEST_METHOD'] === 'POST' ) {
$wgRequestTimeLimit = 200;
} else {
$wgRequestTimeLimit = 60;
}
}
}
# ######################################################################
# Account- and notifications-related settings
# ######################################################################
$wgSecureLogin = true;
$wgMaxNameChars = 85;
// Turn this on so UserMailer::send() will be able to send both text and html email
$wgAllowHTMLEmail = true;
$wgEnotifUserTalk = true;
$wgEnotifWatchlist = true;
// Keep this true; it's just whether the feature is available at all, not the default
// setting. T142727
$wgEnotifMinorEdits = true;
// Use the same expiry for core sessions as for CentralAuth sessions (T313496)
$wgObjectCacheSessionExpiry = 86400;
# ######################################################################
# Anti-abuse settings
# ######################################################################
$wgEnableUserEmailMuteList = true;
if ( $wmgUseGlobalPreferences ) {
// Allow global preferences for email-blacklist and echo-notifications
// to be auto-set where it is overridden
$wgGlobalPreferencesAutoPrefs = [
'email-blacklist',
'echo-notifications-blacklist'
];
}
# ######################################################################
# Legal matters
# ######################################################################
$wgRightsIcon = '//creativecommons.org/images/public/somerights20.png';
# ######################################################################
# ResourceLoader settings
# ######################################################################
$wgInternalServer = $wgCanonicalServer;
$wgArticlePath = '/wiki/$1';
$wgScriptPath = '/w';
$wgScript = "{$wgScriptPath}/index.php";
$wgRedirectScript = "{$wgScriptPath}/redirect.php";
$wgLoadScript = "{$wgScriptPath}/load.php";
// Don't include a hostname in $wgResourceBasePath and friends
// - Goes wrong otherwise on mobile web (T106966, T112646)
// - Improves performance by leveraging HTTP/2
// - $wgLocalStylePath MUST be relative
// Apache rewrites /w/resources, /w/extensions, and /w/skins to /w/static.php (T99096)
$wgResourceBasePath = '/w';
$wgExtensionAssetsPath = "{$wgResourceBasePath}/extensions";
$wgStylePath = "{$wgResourceBasePath}/skins";
$wgLocalStylePath = $wgStylePath;
$wgResourceLoaderMaxQueryLength = 5000;
// Cache version key for ResourceLoader client-side module store
// - Bumped to fix breakage due to old /static/$branchName/ urls still
// being cached after the switch to /w/static.php (T134368).
// - Bumped to fix broken SVG embedding being cached (T176884)
$wgResourceLoaderStorageVersion .= '-3';
$wgGitInfoCacheDirectory = "$IP/cache/gitinfo";
// @var string|bool: E-mail address to send notifications to, or false to disable notifications.
$wmgAddWikiNotify = "newprojects@lists.wikimedia.org";
$wgLocalisationCacheConf['storeClass'] = LCStoreCDB::class;
$wgLocalisationCacheConf['storeDirectory'] = "$IP/cache/l10n";
$wgLocalisationCacheConf['manualRecache'] = true;
// Add some useful config data to query=siteinfo
$wgHooks['APIQuerySiteInfoGeneralInfo'][] = static function ( $module, &$data ) {
global $wmgMasterDatacenter, $wmgEtcdLastModifiedIndex, $wmgCirrusSearchDefaultCluster,
$wgCirrusSearchDefaultCluster;
$data['wmf-config'] = [
'wmfMasterDatacenter' => $wmgMasterDatacenter,
'wmfEtcdLastModifiedIndex' => $wmgEtcdLastModifiedIndex,
'wmgCirrusSearchDefaultCluster' => $wmgCirrusSearchDefaultCluster,
'wgCirrusSearchDefaultCluster' => $wgCirrusSearchDefaultCluster,
];
};
$wgEmergencyContact = 'noc@wikipedia.org';
# Default address gets rejected by some mail hosts.
# This email is used for more than just sending password resets, also e.g. Echo notifications
# and random contact forms.
$wgPasswordSender = 'wiki@wikimedia.org';
$wgShowIPinHeader = false;
$wgRCMaxAge = 30 * 86400;
$wgTmpDirectory = '/tmp';
$wgOverrideUcfirstCharacters = include __DIR__ . '/UcfirstOverrides.php';
# Object cache and session settings
$wgSessionName = $wgDBname . 'Session';
$pcServers = [];
foreach ( $wmgLocalServices['parsercache-dbs'] as $tag => $host ) {
$pcServers[$tag] = [
'type' => 'mysql',
'host' => $host,
'dbname' => 'parsercache',
'user' => $wgDBuser,
'password' => $wgDBpassword,
'flags' => 0,
];
}
$wgObjectCaches['mysql-multiwrite'] = [
'class' => 'MultiWriteBagOStuff',
'caches' => [
0 => [
'factory' => [ 'ObjectCache', 'getInstance' ],
'args' => [ 'mcrouter' ]
],
1 => [
'class' => 'SqlBagOStuff',
'servers' => $pcServers,
'purgePeriod' => 0,
'tableName' => 'pc',
'shards' => 256,
'reportDupes' => false
],
],
'replication' => 'async',
'reportDupes' => false
];
$wgObjectCaches['kask-session'] = [
'class' => 'RESTBagOStuff',
'url' => "{$wmgLocalServices['sessionstore']}/sessions/v1/",
'httpParams' => [
'writeHeaders' => [
'content-type' => 'application/octet-stream',
],
'writeMethod' => 'POST',
],
'serialization_type' => 'PHP',
'hmac_key' => $wmgSessionStoreHMACKey,
'extendedErrorBodyFields' => [ 'type', 'title', 'detail', 'instance' ]
];
$wgObjectCaches['kask-echoseen'] = [
'class' => 'RESTBagOStuff',
'url' => "{$wmgLocalServices['echostore']}/echoseen/v1/",
'httpParams' => [
'writeHeaders' => [
'content-type' => 'application/octet-stream',
],
'writeMethod' => 'POST',
],
'serialization_type' => 'JSON',
'extendedErrorBodyFields' => [ 'type', 'title', 'detail', 'instance' ],
'reportDupes' => false,
];
$wgObjectCaches['db-mainstash'] = [
'class' => 'SqlBagOStuff',
'cluster' => 'extension2',
'dbDomain' => 'mainstash',
'globalKeyLbDomain' => 'mainstash',
'tableName' => 'objectstash',
'multiPrimaryMode' => true,
'purgePeriod' => 100,
'purgeLimit' => 1000,
'reportDupes' => false
];
session_name( $lang . 'wikiSession' );
// Use PBKDF2 for password hashing (T70766)
$wgPasswordDefault = 'pbkdf2';
// This needs to be increased as allowable by server performance
$wgPasswordConfig['pbkdf2'] = [
'class' => 'Pbkdf2Password',
'algo' => 'sha512',
'cost' => '128000',
'length' => '64',
];
// Temporary for T57420
$wgPasswordConfig['null'] = [ 'class' => InvalidPassword::class ];
// Password policies; see https://meta.wikimedia.org/wiki/Password_policy
//
// For global policies, see $wgCentralAuthGlobalPasswordPolicies below
$wmgPrivilegedPolicy = [
'MinimalPasswordLength' => [ 'value' => 10, 'suggestChangeOnLogin' => true, 'forceChange' => true ],
// With MinimumPasswordLengthToLogin, if the length of the password is <= the value
// of the policy, the user will be forced to use Special:PasswordReset or similar
// to be able to get into their account
'MinimumPasswordLengthToLogin' => [ 'value' => 1 ],
'PasswordNotInCommonList' => [ 'value' => true, 'suggestChangeOnLogin' => true ],
];
if ( $wgDBname === 'labswiki' || $wgDBname === 'labtestwiki' ) {
$wgPasswordPolicy['policies']['default']['MinimalPasswordLength'] = [
'value' => 10,
'suggestChangeOnLogin' => true,
'forceChange' => true,
];
} else {
foreach ( $wmgPrivilegedGroups as $group ) {
// On non-SUL wikis this is the effective password policy. On SUL wikis, it will be overridden
// in the PasswordPoliciesForUser hook, but still needed for Special:PasswordPolicies
if ( $group === 'user' ) {
$group = 'default'; // For e.g. private and fishbowl wikis; covers 'user' in password policies
}
$wgPasswordPolicy['policies'][$group] = array_merge( $wgPasswordPolicy['policies'][$group] ?? [],
$wmgPrivilegedPolicy );
}
}
$wgPasswordPolicy['policies']['default']['MinimalPasswordLength'] = [
'value' => 8,
'suggestChangeOnLogin' => false,
];
$wgPasswordPolicy['policies']['default']['PasswordNotInCommonList'] = [
'value' => true,
'suggestChangeOnLogin' => true,
];
// Enforce password policy when users login on other wikis; also for sensitive global groups
// FIXME does this just duplicate the global policy checks down in the main $wmgUseCentralAuth block?
if ( $wmgUseCentralAuth ) {
$wgHooks['PasswordPoliciesForUser'][] = static function ( User $user, array &$effectivePolicy ) use ( $wmgPrivilegedPolicy ) {
$privilegedGroups = wmfGetPrivilegedGroups( $user );
if ( $privilegedGroups ) {
$effectivePolicy = UserPasswordPolicy::maxOfPolicies( $effectivePolicy, $wmgPrivilegedPolicy );
if ( in_array( 'staff', $privilegedGroups, true ) ) {
$effectivePolicy['MinimumPasswordLengthToLogin'] = [
'value' => 10,
];
}
}
};
}
if ( $wmgDisableAccountCreation ) {
$wgGroupPermissions['*']['createaccount'] = false;
$wgGroupPermissions['*']['autocreateaccount'] = true;
}
# ######################################################################
# Server security settings
# ######################################################################
$wgShellRestrictionMethod = 'firejail';
$wgUseImageMagick = true;
$wgImageMagickConvertCommand = '/usr/local/bin/mediawiki-firejail-convert';
$wgSharpenParameter = '0x0.8'; # for IM>6.5, T26857
if ( $wmgUsePagedTiffHandler ) {
wfLoadExtension( 'PagedTiffHandler' );
$wgTiffUseTiffinfo = true;
$wgTiffMaxMetaSize = 1048576;
if ( $wmgUsePagedTiffHandlerShellbox && $wmgLocalServices['shellbox-media'] ) {
// Route pagedtiffhandler to the Shellbox named "shellbox-media".
$wgShellboxUrls['pagedtiffhandler'] = $wmgLocalServices['shellbox-media'];
// $wgShellboxSecretKey set in PrivateSettings.php
}
}
// Disable $wgMaxImageArea checks, Thumbor uses a timeout instead
// of a size limit (T291014#7367570)
$wgMaxImageArea = false;
$wgMaxAnimatedGifArea = 10e7; // 100MP
$wgFileExtensions = array_merge( $wgFileExtensions, $wmgFileExtensions );
$wgProhibitedFileExtensions = array_merge( $wgProhibitedFileExtensions, $wmgProhibitedFileExtensions );
if ( isset( $wmgUploadStashMaxAge ) ) {
$wgUploadStashMaxAge = $wmgUploadStashMaxAge;
}
if ( $wmgPrivateWikiUploads ) {
# mav forced me to --midom
$wgFileExtensions[] = 'ppt';
# mav forced me as well!!! -- Tim
$wgFileExtensions[] = 'doc';
# adding since removed elsewhere now -- 2007-08-21 -- brion
$wgFileExtensions[] = 'xls';
# delphine made me do it!!!!! --brion
$wgFileExtensions[] = 'eps';
$wgFileExtensions[] = 'zip';
# OpenOffice, hell if we're going to allow doc we may as well have these too -- Tim
$wgFileExtensions[] = 'odf';
$wgFileExtensions[] = 'odp';
$wgFileExtensions[] = 'ods';
$wgFileExtensions[] = 'odt';
$wgFileExtensions[] = 'odg'; // OpenOffice Graphics
$wgFileExtensions[] = 'ott'; // Templates
# Temporary for office work :P
$wgFileExtensions[] = 'wmv';
$wgFileExtensions[] = 'dv';
$wgFileExtensions[] = 'avi';
$wgFileExtensions[] = 'mov';
$wgFileExtensions[] = 'aif'; // "
$wgFileExtensions[] = 'aiff'; // "
# Because I hate having to find print drivers -- tomasz
$wgFileExtensions[] = 'ppd';
# InDesign & PhotoShop, Illustrator wanted for Chapters logo work
$wgFileExtensions[] = 'indd';
$wgFileExtensions[] = 'inx';
$wgFileExtensions[] = 'psd';
$wgFileExtensions[] = 'ai';
# Pete made me --Roan
$wgFileExtensions[] = 'omniplan';
# Dia Diagrams files --fred.
$wgFileExtensions[] = 'dia';
# Font files (so we can upload Montserrat to donatewiki) --Roan
$wgFileExtensions[] = 'woff';
$wgFileExtensions[] = 'woff2';
// To allow OpenOffice doc formats we need to not exclude zip files
$wgMimeTypeExclusions = array_diff(
$wgMimeTypeExclusions,
[ 'application/zip' ]
);
}
# ######################################################################
# SVG renderer settings
# ######################################################################
$wgSVGConverter = 'rsvg-secure';
$wgSVGConverterPath = '/usr/bin';
$wgSVGMaxSize = 4096; // 1024's a bit low?
# Hack for rsvg broken by security patch
$wgSVGConverters['rsvg-broken'] = '$path/rsvg-convert -w $width -h $height -o $output < $input';
# This converter will only work when rsvg has a suitable security patch
$wgSVGConverters['rsvg-secure'] = '$path/rsvg-convert --no-external-files -w $width -h $height -o $output $input';
# ######################################################################
# DJVU renderer settings
# ######################################################################
$wgDjvuDump = '/usr/bin/djvudump';
$wgDjvuRenderer = '/usr/bin/ddjvu';
$wgDjvuTxt = '/usr/bin/djvutxt';
# ######################################################################
# Reverse proxy Configuration
# ######################################################################
$wgStatsdServer = $wmgLocalServices['statsd'];
$wgUseCdn = true;
if ( $wmgRealm === 'production' ) {
require __DIR__ . '/reverse-proxy.php';
} elseif ( $wmgRealm === 'labs' ) {
$wgStatsdMetricPrefix = 'BetaMediaWiki';
require __DIR__ . '/reverse-proxy-labs.php';
}
// CORS (cross-domain AJAX, T22814)
// This lists the domains that are accepted as *origins* of CORS requests
// DO NOT add domains here that aren't WMF wikis unless you really know what you're doing
if ( $wmgUseCORS ) {
$wgCrossSiteAJAXdomains = [
'*.wikipedia.org',
'*.wikinews.org',
'*.wiktionary.org',
'*.wikibooks.org',
'*.wikiversity.org',
'*.wikisource.org',
'wikisource.org',
'*.wikiquote.org',
'www.wikidata.org',
'm.wikidata.org',
'test.wikidata.org',
'test.m.wikidata.org',
'*.wikivoyage.org',
'www.mediawiki.org',
'm.mediawiki.org',
'www.wikifunctions.org',
'm.wikifunctions.org',
'advisory.wikimedia.org',
'advisory.m.wikimedia.org',
'affcom.wikimedia.org',
'api.wikimedia.org',
'auditcom.wikimedia.org',
'boardgovcom.wikimedia.org',
'board.wikimedia.org',
'chair.wikimedia.org',
'checkuser.wikimedia.org',
'checkuser.m.wikimedia.org',
'collab.wikimedia.org',
'commons.wikimedia.org',
'commons.m.wikimedia.org',
'test-commons.wikimedia.org',
'test-commons.m.wikimedia.org',
'donate.wikimedia.org',
'exec.wikimedia.org',
'foundation.wikimedia.org',
'foundation.m.wikimedia.org',
'grants.wikimedia.org',
'incubator.wikimedia.org',
'incubator.m.wikimedia.org',
'internal.wikimedia.org',
'login.wikimedia.org',
'meta.wikimedia.org',
'meta.m.wikimedia.org',
'movementroles.wikimedia.org',
'office.wikimedia.org',
'office.m.wikimedia.org',
'outreach.wikimedia.org',
'outreach.m.wikimedia.org',
'quality.wikimedia.org',
'quality.m.wikimedia.org',
'searchcom.wikimedia.org',
'spcom.wikimedia.org',
'species.wikimedia.org',
'species.m.wikimedia.org',
'steward.wikimedia.org',
'steward.m.wikimedia.org',
'strategy.wikimedia.org',
'strategy.m.wikimedia.org',
'usability.wikimedia.org',
'usability.m.wikimedia.org',
'vrt-wiki.wikimedia.org',
'vrt-wiki.m.wikimedia.org',
'wikimania.wikimedia.org',
'wikimania.m.wikimedia.org',
'wikimania????.wikimedia.org',
'wikimania????.m.wikimedia.org',
'wikimaniateam.wikimedia.org',
'wikimaniateam.m.wikimedia.org',
'am.wikimedia.org',
'am.m.wikimedia.org',
'ar.wikimedia.org',
'ar.m.wikimedia.org',
'bd.wikimedia.org',
'bd.m.wikimedia.org',
'be.wikimedia.org',
'be.m.wikimedia.org',
'br.wikimedia.org',
'br.m.wikimedia.org',
'ca.wikimedia.org',
'ca.m.wikimedia.org',
'cn.wikimedia.org',
'cn.m.wikimedia.org',
'co.wikimedia.org',
'co.m.wikimedia.org',
'dk.wikimedia.org',
'dk.m.wikimedia.org',
'ec.wikimedia.org',
'ec.m.wikimedia.org',
'ee.wikimedia.org',
'ee.m.wikimedia.org',
'et.wikimedia.org',
'et.m.wikimedia.org',
'fi.wikimedia.org',
'fi.m.wikimedia.org',
'ge.wikimedia.org',
'ge.m.wikimedia.org',
'hi.wikimedia.org',
'hi.m.wikimedia.org',
'id.wikimedia.org',
'id.m.wikimedia.org',
'il.wikimedia.org',
'il.m.wikimedia.org',
'mai.wikimedia.org',
'mai.m.wikimedia.org',
'mk.wikimedia.org',
'mk.m.wikimedia.org',
'mx.wikimedia.org',
'mx.m.wikimedia.org',
'nl.wikimedia.org',
'nl.m.wikimedia.org',
'noboard-chapters.wikimedia.org',
'no.wikimedia.org',
'no.m.wikimedia.org',
'nyc.wikimedia.org',
'nyc.m.wikimedia.org',
'nz.wikimedia.org',
'nz.m.wikimedia.org',
'punjabi.wikimedia.org',
'punjabi.m.wikimedia.org',
'pa-us.wikimedia.org',
'pa-us.m.wikimedia.org',
'pl.wikimedia.org',
'pl.m.wikimedia.org',
'pt.wikimedia.org',
'pt.m.wikimedia.org',
'romd.wikimedia.org',
'romd.m.wikimedia.org',
'rs.wikimedia.org',
'rs.m.wikimedia.org',
'ru.wikimedia.org',
'ru.m.wikimedia.org',
'se.wikimedia.org',
'se.m.wikimedia.org',
'tr.wikimedia.org',
'tr.m.wikimedia.org',
'ua.wikimedia.org',
'ua.m.wikimedia.org',
'wb.wikimedia.org',
'wb.m.wikimedia.org',
];
}
wfLoadSkins( [ 'Vector', 'MonoBook', 'Modern', 'CologneBlue', 'Timeless' ] );
// Grants and rights
// Note these have to be visible on all wikis, not just the ones the
// extension is enabled on, for proper display in OAuth pages and such.
// Adding Flaggedrevs rights so that they are available for globalgroups/staff rights - JRA 2013-07-22
$wgAvailableRights[] = 'autoreview';
$wgAvailableRights[] = 'autoreviewrestore';
$wgAvailableRights[] = 'movestable';
$wgAvailableRights[] = 'review';
$wgAvailableRights[] = 'stablesettings';
$wgAvailableRights[] = 'unreviewedpages';
$wgAvailableRights[] = 'validate';
$wgGrantPermissions['editprotected']['movestable'] = true;
// So that protection rights can be assigned to global groups
$wgAvailableRights[] = 'templateeditor';
$wgAvailableRights[] = 'editeditorprotected';
$wgAvailableRights[] = 'editextendedsemiprotected';
$wgAvailableRights[] = 'extendedconfirmed';
$wgAvailableRights[] = 'editautoreviewprotected';
$wgAvailableRights[] = 'editautopatrolprotected';
$wgAvailableRights[] = 'edittrustedprotected';
$wgGrantPermissions['editprotected']['templateeditor'] = true;
$wgGrantPermissions['editprotected']['editeditorprotected'] = true;
$wgGrantPermissions['editprotected']['editextendedsemiprotected'] = true;
$wgGrantPermissions['editprotected']['extendedconfirmed'] = true;