-
Notifications
You must be signed in to change notification settings - Fork 51
/
CommonSettings.php
3235 lines (2705 loc) · 103 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 publically viewable on the web. Do not put private data here.
#######################################################################
# CommonSettings.php is the main configuration file of the WMF cluster.
# It is included by LocalSettings.php
#
# This file contains settings common to all or many WMF wikis.
# Per-wiki configuration is done in InitialiseSettings.php (included
# into this file a little way down).
#######################################################################
use MediaWiki\Logger\LoggerFactory;
# Godforsaken hack to work around problems with the Squid 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" );
}
if ( PHP_SAPI == 'cli' ) {
# Override for sanity's sake.
ini_set( 'display_errors', 1 );
}
if ( isset( $_SERVER['SERVER_ADDR'] ) ) {
ini_set( 'error_append_string', ' (' . $_SERVER['SERVER_ADDR'] . ')' );
}
# ----------------------------------------------------------------------
# Initialisation
# Get the version object for this Wiki (must be set by now, along with $IP)
if ( !class_exists( 'MWMultiVersion' ) ) {
print "No MWMultiVersion instance initialized! MWScript.php wrapper not used?\n";
exit(1);
}
$multiVersion = MWMultiVersion::getInstance();
set_include_path( "$IP:/usr/local/lib/php:/usr/share/php" );
# Master datacenter
# The datacenter from which we serve traffic.
$wmfMasterDatacenter = 'eqiad';
### List of some service hostnames
# 'meta' : meta wiki for user editable content
# 'upload' : hostname where files are hosted
# 'wikidata': hostname for the data repository
# 'bits' : for load.php and js/css assets
# Whenever all realms/datacenters should use the same host, do not use
# $wmfHostnames 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.
$wmfHostnames = array();
switch( $wmfRealm ) {
case 'labs':
$wmfHostnames['bits'] = 'bits.beta.wmflabs.org';
$wmfHostnames['meta'] = 'meta.wikimedia.beta.wmflabs.org';
$wmfHostnames['test'] = 'test.wikimedia.beta.wmflabs.org';
$wmfHostnames['upload'] = 'upload.beta.wmflabs.org';
$wmfHostnames['wikidata'] = 'wikidata.beta.wmflabs.org';
break;
case 'production':
default:
$wmfHostnames['bits'] = 'bits.wikimedia.org';
$wmfHostnames['meta'] = 'meta.wikimedia.org';
$wmfHostnames['test'] = 'test.wikipedia.org';
$wmfHostnames['upload'] = 'upload.wikimedia.org';
$wmfHostnames['wikidata'] = 'www.wikidata.org';
break;
}
# This must be set *after* the DefaultSettings.php inclusion
$wgDBname = $multiVersion->getDatabase();
# Better have the proper username (T46251)
$wgDBuser = 'wikiuser';
# wmf-config directory (in common/)
$wmfConfigDir = "$IP/../wmf-config";
# Include all the service definitions
# TODO: only include if in production, set up beta separately
switch( $wmfRealm ) {
case 'labs':
require "$wmfConfigDir/LabsServices.php";
break;
case 'production':
default:
require "$wmfConfigDir/ProductionServices.php";
}
# Must be set before InitialiseSettings.php:
$wmfUdp2logDest = $wmfLocalServices['udp2log'];
# Initialise wgConf
require( "$wmfConfigDir/wgConf.php" );
function wmfLoadInitialiseSettings( $conf ) {
global $wmfConfigDir;
require( "$wmfConfigDir/InitialiseSettings.php" );
}
$wgLocalVirtualHosts = array(
'wikipedia.org',
'wiktionary.org',
'wikiquote.org',
'wikibooks.org',
'wikiquote.org',
'wikinews.org',
'wikisource.org',
'wikiversity.org',
'wikivoyage.org',
// 'wikimedia.org' // Removed 2008-09-30 by brion -- breaks codereview-proxy.wikimedia.org
'meta.wikimedia.org', // Presumably needed to load meta spam list. Any others?
'commons.wikimedia.org',
);
# Is this database listed in dblist?
# Note: $wgLocalDatabases set in wgConf.php.
# Note: must be done before calling $multiVersion functions other than getDatabase().
if ( array_search( $wgDBname, $wgLocalDatabases ) === false ) {
# No? Load missing.php
if ( $wgCommandLineMode ) {
print "Database name $wgDBname is not listed in dblist\n";
} else {
require( "$wmfConfigDir/missing.php" );
}
exit;
}
# Determine domain and language and the directories for this instance
list( $site, $lang ) = $wgConf->siteFromDB( $wgDBname );
$wmgVersionNumber = $multiVersion->getVersionNumber();
# Try configuration cache
$filename = "/tmp/mw-cache-$wmgVersionNumber/conf-$wgDBname";
if ( defined( 'HHVM_VERSION' ) ) {
$filename .= '-hhvm';
}
$globals = false;
if ( @filemtime( $filename ) >= filemtime( "$wmfConfigDir/InitialiseSettings.php" ) ) {
$cacheRecord = @file_get_contents( $filename );
if ( $cacheRecord !== false ) {
$globals = unserialize( $cacheRecord );
}
}
if ( !$globals ) {
# Get configuration from SiteConfiguration object
require( "$wmfConfigDir/InitialiseSettings.php" );
$wikiTags = array();
foreach ( array( 'private', 'fishbowl', 'special', 'closed', 'flow', 'flaggedrevs', 'small', 'medium',
'large', 'wikimania', 'wikidata', 'wikidataclient', 'visualeditor-default',
'commonsuploads', 'nonbetafeatures', 'group0', 'wikipedia',
'arbitraryaccess', 'nonglobal', 'wikitech'
) as $tag ) {
$dblist = MWWikiversions::readDbListFile( $tag );
if ( in_array( $wgDBname, $dblist ) ) {
$wikiTags[] = $tag;
}
}
$dbSuffix = ( $site === 'wikipedia' ) ? 'wiki' : $site;
$globals = $wgConf->getAll( $wgDBname, $dbSuffix,
array(
'lang' => $lang,
'docRoot' => $_SERVER['DOCUMENT_ROOT'],
'site' => $site,
'stdlogo' => "//{$wmfHostnames['upload']}/$site/$lang/b/bc/Wiki.png" ,
), $wikiTags );
# Save cache
@mkdir( '/tmp/mw-cache-' . $wmgVersionNumber );
$tmpFile = tempnam( '/tmp/', "conf-$wmgVersionNumber-$wgDBname" );
if ( $tmpFile && file_put_contents( $tmpFile, serialize( $globals ) ) ) {
rename( $tmpFile, $filename );
}
}
extract( $globals );
# -------------------------------------------------------------------------
# Settings common to all wikis
# Private settings such as passwords, that shouldn't be published
# Needs to be before db.php
require( "$wmfConfigDir/PrivateSettings.php" );
$wgMemCachedServers = array();
require "$wmfConfigDir/logging.php";
require "$wmfConfigDir/redis.php";
if ( isset( $_SERVER['HTTP_X_WIKIMEDIA_DEBUG'] ) && preg_match( '/\breadonly\b/i', $_SERVER['HTTP_X_WIKIMEDIA_DEBUG'] ) ) {
$wgReadOnly = 'X-Wikimedia-Debug';
}
if ( $wmfRealm === 'labs' ) {
require "$wmfConfigDir/db-labs.php";
require "$wmfConfigDir/mc-labs.php";
} else {
require "$wmfConfigDir/mc.php";
require "$wmfConfigDir/db-{$wmfDatacenter}.php";
}
# Disallow web request DB transactions slower than this
$wgMaxUserDBWriteDuration = 6.0;
# Activate read-only mode for bots when lag is getting high.
# This should be lower than 'max lag' in the LBFactory conf.
$wgAPIMaxLagThreshold = 6;
ini_set( 'memory_limit', $wmgMemoryLimit );
# Rewrite commands given to wfShellWikiCmd() to use Het-Deploy
$wgHooks['wfShellWikiCmd'][] = 'MWMultiVersion::onWfShellMaintenanceCmd';
setlocale( LC_ALL, 'en_US.UTF-8' );
unset( $wgStylePath );
unset( $wgStyleSheetPath );
$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;
// Deprecated
$wgStyleSheetPath = $wgStylePath;
// Deprecated
$wgIncludeLegacyJavaScript = true;
if ( gethostname() === 'osmium' ) {
$wgResourceLoaderStorageEnabled = false;
}
$wgCacheDirectory = '/tmp/mw-cache-' . $wmgVersionNumber;
$wgGitInfoCacheDirectory = "$IP/cache/gitinfo";
// @var string|bool: E-mail address to send notifications to, or false to disable notifications.
$wmgAddWikiNotify = "newprojects@lists.wikimedia.org";
// Comment out the following lines to get the old-style l10n caching -- TS 2011-02-22
$wgLocalisationCacheConf['storeDirectory'] = "$IP/cache/l10n";
$wgLocalisationCacheConf['manualRecache'] = true;
// T29320: skip MessageBlobStore::clear(); handle via refreshMessageBlobs.php instead
$wgHooks['LocalisationCacheRecache'][] = function( $cache, $code, &$allData, &$purgeBlobs = true ) {
$purgeBlobs = false;
return true;
};
$wgFileStore['deleted']['directory'] = "/mnt/upload7/private/archive/$site/$lang";
# used for mysql/search settings
$tmarray = getdate( time() );
$hour = $tmarray['hours'];
$day = $tmarray['wday'];
$wgEmergencyContact = 'noc@wikipedia.org';
if ( !isset( $wgLocaltimezone ) ) {
$wgLocaltimezone = 'UTC';
}
if ( $wgLocaltimezone !== 'UTC' ) {
$wgLocalTZOffset = timezone_offset_get(
timezone_open( $wgLocaltimezone ),
date_create( 'now', timezone_open( 'UTC' ) )
) / 60;
} else {
$wgLocalTZOffset = 0;
}
$wgShowIPinHeader = false;
$wgUseGzip = true;
$wgRCMaxAge = 30 * 86400;
$wgTmpDirectory = '/tmp';
$wgSQLMode = null;
# Object cache and session settings
$wgSessionName = $wgDBname . 'Session';
$pcTemplate = array( 'type' => 'mysql',
'dbname' => 'parsercache',
'user' => $wgDBuser,
'password' => $wgDBpassword,
'flags' => 0,
);
$pcServers = array();
foreach ( $wmgParserCacheDBs as $host ) {
$pcServers[] = array( 'host' => $host ) + $pcTemplate;
}
$wgObjectCaches['mysql-multiwrite'] = array(
'class' => 'MultiWriteBagOStuff',
'caches' => array(
0 => array(
'factory' => array( 'ObjectCache', 'getInstance' ),
'args' => array( 'memcached-pecl' )
),
1 => array(
'class' => 'SqlBagOStuff',
'servers' => $pcServers,
'purgePeriod' => 0,
'tableName' => 'pc',
'shards' => 256,
),
),
'replication' => 'async'
);
$wgSessionsInObjectCache = true;
session_name( $lang . 'wikiSession' );
if ( $wgDBname === 'labswiki' ) {
$wgMessageCacheType = 'memcached-pecl';
$wgCookieDomain = "wikitech.wikimedia.org"; // TODO: Is this really necessary?
}
if ( $wgDBname === 'labtestwiki' ) {
$wgMessageCacheType = 'memcached-pecl';
$wgCookieDomain = "labtestwikitech.wikimedia.org"; // TODO: Is this really necessary?
}
// Use PBKDF2 for password hashing (T70766)
$wgPasswordDefault = 'pbkdf2';
// This needs to be increased as allowable by server performance
$wgPasswordConfig['pbkdf2'] = array(
'class' => 'Pbkdf2Password',
'algo' => 'sha512',
'cost' => '128000',
'length' => '64',
);
if ( $wgDBname === 'labswiki' || $wgDBname === 'labtestwiki' ) {
$wgPasswordPolicy['policies']['default']['MinimalPasswordLength'] = 10;
} else {
// See password policy RFC on meta
// [[m:Requests_for_comment/Password_policy_for_users_with_certain_advanced_permissions]]
foreach ( array( 'bureaucrat', 'sysop', 'checkuser', 'oversight' ) as $group ) {
$wgPasswordPolicy['policies'][$group]['MinimalPasswordLength'] = 8;
$wgPasswordPolicy['policies'][$group]['MinimumPasswordLengthToLogin'] = 1;
$wgPasswordPolicy['policies'][$group]['PasswordCannotBePopular'] = 10000;
}
$wgPasswordPolicy['policies']['bot']['MinimalPasswordLength'] = 1;
}
// Enforce password policy when users login on other wikis
if ( $wmgUseCentralAuth ) {
$wgHooks['PasswordPoliciesForUser'][] = function( User $user, array &$effectivePolicy ) {
$central = CentralAuthUser::getInstance( $user );
if ( !$central->exists() ) {
return true;
}
$privilegedPolicy = array(
'MinimalPasswordLength' => 8,
'MinimumPasswordLengthToLogin' => 1,
'PasswordCannotBePopular' => 10000,
);
if ( array_intersect(
array( 'bureaucrat', 'sysop', 'checkuser', 'oversight', 'interface-editor' ),
$central->getLocalGroups()
) ) {
$effectivePolicy = UserPasswordPolicy::maxOfPolicies(
$effectivePolicy,
$privilegedPolicy
);
return true;
}
// Result should be cached by getLocalGroups() above
$attachInfo = $central->queryAttached();
$enforceWikiGroups = array(
'centralnoticeadmin' => array( 'metawiki', 'testwiki' ),
'templateeditor' => array( 'fawiki', 'rowiki' ),
'botadmin' => array( 'frwiktionary', 'mlwiki', 'mlwikisource', 'mlwiktionary' ),
'translator' => array( 'incubatorwiki' ),
'technician' => array( 'trwiki' ),
'wikidata-staff' => array( 'wikidata' ),
);
foreach ( $enforceWikiGroups as $group => $wikis ) {
foreach ( $wikis as $wiki ) {
if ( isset( $attachInfo[$wiki]['groups'] )
&& in_array( $group, $attachInfo[$wiki]['groups'] ) )
{
$effectivePolicy = UserPasswordPolicy::maxOfPolicies(
$effectivePolicy,
$privilegedPolicy
);
return true;
}
}
}
return true;
};
}
// For global policies, see $wgCentralAuthGlobalPasswordPolicies below
$wgEnableBotPasswords = $wmgEnableBotPasswords;
$wgBotPasswordsCluster = $wmgBotPasswordsCluster;
$wgBotPasswordsDatabase = $wmgBotPasswordsDatabase;
if ( PHP_SAPI === 'cli' ) {
$wgShowExceptionDetails = true;
}
$wgUseImageResize = true;
$wgUseImageMagick = true;
$wgImageMagickConvertCommand = '/usr/bin/convert';
$wgSharpenParameter = '0x0.8'; # for IM>6.5, T26857
$wgFileBlacklist[] = 'txt';
$wgFileBlacklist[] = 'mht';
if ( $wmgUsePagedTiffHandler ) {
include( $IP . '/extensions/PagedTiffHandler/PagedTiffHandler.php' );
}
$wgTiffUseTiffinfo = true;
$wgTiffMaxMetaSize = 1048576;
$wgMaxImageArea = 75e6; // 75MP
$wgMaxAnimatedGifArea = 75e6; // 75MP
$wgFileExtensions = array_merge( $wgFileExtensions, $wmgFileExtensions );
// Disable webp for now. T27397
$wgFileExtensions = array_values( array_diff( $wgFileExtensions, array( 'webp' ) ) );
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[] = 'mp3'; // for Jay for fundraising bits
$wgFileExtensions[] = 'aif'; // "
$wgFileExtensions[] = 'aiff'; // "
# Becausee 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';
// To allow OpenOffice doc formats we need to not blacklist zip files
$wgMimeTypeBlacklist = array_diff(
$wgMimeTypeBlacklist,
array( 'application/zip' ) );
}
# Hack for rsvg broken by security patch
$wgSVGConverters['rsvg-broken'] = '$path/rsvg-convert -w $width -h $height -o $output < $input';
if ( defined( 'HHVM_VERSION' ) ) {
# Newer librsvg supports a sane security model by default and doesn't need our security patch
$wgSVGConverters['rsvg-secure'] = '$path/rsvg-convert -w $width -h $height -o $output $input';
} else {
# 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';
// Special config for wikitech which runs trusty (and therefore the new librsvg2-bin package),
// but on PHP 5.5 (not HHVM)
$wgSVGConverters['rsvg-wikitech'] = '$path/rsvg-convert -w $width -h $height -o $output $input';
}
#######################################################################
# Squid Configuration
#######################################################################
$wgStatsdServer = $wmfLocalServices['statsd'];
if ( $wmfRealm === 'production' ) {
if ( $wmgUseClusterSquid ) {
$wgUseSquid = true;
require( "$wmfConfigDir/squid.php" );
}
} elseif ( $wmfRealm === 'labs' ) {
$wgStatsdMetricPrefix = 'BetaMediaWiki';
if ( $wmgUseClusterSquid ) {
$wgUseSquid = true;
require( "$wmfConfigDir/squid-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 = array(
'*.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',
'*.wikivoyage.org',
'www.mediawiki.org',
'm.mediawiki.org',
'wikimediafoundation.org',
'advisory.wikimedia.org',
'affcom.wikimedia.org',
'auditcom.wikimedia.org',
'boardgovcom.wikimedia.org',
'board.wikimedia.org',
'chair.wikimedia.org',
'checkuser.wikimedia.org',
'collab.wikimedia.org',
'commons.wikimedia.org',
'donate.wikimedia.org',
'exec.wikimedia.org',
'grants.wikimedia.org',
'incubator.wikimedia.org',
'internal.wikimedia.org',
'login.wikimedia.org',
'meta.wikimedia.org',
'movementroles.wikimedia.org',
'office.wikimedia.org',
'otrs-wiki.wikimedia.org',
'outreach.wikimedia.org',
'quality.wikimedia.org',
'searchcom.wikimedia.org',
'spcom.wikimedia.org',
'species.wikimedia.org',
'steward.wikimedia.org',
'strategy.wikimedia.org',
'usability.wikimedia.org',
'wikimania????.wikimedia.org',
'wikimaniateam.wikimedia.org',
);
}
wfLoadSkins( array( 'Vector', 'MonoBook', 'Modern', 'CologneBlue' ) );
// 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[] = 'stablesettings';
$wgAvailableRights[] = 'review';
$wgAvailableRights[] = 'unreviewedpages';
$wgAvailableRights[] = 'movestable';
$wgAvailableRights[] = 'validate';
$wgGrantPermissions['editprotected']['movestable'] = true;
// So that protection rights can be assigned to global groups
$wgAvailableRights[] = 'templateeditor';
$wgAvailableRights[] = 'editeditorprotected';
$wgAvailableRights[] = 'editextendedsemiprotected';
$wgAvailableRights[] = 'extendedconfirmed';
$wgGrantPermissions['editprotected']['templateeditor'] = true;
$wgGrantPermissions['editprotected']['editeditorprotected'] = true;
$wgGrantPermissions['editprotected']['editextendedsemiprotected'] = true;
$wgGrantPermissions['editprotected']['extendedconfirmed'] = true;
// Allow tboverride with editprotected, and tboverride-account with createaccount
$wgGrantPermissions['editprotected']['tboverride'] = true;
$wgGrantPermissions['createaccount']['tboverride-account'] = true;
// Adding Flow's rights so that they are available for global groups/staff rights
$wgAvailableRights[] = 'flow-edit-post';
$wgAvailableRights[] = 'flow-suppress';
$wgAvailableRights[] = 'flow-hide';
$wgAvailableRights[] = 'flow-delete';
$wgAvailableRights[] = 'moodbar-admin'; // To allow global groups to include this right -AG
// Enable gather-hidelist for global user groups - JRA 4-1-2015 T94652
$wgAvailableRights[] = 'gather-hidelist';
// Checkuser
$wgGrantPermissions['checkuser']['checkuser'] = true;
$wgGrantPermissions['checkuser']['checkuser-log'] = true;
// Categorize additional groups defined above.
// Corresponding messages are mwoauth-grant-* in WikimediaMessages.
$wgGrantPermissionGroups['checkuser'] = 'administration';
// Rights needed to interact with wikibase
$wgGrantPermissions['createeditmovepage']['property-create'] = true;
$wgGrantPermissions['editpage']['item-term'] = true;
$wgGrantPermissions['editpage']['item-merge'] = true;
$wgGrantPermissions['editpage']['property-term'] = true;
$wgGrantPermissions['editpage']['item-redirect'] = true;
// Enable a "viewdeletedfile" userright for [[m:Global deleted image review]] (T16801)
$wgAvailableRights[] = 'viewdeletedfile';
$wgHooks['TitleQuickPermissions'][] = function ( Title $title, User $user, $action, &$errors, $doExpensiveQueries, $short ) {
return ( !in_array( $action, array( 'deletedhistory', 'deletedtext' ) ) || !$title->inNamespaces( NS_FILE, NS_FILE_TALK ) || !$user->isAllowed( 'viewdeletedfile' ) );
};
if ( $wmgUseTimeline ) {
include( $IP . '/extensions/timeline/Timeline.php' );
if ( $wgDBname == 'testwiki' || $wgDBname == 'mlwiki' ) {
// FreeSansWMF has been generated from FreeSans and FreeSerif by using this script with fontforge:
// Open("FreeSans.ttf");
// MergeFonts("FreeSerif.ttf");
// SetFontNames("FreeSans-WMF", "FreeSans WMF", "FreeSans WMF Regular", "Regular", "");
// Generate("FreeSansWMF.ttf", "", 4 );
$wgTimelineSettings->fontFile = 'FreeSansWMF.ttf';
} elseif ( $lang == 'zh' ) {
$wgTimelineSettings->fontFile = 'unifont-5.1.20080907.ttf';
}
$wgTimelineSettings->fileBackend = 'local-multiwrite';
$wgTimelineSettings->ploticusCommand = '/usr/bin/ploticus';
$wgTimelineSettings->epochTimestamp = '20130601000000';
}
putenv( "GDFONTPATH=/srv/mediawiki/fonts" );
if ( $wmgUseWikiHiero ) {
include( $IP . '/extensions/wikihiero/wikihiero.php' );
}
include( $IP . '/extensions/SiteMatrix/SiteMatrix.php' );
// Config for sitematrix
$wgSiteMatrixFile = ( $wmfRealm === 'labs' ) ? "$IP/../langlist-labs" : "$IP/../langlist";
$wgSiteMatrixClosedSites = MWWikiversions::readDbListFile( 'closed' );
$wgSiteMatrixPrivateSites = MWWikiversions::readDbListFile( 'private' );
$wgSiteMatrixFishbowlSites = MWWikiversions::readDbListFile( 'fishbowl' );
if ( $wmgUseCharInsert ) {
wfLoadExtension( 'CharInsert' );
}
if ( $wmgUseParserFunctions ) {
wfLoadExtension( 'ParserFunctions' );
}
$wgExpensiveParserFunctionLimit = 500;
if ( $wmgUseCite ) {
wfLoadExtension( 'Cite' );
}
if ( $wmgUseCiteThisPage ) {
wfLoadExtension( 'CiteThisPage' );
}
if ( $wmgUseInputBox ) {
wfLoadExtension( 'InputBox' );
}
if ( $wmgUseImageMap ) {
wfLoadExtension( 'ImageMap' );
}
if ( $wmgUseGeSHi ) {
wfLoadExtension( 'SyntaxHighlight_GeSHi' );
}
if ( $wmgUseDoubleWiki ) {
wfLoadExtension( 'DoubleWiki' );
}
if ( $wmgUsePoem ) {
wfLoadExtension( 'Poem' );
}
if ( $wmgUseUnicodeConverter ) {
wfLoadExtension( 'UnicodeConverter' );
}
// Per-wiki config for Flagged Revisions
if ( $wmgUseFlaggedRevs ) {
include( "$wmfConfigDir/flaggedrevs.php" );
}
if ( $wmgUseCategoryTree ) {
require( $IP . '/extensions/CategoryTree/CategoryTree.php' );
$wgCategoryTreeCategoryPageMode = $wmgCategoryTreeCategoryPageMode;
$wgCategoryTreeCategoryPageOptions = $wmgCategoryTreeCategoryPageOptions;
}
if ( $wmgUseProofreadPage ) {
include( $IP . '/extensions/ProofreadPage/ProofreadPage.php' );
if ( $wgDBname == 'dewikisource' ) {
$wgGroupPermissions['*']['pagequality'] = true; # 27516
} elseif ( $wgDBname == 'enwikisource' || $wgDBname == 'svwikisource' ) {
$wgDefaultUserOptions['proofreadpage-showheaders'] = 1;
}
}
if ( $wmgUseLabeledSectionTransclusion ) {
include( $IP . '/extensions/LabeledSectionTransclusion/lst.php' );
}
if ( $wmgUseSpamBlacklist ) {
include( $IP . '/extensions/SpamBlacklist/SpamBlacklist.php' );
$wgBlacklistSettings = array(
'spam' => array(
'files' => array(
'https://meta.wikimedia.org/w/index.php?title=Spam_blacklist&action=raw&sb_ver=1'
),
),
);
$wgLogSpamBlacklistHits = true;
}
include( $IP . '/extensions/TitleBlacklist/TitleBlacklist.php' );
$wgTitleBlacklistBlockAutoAccountCreation = false;
if ( $wmgUseGlobalTitleBlacklist ) {
$wgTitleBlacklistSources = array(
'meta' => array(
'type' => TBLSRC_URL,
'src' => "https://meta.wikimedia.org/w/index.php?title=Title_blacklist&action=raw&tb_ver=1",
),
);
$wgTitleBlacklistUsernameSources = $wmgTitleBlacklistUsernameSources;
}
if ( $wmgUseQuiz ) {
include( "$IP/extensions/Quiz/Quiz.php" );
}
if ( $wmgUseFundraisingTranslateWorkflow ) {
include( "$IP/extensions/FundraisingTranslateWorkflow/FundraisingTranslateWorkflow.php" );
}
if ( $wmgUseGadgets ) {
include( "$IP/extensions/Gadgets/Gadgets.php" );
$wgGadgetsCacheType = CACHE_ACCEL;
$wgSpecialGadgetUsageActiveUsers = $wmgSpecialGadgetUsageActiveUsers;
}
if ( $wmgUseMwEmbedSupport ) {
require_once( "$IP/extensions/MwEmbedSupport/MwEmbedSupport.php" );
}
if ( $wmgUseTimedMediaHandler ) {
require_once( "$IP/extensions/TimedMediaHandler/TimedMediaHandler.php" );
$wgTimedTextForeignNamespaces = array( 'commonswiki' => 102 );
if ( $wgDBname == 'commonswiki' ) {
$wgTimedTextNS = 102;
}
//overwrite enabling of local TimedText namespace
$wgEnableLocalTimedText = $wmgEnableLocalTimedText;
//enable transcoding on all wikis that allow uploads
$wgEnableTranscode = $wgEnableUploads;
$wgOggThumbLocation = false; // use ffmpeg for performance
//tmh1/2 have 12 cores and need lots of shared memory
//for avconv / ffmpeg2theora
$wgTranscodeBackgroundMemoryLimit = 4 * 1024 * 1024; // 4GB
$wgFFmpegThreads = 2;
// Minimum size for an embed video player
$wgMinimumVideoPlayerSize = $wmgMinimumVideoPlayerSize;
// use new ffmpeg build w/ VP9 & Opus support
$wgFFmpegLocation = '/usr/bin/ffmpeg';
}
if ( $wmgUseUrlShortener ) {
wfLoadExtension( 'UrlShortener' );
$wgUrlShortenerTemplate = '/$1';
$wgUrlShortenerServer = 'w.wiki';
$wgUrlShortenerDBCluster = 'extension1';
$wgUrlShortenerDBName = 'wikishared';
$wgUrlShortenerDomainsWhitelist = array(
'(.*\.)?wikipedia\.org',
'(.*\.)?wiktionary\.org',
'(.*\.)?wikibooks\.org',
'(.*\.)?wikinews\.org',
'(.*\.)?wikiquote\.org',
'(.*\.)?wikisource\.org',
'(.*\.)?wikiversity\.org',
'(.*\.)?wikivoyage\.org',
'(.*\.)?wikimedia\.org',
'wikidata\.org',
);
$wgUrlShortenerApprovedDomains = array(
'*.wikipedia.org',
'*.wiktionary.org',
'*.wikibooks.org',
'*.wikinews.org',
'*.wikiquote.org',
'*.wikisource.org',
'*.wikiversity.org',
'*.wikivoyage.org',
'*.wikimedia.org',
'wikidata.org',
);
$wgUrlShortenerReadOnly = true;
}
if ( $wmgPFEnableStringFunctions ) {
$wgPFEnableStringFunctions = true;
}
if ( $wgDBname == 'mediawikiwiki' ) {
include( "$IP/extensions/ExtensionDistributor/ExtensionDistributor.php" );
$wgExtDistListFile = 'https://gerrit.wikimedia.org/mediawiki-extensions.txt';
$wgExtDistAPIConfig = array(
'class' => 'GerritExtDistProvider',
'apiUrl' => 'https://gerrit.wikimedia.org/r/projects/mediawiki%2F$TYPE%2F$EXT/branches',
'tarballUrl' => 'https://extdist.wmflabs.org/dist/$TYPE/$EXT-$REF-$SHA.tar.gz',
'tarballName' => '$EXT-$REF-$SHA.tar.gz',
'repoListUrl' => 'https://gerrit.wikimedia.org/r/projects/?p=mediawiki/$TYPE/',
);
// Current stable release
$wgExtDistDefaultSnapshot = 'REL1_26';
// When changing the Snapshot Refs please change the corresponding
// extension distributor messages for mediawiki.org in WikimediaMessages/i18n/wikimedia/*.json too
$wgExtDistSnapshotRefs = array(
'master',
'REL1_26',
'REL1_25',
'REL1_24',
'REL1_23',
'REL1_22',
'REL1_21',
'REL1_20',
'REL1_19',
);
// Use Graphite for popular list
$wgExtDistGraphiteRenderApi = 'https://graphite.wikimedia.org/render';
}
if ( $wmgUseGlobalBlocking ) {
include( $IP . '/extensions/GlobalBlocking/GlobalBlocking.php' );
$wgGlobalBlockingDatabase = 'centralauth';
$wgApplyGlobalBlocks = $wmgApplyGlobalBlocks;
$wgGlobalBlockingBlockXFF = $wmgUseXFFBlocks;
}
include( $IP . '/extensions/TrustedXFF/TrustedXFF.php' );
$wgTrustedXffFile = "$wmfConfigDir/trusted-xff.cdb";
if ( $wmgUseContactPage ) {
include( $IP . '/extensions/ContactPage/ContactPage.php' );
$wgContactConfig['default'] = array_merge( $wgContactConfig['default'], $wmgContactPageConf );
if ( $wgDBname === 'metawiki' ) {
include( "$wmfConfigDir/LegalContactPages.php" );
include( "$wmfConfigDir/AffComContactPages.php" );
}
}
if ( $wmgUseSecurePoll ) {
include( $IP . '/extensions/SecurePoll/SecurePoll.php' );
$wgSecurePollUseNamespace = $wmgSecurePollUseNamespace;
$wgSecurePollScript = 'auth-api.php';
$wgHooks['SecurePoll_JumpUrl'][] = function( $page, &$url ) {
global $site, $lang;
$url = wfAppendQuery( $url, array( 'site' => $site, 'lang' => $lang ) );
return true;
};
$wgSecurePollCreateWikiGroups = array(
'securepollglobal' => 'securepoll-dblist-securepollglobal'
);
}
// PoolCounter
if ( $wmgUsePoolCounter ) {
include( "$wmfConfigDir/PoolCounterSettings.php" );
}
if ( $wmgUseScore ) {
include( "$IP/extensions/Score/Score.php" );
$wgScoreFileBackend = $wmgScoreFileBackend;
$wgScorePath = $wmgScorePath;
}
$wgHiddenPrefs[] = 'realname';
# Default address gets rejected by some mail hosts
$wgPasswordSender = 'wiki@wikimedia.org';
# e-mailing password based on e-mail address (T36386)
$wgPasswordResetRoutes['email'] = true;
if ( $wmgUseClusterFileBackend ) {
# Cluster-dependent files for file backend
require "{$wmfConfigDir}/filebackend-{$wmfRealm}.php";
} else {
$wgUseInstantCommons = true;
}
if ( $wmgUseClusterJobqueue ) {
# Cluster-dependent files for job queue and job queue aggregator
require $wmfRealm === 'labs'
? "$wmfConfigDir/jobqueue-labs.php"
: "$wmfConfigDir/jobqueue.php";
}
if ( $wgDBname == 'nostalgiawiki' ) {
# Link back to current version from the archive funhouse
if ( ( isset( $_REQUEST['title'] ) && ( $title = $_REQUEST['title'] ) )
|| ( isset( $_SERVER['PATH_INFO'] ) && ( $title = substr( $_SERVER['PATH_INFO'], 1 ) ) ) ) {
if ( preg_match( '/^(.*)\\/Talk$/', $title, $matches ) ) {
$title = 'Talk:' . $matches[1];
}
$wgSiteNotice = "[//en.wikipedia.org/wiki/" .
htmlspecialchars( urlencode( $title ) ) .
' See the current version of this page on Wikipedia]';
} else {
$wgSiteNotice = "[//en.wikipedia.org/ See current Wikipedia]";
}
// Nostalgia skin
wfLoadSkin( 'Nostalgia' );
}
$wgFooterIcons['copyright']['copyright'] = '<a href="https://wikimediafoundation.org/">' .
'<img src="/static/images/wikimedia-button.png" ' .
'srcset="' .
'/static/images/wikimedia-button-1.5x.png 1.5x, ' .
'/static/images/wikimedia-button-2x.png 2x' .
'" ' .
'width="88" height="31" alt="Wikimedia Foundation"/></a>';
# :SEARCH:
# All wikis are special and get Cirrus :)
# Must come *AFTER* PoolCounterSettings.php
require_once( "$IP/extensions/Elastica/Elastica.php" );
require_once( "$IP/extensions/CirrusSearch/CirrusSearch.php" );
include( "$wmfConfigDir/CirrusSearch-common.php" );
// Various DB contention settings
if ( in_array( $wgDBname, array( 'testwiki', 'test2wiki', 'mediawikiwiki', 'commonswiki' ) ) ) {
$wgSiteStatsAsyncFactor = 1;
}