/
LocalSettings.php
696 lines (607 loc) · 25.2 KB
/
LocalSettings.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
<?php
/**
* This file includes core settings that are unlikely to need to change much.
* These settings should also not be needed for the localization rebuild
*/
if ( !array_key_exists( WBSTACK_INFO_GLOBAL, $GLOBALS ) ) {
// We shouldn't reach here as all entry points should create this GLOBAL..
// However if new things get introduced we will end up here, and we will need another shim!
echo 'LS.php not got wiki info.';
die(1);
}
require_once __DIR__ . '/../loadAll.php';
/** @var \WBStack\Info\WBStackInfo $wikiInfo */
$wikiInfo = $GLOBALS[WBSTACK_INFO_GLOBAL];
// Define STDERR if it is not already. This is used for logging.
if ( !defined( 'STDERR' ) ) {
define( 'STDERR', fopen( 'php://stderr', 'w' ) );
}
// Define some conditions to switch behaviour on
$wwDomainSaysLocal = preg_match("/(\w\.localhost)/", $_SERVER['SERVER_NAME']) === 1;
$wwDomainIsMaintenance = $wikiInfo->requestDomain === 'maintenance';
$wwIsPhpUnit = isset( $maintClass ) && $maintClass === 'PHPUnitMaintClass';
$wwIsLocalisationRebuild = basename( $_SERVER['SCRIPT_NAME'] ) === 'rebuildLocalisationCache.php';
$wwUseMailgunExtension = true; // default for wbstack
if (getenv('MW_MAILGUN_DISABLED') === 'yes') {
$wwUseMailgunExtension = false;
}
#######################################
## --- Base MediaWiki Settings --- ##
#######################################
// No error output or debugging in production
ini_set( 'display_errors', 0 );
$wgShowExceptionDetails = false;
if( $wwDomainIsMaintenance || $wwIsPhpUnit || $wwIsLocalisationRebuild || $wwDomainSaysLocal ) {
ini_set( 'display_errors', 1 );
$wgShowExceptionDetails = true;
}
// Load Logging when not in phpunit or doing l10n rebuild
if ( !$wwIsPhpUnit && !$wwIsLocalisationRebuild ) {
$wgMWLoggerDefaultSpi = [
'class' => \WBStack\Logging\CustomSpi::class,
'args' => [[
'ignoreLevels' => [
'debug',
'info',
],
'ignoreAllInGroup' => [
'DBPerformance',
'objectcache',// ideally want to show objectcache errors, but not warnings
],
'logAllInGroup' => [
'WBSTACK',
'HttpError',
'SpamBlacklistHit',
'security',
'exception-json',
//'error',
'fatal',
'badpass',
'badpass-priv',
'api-warning',
],
'logAllInGroupExceptDebug' => [
//'Wikibase',
'BlockManager',// we want info https://gerrit.wikimedia.org/g/mediawiki/core/+/916c0307a06e64b49d4b7f0340808a38b6d5b9a4/includes/block/BlockManager.php#426
],
]],
];
}
// Disable logging for local dev setup so it get's redirected to stderr and therefore can be viewed in the Kubernetes dashboard
if ( getenv('MW_LOG_TO_STDERR') === 'yes' ) {
$wgMWLoggerDefaultSpi = [
'class' => \WBStack\Logging\CustomSpi::class,
'args' => [[
'ignoreLevels' => [],
'ignoreAllInGroup' => [],
'logAllInGroup' => [],
'logAllInGroupExceptDebug' => [],
]],
];
}
if ( $wwDomainSaysLocal ) {
$wgServer = "http://" . $wikiInfo->domain;
} else {
$wgServer = "https://" . $wikiInfo->domain;
}
$wgScriptPath = "/w";
$wgArticlePath = "/wiki/$1";
$wgDBname = $wikiInfo->wiki_db->name;
$wgDBprefix = $wikiInfo->wiki_db->prefix . '_';
$wgDBTableOptions = "ENGINE=InnoDB, DEFAULT CHARSET=binary";
$wgDBservers = [
[
'host' => getenv('MW_DB_SERVER_MASTER'),
'dbname' => $wgDBname,
'user' => $wikiInfo->wiki_db->user,
'password' => $wikiInfo->wiki_db->password,
'type' => "mysql",
'flags' => DBO_DEFAULT,
'load' => 1,
],
];
// DO NOT add the replica server config if we are just running a non wiki maint script.
// For example schema generation or localization cache reload
// WBS_DOMAIN=maint php ./w/maintenance/update.php --schema sql.sql --quick
// As in these contexts there is often no replica.... and thus one would fail...
if( !$wwDomainIsMaintenance ){
$wgDBservers[] = [
'host' => getenv('MW_DB_SERVER_REPLICA'),
'dbname' => $wgDBname,
'user' => $wikiInfo->wiki_db->user,
'password' => $wikiInfo->wiki_db->password,
'type' => "mysql",
'flags' => DBO_DEFAULT,
'max lag' => 10,
'load' => 100,
];
}
// Jobs
# For now jobs will run in the requests, this obviously isn't the ideal solution and really
# there should be a job running service deployed...
# This was set to 2 as Andra experienced a backup of jobs. https://github.com/addshore/wbstack/issues/51
$wgJobRunRate = 2;
// Storage
// Compress revisions
$wgCompressRevisions = true;
// Notifications
$wgEnotifUserTalk = false;
$wgEnotifWatchlist = false;
// Files
// $wgUseImageMagick Is needed so that Score auto trims rendered musical notations
$wgUseImageMagick = true;
$wgEnableUploads = false;
$wgAllowCopyUploads = false;
$wgUseInstantCommons = false;
$wgFileExtensions = array_merge( $wgFileExtensions,
array( 'doc', 'xls', 'mpp', 'pdf', 'ppt', 'xlsx', 'jpg',
'tiff', 'odt', 'odg', 'ods', 'odp', 'svg'
)
);
//$wgFileExtensions[] = 'djvu';
$wgSitename = $wikiInfo->sitename;
// Logos
$wgLogos = [
"1x" => $wikiInfo->getSetting('wgLogo'),
];
if( $wgLogos["1x"] === null ) {
// Fallback to the mediawiki logo without the wgLogo overlay
$wgLogos = [
"1x" => "https://storage.googleapis.com/wbstack-static/assets/mediawiki/mediawiki.png",
];
}
// Favicon
$wgFavicon = $wikiInfo->getSetting('wgFavicon');
if( $wgFavicon === null ) {
// Default from install, but maybe we want to change this?
$wgFavicon = "/favicon.ico";
}
// Readonly: null, or a string message for readonly mode & reason.
// Always writable via CLI
$wgReadOnly = ( PHP_SAPI === 'cli' ) ? false : $wikiInfo->getSetting('wgReadOnly');
// https://www.mediawiki.org/wiki/Manual:$wgFooterIcons
// Add the custom powered by icons....
// TODO the Wikibase one should be in Wikibase..
$wgFooterIcons = [
"copyright" => [
"copyright" => [], // placeholder for the built in copyright icon
],
"poweredby" => [
"wbstack" => [
"src" => "https://storage.googleapis.com/wbstack-static/assets/Powered_by_WBStack_88x31.png",
"url" => "https://wbstack.com/",
"alt" => "Powered by WBStack",
],
"wikibase" => [
"src" => "https://storage.googleapis.com/wbstack-static/assets/Powered_by_Wikibase_88x31.png",
"url" => "https://wikiba.se/",
"alt" => "Powered by Wikibase",
],
"mediawiki" => [
"src" => "https://storage.googleapis.com/wbstack-static/assets/mediawiki/poweredby_mediawiki_88x31.png",
"url" => "https://www.mediawiki.org/",
"alt" => "Powered by MediaWiki",
]
],
];
// Language
// TODO this should be settings from the main platform
$wgLanguageCode = "en";
// Email
$wgEnableEmail = true;
$wgEnableUserEmail = false;
$wgAllowHTMLEmail = true;
// enable email authentication (confirmation) for this wiki
$wgEmailAuthentication = true;
// require email authentication
$wgEmailConfirmToEdit = true;
// TODO make this a real wbstack email address?
$wgEmergencyContact = "emergency.wbstack@addshore.com";
$wgPasswordSender = 'noreply@' . getenv('MW_EMAIL_DOMAIN');
$wgNoReplyAddress = 'noreply@' . getenv('MW_EMAIL_DOMAIN');
// SMTP
if (getenv('MW_SMTP_ENABLED') === 'yes') {
$wgSMTP = [
'host' => getenv('MW_SMTP_HOST'), // could also be an IP address. Where the SMTP server is located. If using SSL or TLS, add the prefix "ssl://" or "tls://".
'IDHost' => getenv('MW_EMAIL_DOMAIN'), // Generally this will be the domain name of your website (aka mywiki.org)
'port' => getenv('MW_SMTP_PORT'), // Port to use when connecting to the SMTP server
'auth' => getenv('MW_SMTP_AUTH') == "true", // Should we use SMTP authentication (true or false)
'username' => getenv('MW_SMTP_USERNAME'), // Username to use for SMTP authentication (if being used)
'password' => getenv('MW_SMTP_PASSWORD') // Password to use for SMTP authentication (if being used)
];
}
## Keys
$wgSecretKey = $wikiInfo->getSetting('wgSecretKey');
$wgAuthenticationTokenVersion = "1";
// So we are uniform, have the project namespace as Project
$wgMetaNamespace = 'Project';
// Needed so that Wikibase items appear in Special:Random and are counted as content pages.
// TODO this should be a Wikibase default behaviour?
$wgContentNamespaces[] = 120;
// TODO sort out directories and stuff...?
// $wgCacheDirectory is needed at least for the l10n rebuild
$wgCacheDirectory = '/tmp/mw-cache';
//$wgUploadDirectory = "{$IP}/images/docker/{$dockerDb}";
//$wgUploadPath = "{$wgScriptPath}/images/docker/{$dockerDb}";
//$wgTmpDirectory = "{$wgUploadDirectory}/tmp";
## Locale
/**
* The docker image only has C.UTF-8 currently.
* This is the default for https://www.mediawiki.org/wiki/Manual:$wgShellLocale for core as of 1.30
* But explicitly set it here as it is all the image has!
*/
$wgShellLocale = "C.UTF-8";
#######################################
## --- Default Permissions --- ##
#######################################
# Disallow anon editing for now
$wgGroupPermissions['*']['edit'] = false;
$wgGroupPermissions['*']['createpage'] = false;
# Stop crats from being able to interact with the platform group
$wgGroupPermissions['bureaucrat']['userrights'] = false;
$wgAddGroups['bureaucrat'][] = 'sysop';
$wgAddGroups['bureaucrat'][] = 'bureaucrat';
$wgAddGroups['bureaucrat'][] = 'bot';
$wgAddGroups['bureaucrat'][] = 'emailconfirmed';
$wgRemoveGroups['bureaucrat'][] = 'sysop';
$wgRemoveGroups['bureaucrat'][] = 'bureaucrat';
$wgRemoveGroups['bureaucrat'][] = 'bot';
$wgRemoveGroups['bureaucrat'][] = 'emailconfirmed';
# Remove the predefined interface-admin group
unset( $wgGroupPermissions['interface-admin'] );
unset( $wgRevokePermissions['interface-admin'] );
unset( $wgAddGroups['interface-admin'] );
unset( $wgRemoveGroups['interface-admin'] );
unset( $wgGroupsAddToSelf['interface-admin'] );
unset( $wgGroupsRemoveFromSelf['interface-admin'] );
# Allow crats to editsitecss
$wgGroupPermissions['bureaucrat']['editsitecss'] = true;
# Disable user CSS and JS editing for now
$wgGroupPermissions['user']['editmyusercss'] = false;
$wgGroupPermissions['user']['editmyuserjs'] = false;
# Allow emailconfirmed to skip captcha
$wgGroupPermissions['emailconfirmed']['skipcaptcha'] = true;
# Oauth
$wgGroupPermissions['sysop']['mwoauthproposeconsumer'] = true;
$wgGroupPermissions['sysop']['mwoauthmanageconsumer'] = true;
$wgGroupPermissions['sysop']['mwoauthviewprivate'] = true;
$wgGroupPermissions['sysop']['mwoauthupdateownconsumer'] = true;
$wgGroupPermissions['platform']['mwoauthproposeconsumer'] = true;
$wgGroupPermissions['platform']['mwoauthmanageconsumer'] = true;
$wgGroupPermissions['platform']['mwoauthviewprivate'] = true;
$wgGroupPermissions['platform']['mwoauthupdateownconsumer'] = true;
#######################################
## --- Skins --- ##
#######################################
wfLoadSkin( 'Vector' );
wfLoadSkin( 'Timeless' );
wfLoadSkin( 'Modern' );
wfLoadSkin( 'MinervaNeue' );
// TODO allow turning some skins on and off?
$wgDefaultSkin = $wikiInfo->getSetting('wgDefaultSkin');
if( $wgDefaultSkin === null ) {
// Fallback to vector
$wgDefaultSkin = "vector";
}
#######################################
## --- Extensions --- ##
#######################################
wfLoadExtension( 'SyntaxHighlight_GeSHi' );
wfLoadExtension( 'RevisionSlider' );
wfLoadExtension( 'TorBlock' );
wfLoadExtension( 'Nuke' );
wfLoadExtension( 'EntitySchema' );
wfLoadExtension( 'UniversalLanguageSelector' );
wfLoadExtension( 'cldr' );
# TODO load again once there is a fix for localization cache reload without DBhttps://phabricator.wikimedia.org/T237148
#wfLoadExtension( 'Gadgets' );
wfLoadExtension( 'OAuth' );
wfLoadExtension( 'JsonConfig' );
wfLoadExtension( 'Math' );
wfLoadExtension( 'Kartographer' );
wfLoadExtension( 'PageImages' );
wfLoadExtension( 'TextExtracts' );
wfLoadExtension( 'Popups' );
wfLoadExtension( 'Scribunto' );
wfLoadExtension( 'Cite' );
wfLoadExtension( 'TemplateSandbox' );
wfLoadExtension( 'WikiEditor' );
wfLoadExtension( 'CodeEditor' );
wfLoadExtension( 'CodeMirror' );
wfLoadExtension( 'SecureLinkFixer' );
wfLoadExtension( 'Echo' );
wfLoadExtension( 'Thanks' );
wfLoadExtension( 'Graph' );
wfLoadExtension( 'Poem' );
wfLoadExtension( 'TemplateData' );
wfLoadExtension( 'AdvancedSearch' );
wfLoadExtension( 'ParserFunctions' );
wfLoadExtension( 'EmbedVideo' );
wfLoadExtension( 'DeleteBatch' );
wfLoadExtension( 'MultimediaViewer' );
wfLoadExtension( 'WikiHiero' );
# ConfirmAccount (only loaded when the setting is on)
if( $wikiInfo->getSetting('wwExtEnableConfirmAccount') ) {
wfLoadExtension( 'ConfirmAccount' );
$wgMakeUserPageFromBio = false;
$wgAutoWelcomeNewUsers = false;
$wgConfirmAccountRequestFormItems = [
'UserName' => [ 'enabled' => true ],
'RealName' => [ 'enabled' => false ],
'Biography' => [ 'enabled' => false, 'minWords' => 50 ],
'AreasOfInterest' => [ 'enabled' => false ],
'CV' => [ 'enabled' => false ],
'Notes' => [ 'enabled' => true ],
'Links' => [ 'enabled' => false ],
'TermsOfService' => [ 'enabled' => false ],
];
$wgGroupPermissions['bureaucrat']['confirmaccount-notify'] = true;
$wgGroupPermissions['bureaucrat']['requestips'] = false;
$wgGroupPermissions['bureaucrat']['lookupcredentials'] = false;
$wgGroupPermissions['*']['requestips'] = false;
$wgGroupPermissions['*']['lookupcredentials'] = false;
$wgHooks['PersonalUrls'][] = 'onPersonalUrlsConfirmAccount';
function onPersonalUrlsConfirmAccount( array &$personal_urls, Title $title, SkinTemplate $skin ) {
// Add a link to Special:RequestAccount if a link exists for login
if ( isset( $personal_urls['login'] ) || isset( $personal_urls['anonlogin'] ) ) {
$personal_urls['createaccount'] = array(
'text' => wfMessage( 'requestaccount' )->text(),
'href' => SpecialPage::getTitleFor( 'RequestAccount' )->getFullURL()
);
}
return true;
}
// fix known issue for mediawiki newer than 1.35 to prevent unapproved creation
$wgGroupPermissions['*']['createaccount'] = false;
$wgGroupPermissions['bureaucrat']['createaccount'] = true;
}
# InviteSignup (only loaded when the setting is on)
if( $wikiInfo->getSetting('wwExtEnableInviteSignup') ) {
wfLoadExtension( 'InviteSignup' );
# Restrict account creation
$wgGroupPermissions['*']['createaccount'] = false;
$wgGroupPermissions['user']['createaccount'] = false;
# Allow sysops to review the queue
$wgGroupPermissions['sysop']['invitesignup'] = true;
# Suggest / add invited people to confirmed
$wgISGroups = [ 'confirmed' ];
}
# WikibaseInWikitext
wfLoadExtension( 'WikibaseInWikitext' ); // custom wbstack extension
$wgWikibaseInWikitextSparqlDefaultUi = $wgServer . '/query';
# WikibaseEdtf
wfLoadExtension( 'WikibaseEdtf' );
# ThatSrc: Only load it when manually enabled on a wiki https://github.com/wbstack/mediawiki/issues/57#issuecomment-827116895
if( $wikiInfo->getSetting('nyurikThatSrcEnable') ) {
wfLoadExtension( 'ThatSrc' );
}
# TwoColConflict
wfLoadExtension( 'TwoColConflict' );
// Enable the feature by default
$wgTwoColConflictBetaFeature = false;
# StopForumSpam
wfLoadExtension( 'StopForumSpam' );
# SpamBlacklist
wfLoadExtension( 'SpamBlacklist' );
$wgBlacklistSettings = [
'spam' => [
'files' => [
"https://meta.wikimedia.org/w/index.php?title=Spam_blacklist&action=raw&sb_ver=1",
"https://en.wikipedia.org/w/index.php?title=MediaWiki:Spam-blacklist&action=raw&sb_ver=1",
"https://raw.githubusercontent.com/wbstack/mediawiki-spam-lists/main/spam_list",
],
],
'email' => [
'files' => [
"https://raw.githubusercontent.com/wbstack/mediawiki-spam-lists/main/email_list",
],
],
];
# Check IPs at https://whatismyipaddress.com/blacklist-check if they are troublesome
$wgEnableDnsBlacklist = true;
$wgDnsBlacklistUrls =
[
'combined.abuse.ch.',
'xbl.spamhaus.org.',
'cbl.abuseat.org.',
'http.dnsbl.sorbs.net.',
'opm.tornevall.org.',
'all.s5h.net.',
'dnsbl.dronebl.org.',
];
# ConfirmEdit
wfLoadExtensions([ 'ConfirmEdit', 'ConfirmEdit/ReCaptchaNoCaptcha' ]);
$wgCaptchaClass = 'ReCaptchaNoCaptcha';
$wgReCaptchaSendRemoteIP = true;
$wgReCaptchaSiteKey = getenv('MW_RECAPTCHA_SITEKEY');
$wgReCaptchaSecretKey = getenv('MW_RECAPTCHA_SECRETKEY');
# Mailgun
if ($wwUseMailgunExtension) {
wfLoadExtension( 'Mailgun' );
$wgMailgunAPIKey = getenv('MW_MAILGUN_API_KEY');
$wgMailgunDomain = getenv('MW_MAILGUN_DOMAIN');
// Example Endpoint "https://api.mailgun.net"
$wgMailgunEndpoint = getenv('MW_MAILGUN_ENDPOINT');
}
# MobileFrontend
wfLoadExtension( 'MobileFrontend' );
$wgMFDefaultSkinClass = 'SkinMinerva';
# Score
wfLoadExtension( 'Score' );
$wgMusicalNotationEnableWikibaseDataType = true;
#######################################
## --- Wikibase --- ##
#######################################
wfLoadExtension( 'WikibaseRepository', "$IP/extensions/Wikibase/extension-repo.json" );
require_once "$IP/extensions/Wikibase/repo/ExampleSettings.php";
wfLoadExtension( 'WikibaseClient', "$IP/extensions/Wikibase/extension-client.json" );
require_once "$IP/extensions/Wikibase/client/ExampleSettings.php";
$wwWikibaseStringLengthString = $wikiInfo->getSetting('wwWikibaseStringLengthMonolingualText');
if($wwWikibaseStringLengthString) {
$wgWBRepoSettings['string-limits']['VT:string']['length'] = (int)$wwWikibaseStringLengthString;
}
$wwWikibaseStringLengthMonolingualText = $wikiInfo->getSetting('wwWikibaseStringLengthMonolingualText');
if($wwWikibaseStringLengthMonolingualText) {
$wgWBRepoSettings['string-limits']['VT:monolingualtext']['length'] = (int)$wwWikibaseStringLengthMonolingualText;
}
$wwWikibaseStringLengthMultilang = $wikiInfo->getSetting('wwWikibaseStringLengthMultilang');
if($wwWikibaseStringLengthMultilang) {
$wgWBRepoSettings['string-limits']['multilang']['length'] = (int)$wwWikibaseStringLengthMultilang;
}
$wgWBClientSettings['siteGlobalID'] = $wgDBname;
$wgWBClientSettings['repoScriptPath'] = '/w';
$wgWBClientSettings['repoArticlePath'] = '/wiki/$1';
$wgWBClientSettings['siteGroup'] = null;
$wgWBClientSettings['thisWikiIsTheRepo'] = true;
$wgWBClientSettings['repoUrl'] = $GLOBALS['wgServer'];
$wgWBClientSettings['repoSiteName'] = $GLOBALS['wgSitename'];
$localConceptBaseUri = 'https://' . $wikiInfo->domain . '/entity/';
$wgWBRepoSettings['entitySources'] = [
'local' =>
[
'entityNamespaces' =>
[
'item' => '120/main',
'property' => '122/main',
],
'repoDatabase' => false,
'baseUri' => $localConceptBaseUri,
'rdfNodeNamespacePrefix' => 'wd',
'rdfPredicateNamespacePrefix' => '',
'interwikiPrefix' => '',
],
];
$wgWBClientSettings['entitySources'] = [
'local' =>
[
'entityNamespaces' =>
[
'item' => '120/main',
'property' => '122/main',
],
'repoDatabase' => false,
'baseUri' => $localConceptBaseUri,
'rdfNodeNamespacePrefix' => 'wd',
'rdfPredicateNamespacePrefix' => '',
'interwikiPrefix' => '',
],
];
// TODO below setting will be empty by default in the future and we could remove them
$wgWBRepoSettings['siteLinkGroups'] = [];
// TODO below setting will be empty by default in the future and we could remove them
$wgWBRepoSettings['specialSiteLinkGroups'] = [];
$wgWBRepoSettings['dataRightsUrl'] = null;
$wgWBRepoSettings['dataRightsText'] = 'None yet set.';
// Until we can scale redis memory we don't want to do this - https://github.com/addshore/wbstack/issues/37
$wgWBRepoSettings['sharedCacheType'] = CACHE_NONE;
# WikibaseLexeme, By default not enabled, enabled in WikiInfo-maint.json
if( $wikiInfo->getSetting('wwExtEnableWikibaseLexeme') ) {
wfLoadExtension( 'WikibaseLexeme' );
$wgLexemeEnableDataTransclusion = true;
$wgWBRepoSettings['entitySources']['local']['entityNamespaces']['lexeme'] = '146/main';
}
# Federated Properties, By default not enabled, not enabled in maint mode
if( $wikiInfo->getSetting('wikibaseFedPropsEnable') ) {
// This will use wikidata.org by default
$wgWBRepoSettings['federatedPropertiesEnabled'] = true;
}
# Auth_remoteuser, By default not enabled, enabled in WikiInfo-maint.json
if( $wikiInfo->getSetting('wwSandboxAutoUserLogin') ) {
wfLoadExtension( 'Auth_remoteuser' );
$wgAuthRemoteuserUserName = "SandboxAdmin";
# Allow Auth_remoteuser to create missing accounts
$wgGroupPermissions['*']['autocreateaccount'] = true;
# Stop users making any additional accounts
$wgGroupPermissions['*']['createaccount'] = false;
# Allow users to act like admins, and pretend they have confirmed emails (so no captchas)
$wgAddGroups['user'][] = 'emailconfirmed';
$wgAddGroups['user'][] = 'sysop';
# Do not force people verify their email account, as they can't do that...
$wgEmailConfirmToEdit = false;
}
# WikibaseManifest
wfLoadExtension( 'WikibaseManifest' );
$wgWbManifestExternalServiceMapping = [
'queryservice_ui' => $wgServer . '/query',
'queryservice' => $wgServer . '/query/sparql',
'quickstatements' => $wgServer . '/tools/quickstatements',
];
if( $wikiInfo->getSetting('wikibaseManifestEquivEntities') ) {
$wwEquivEntities = json_decode( $wikiInfo->getSetting('wikibaseManifestEquivEntities'), true );
if ( is_array( $wwEquivEntities ) ) {
$wgWbManifestWikidataEntityMapping = $wwEquivEntities;
// Wikibase
if ( array_key_exists( 'properties', $wwEquivEntities ) && array_key_exists( 'P1630', $wwEquivEntities['properties'] ) ) {
$wgWBRepoSettings['formatterUrlProperty'] = $wwEquivEntities['properties']['P1630'];
}
if ( array_key_exists( 'properties', $wwEquivEntities ) && array_key_exists( 'P1921', $wwEquivEntities['properties'] ) ) {
$wgWBRepoSettings['canonicalUriProperty'] = $wwEquivEntities['properties']['P1921'];
}
// WikibaseLexeme
if ( array_key_exists( 'properties', $wwEquivEntities ) && array_key_exists( 'P218', $wwEquivEntities['properties'] ) ) {
$wgLexemeLanguageCodePropertyId = $wwEquivEntities['properties']['P218'];
}
}
}
// ElasticSearch extension loading
// Allow maintainance scripts to enter this for the localization cache to be built
if ( $wikiInfo->getSetting( 'wwExtEnableElasticSearch' ) ) {
wfLoadExtension( 'Elastica' );
wfLoadExtension( 'CirrusSearch' );
wfLoadExtension( 'WikibaseCirrusSearch' );
$wgWBRepoSettings['searchIndexTypes'] = [
'string', 'external-id', 'url', 'wikibase-item', 'wikibase-property'
];
// If Wikibase Lexemes are enabled, enable lexeme cirrus search
if ( $wikiInfo->getSetting('wwExtEnableWikibaseLexeme') ) {
wfLoadExtension('WikibaseLexemeCirrusSearch');
$wgLexemeUseCirrus = true;
// So that Lexemes are indexed in the content index
$wgContentNamespaces[] = 146;
// Add lexeme searchIndexTypes
$wgWBRepoSettings['searchIndexTypes'][] = 'wikibase-lexeme';
$wgWBRepoSettings['searchIndexTypes'][] = 'wikibase-form';
$wgWBRepoSettings['searchIndexTypes'][] = 'wikibase-sense';
}
// prepends indices with database name
$wgCirrusSearchIndexBaseName = $wgDBname;
$wgSearchType = 'CirrusSearch';
$wgCirrusSearchDefaultCluster = 'default';
// T308115
$wgCirrusSearchShardCount = [ 'content' => 1, 'general' => 1 ];
// T309379
$wgCirrusSearchEnableArchive = false;
$wgCirrusSearchPrivateClusters = [ 'non-existing-cluster' ];
$wgCirrusSearchClusters = [
'default' => [
[ 'host' => getenv('MW_ELASTICSEARCH_HOST'), 'port' => getenv('MW_ELASTICSEARCH_PORT') ],
]
];
$wgWBCSUseCirrus = true;
}
#######################################
## --- l10n rebuild and beyond --- ##
#######################################
// Skip some things when in l10n rebuild, as they complicate things.
// TODO perhaps change this so that the rebuildLocalisationCache.php passes in an ENV var to block loading the extra settings instead of detecting?
// Disable any chance of localization cache updates during web requests
$wgLocalisationCacheConf['manualRecache'] = true;
// $wgCacheDirectory setting must also be valid for the l10n cache to land on disk
if( !$wwIsLocalisationRebuild ) {
// Only load cache settings (redis db etc) when not doing a l10n rebuild
require_once __DIR__ . '/ProductionCache.php';
// If we have internal settings, and have been told to load them, then load them...
if( getenv('WBSTACK_LOAD_MW_INTERNAL') === 'yes' && file_exists( __DIR__ . '/../loadInternal.php' ) ) {
require_once __DIR__ . '/../loadInternal.php';
} else {
// Code for ONLY the public mw services
$wgReservedUsernames = array_merge(
$wgReservedUsernames,
[
// TODO should this be a constant
'PlatformReservedUser',
]
);
}
}
require_once __DIR__ . '/Hooks.php';