forked from Wikia/app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLocalSettings.php
397 lines (344 loc) · 12.9 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
<?php
/**
* IP stands for Installation Path, the top folder of MediaWiki codebase.
*/
$IP = __DIR__;
/**
* Register some $IP subdirectories in include_path to speed up imports with
* relative paths.
*/
ini_set( 'include_path', "$IP:$IP/includes:$IP/languages:$IP/lib/vendor:.:" );
/**
* FANDOM-specific constants.
*/
require "$IP/includes/wikia/Defines.php";
/**
* This is used by some maintenance scripts that execute other maintenance
* scripts and need to point them to the right LocalSettings.php.
* @deprecated Maintenance scripts must not require --conf
* @var string $wgWikiaLocalSettingsPath
*/
$wgWikiaLocalSettingsPath = __FILE__;
/**
* Runtime datacenter discovered from the environment variable.
* @deprecated Code portability: do not add more dc-specific code.
* @var string $wgWikiaDatacenter
*/
$wgWikiaDatacenter = getenv( 'WIKIA_DATACENTER' );
if ( empty( $wgWikiaDatacenter ) ) {
throw new RuntimeException( 'Datacenter not configured in WIKIA_DATACENTER env variable.' );
}
/**
* Runtime environment discovered from the environment variable.
* @deprecated Code portability: do not add more environment-specific code.
* @see https://github.com/Wikia/chef-repo/blob/master/cookbooks/common/attributes/default.rb
* @var string $wgWikiaEnvironment
*/
$wgWikiaEnvironment = getenv( 'WIKIA_ENVIRONMENT' );
// CONFIG_REVISION: remove $wgWikiaDatacenter and $wgWikiaEnvironment from the global scope and only use it to load configuration
if ( empty( $wgWikiaEnvironment ) ) {
throw new RuntimeException( 'Environment not configured in WIKIA_ENVIRONMENT env variable.' );
}
/**
* Temporary variable for Kubernetes migration
* If {@code true}, then logs will be sent to the configured socket address formatted as JSON, instead of using syslog.
*/
$wgLoggerLogToSocketOnly = $_ENV['LOG_SOCKET_ONLY'] ?? false;
$wgLoggerSocketAddress = $_ENV['LOG_SOCKET_ADDRESS'] ?? 'tcp://127.0.0.1:9999';
/* if {@code true}, then logs will be sent to STDOUT, overrides LOG_SOCKET_ONLY */
$wgLoggerLogToStdOutOnly = $_ENV['LOG_STDOUT_ONLY'] ?? false;
/**
* Name of the Kubernetes deployment, defined if the application is running in k8s.
* @var string|null $wgKubernetesDeploymentName
*/
$wgKubernetesDeploymentName = getenv( 'KUBERNETES_DEPLOYMENT_NAME' );
/**
* Kubernetes namespace name, defined if the application is running in k8s.
* @var string|null $wgKubernetesNamespace
*/
$wgKubernetesNamespace = getenv( 'KUBERNETES_NAMESPACE' );
/**
* Proxy to use for CURL requests.
* @see PLATFORM-1745
* @see includes/wikia/CurlMultiClient.php
* @see includes/HttpFunctions.php
* @var string $wgHTTPProxy
*/
if ( !empty( $wgKubernetesDeploymentName ) ) {
// SUS-5499: Use internal host name for MW->MW requests when running on Kubernetes
$wgHTTPProxy = "$wgKubernetesDeploymentName.$wgKubernetesNamespace:80";
}
else {
// SUS-5675 | TODO: remove when we switch fully to Kubernetes
$wgHTTPProxy = 'prod.border.service.consul:80';
}
/**
* Whether to use Kubernetes internal ingress for making requests to service dependencies on Kubernetes.
* This is only enabled if app itself is running on Kubernetes.
* @var bool $wgUseKubernetesInternalIngress
*/
$wgUseKubernetesInternalIngress = (bool) getenv( 'KUBERNETES_POD' );
/**
* Some environments share components (e.g. preview, verify, sandbox and stable
* use prod databases). This variable represents that.
* @var string $wgRealEnvironment
*/
$wgRealEnvironment = $wgWikiaEnvironment;
/**
* Indicate the runtime environment as dev.
* @deprecated Code portability: do not add more environment-specific code.
* @var bool $wgDevelEnvironment
*/
$wgDevelEnvironment = ( $wgWikiaEnvironment == WIKIA_ENV_DEV );
/**
* Create a site configuration object. Not used for much in a default install.
* @see includes/SiteConfiguration.php
* @var SiteConfiguration $wgConf
*/
$wgConf = new SiteConfiguration;
/**
* URL of the server, containing scheme and host. This is usually detected
* correctly by MediaWiki based on information from $_SERVER. If MediaWiki
* detects the wrong server, it will redirect incorrectly after you save a page.
* In that case, set this variable to fix it. If you want to use
* protocol-relative URLs on your wiki, set this to a protocol-relative URL like
* '//example.com' and set $wgCanonicalServer to a fully qualified URL.
* @example $wgServer = 'http://example.com';
* @var string $wgServer
*/
$wgServer = WebRequest::detectServer();
/**
* Whether to support URLs like index.php/Page_title These often break when PHP
* is set up in CGI mode. PATH_INFO *may* be correct if cgi.fix_pathinfo is set,
* but then again it may not; lighttpd converts incoming path data to lowercase
* on systems with case-insensitive filesystems, and there have been reports of
* problems on Apache as well. To be safe we'll continue to keep it off by
* default. Override this to false if $_SERVER['PATH_INFO'] contains
* unexpectedly incorrect garbage, or to true if it is really correct. The
* default $wgArticlePath will be set based on this value at runtime, but if
* you have customized it, having this incorrectly set to true can cause
* redirect loops when "pretty URLs" are used.
* @var bool $wgUsePathInfo
*/
$wgUsePathInfo = ( strpos(php_sapi_name(), 'cgi') === false ) &&
( strpos(php_sapi_name(), 'apache2filter') === false ) &&
( strpos(php_sapi_name(), 'isapi') === false );
/**
* Show EXIF data, on by default if available. Requires PHP's EXIF extension.
* @see http://www.php.net/manual/en/ref.exif.php
* @see includes/media
* @see includes/ImagePage.php
* @var boolean $wgShowEXIF
*/
$wgShowEXIF = function_exists( 'exif_read_data' );
/**
* Use Tidy from PHP extension ("internal") rather than external binary.
* @see $wgUseTidy
* @var bool $wgTidyInternal
*/
$wgTidyInternal = extension_loaded( 'tidy' );
/**
* Set $wgCommandLineMode if it's not set already, to avoid notices
*/
if (!isset($wgCommandLineMode)) {
// TODO:log those as suspicious cases
// is wikia logger here?
$wgCommandLineMode = false;
}
/**
* Global list of hooks.
* Add a hook by doing:
* $wgHooks['event_name'][] = $function;
* or:
* $wgHooks['event_name'][] = array($function, $data);
* or:
* $wgHooks['event_name'][] = array($object, 'method');
* or:
* Hooks::register($name, $callback);
*/
$wgHooks = &Hooks::getHandlersArray();
/**
* Timeout for HTTP requests done internally
*
* Let's use different values when running a maintenance script (that includes Wikia Tasks)
* and when serving HTTP request
*
* @see PLATFORM-2385
* @see includes/HttpFunctions.php
* @var int $wgHTTPTimeout
*/
$wgHTTPTimeout = ( $wgCommandLineMode ) ? 25 : 5; # Wikia change
/**
* If true, will send MemCached debugging information to $wgDebugLogFile.
* @see $wgDebugLogFile
* @see includes/cache/wikia/LibmemcachedBagOStuff.php
* @see includes/cache/MemcachedSessions.php
* @see includes/objectcache/MemcachedPhpBagOStuff.php
* @var bool $wgMemCachedDebug
*/
$wgMemCachedDebug = ! $wgCommandLineMode; // true unless in command line mode
/**
* Elementary variables.
*/
require_once "$IP/includes/wikia/VariablesBase.php";
/**
* Access credentials from private repository.
*/
require_once "$IP/../config/secrets.php";
/**
* Variable expansions.
*/
require_once "$IP/includes/wikia/VariablesExpansions.php";
/**
* FANDOM-specific general settings.
*/
require_once "$IP/includes/wikia/DefaultSettings.php";
/**
* @see BAC-1235
*/
if ( !empty( $maintClass ) && $maintClass == 'RebuildLocalisationCache' ) {
$wgLocalisationCacheConf['manualRecache'] = false;
}
/**
* A collection of general-purpose functions, wf*() family.
*/
require_once "$IP/includes/GlobalFunctions.php";
require_once "$IP/includes/wikia/GlobalFunctions.php";
/**
* Manipulate IEUrlExtension::areServerVarsBad() to work well with our Apache
* mod_rewrite rules.
* @see IEUrlExtension::areServerVarsBad()
* @see includes/WebRequest.php
*/
unset( $_SERVER[ 'SERVER_SOFTWARE' ] );
/**
* The file is generated by deploy tools upon release. It sets $wgStyleVersion
* to proper value.
* @see $wgStyleVersion
*/
require_once "$IP/wgStyleVersion.php";
/**
* Set domains that should be considered local ones.
* @see $wgConf
* @see includes/HttpFunctions.php
*/
$wgConf->localVHosts = array_merge(
$wgWikiFactoryDomains,
[
$wgWikiaBaseDomain,
'uncyclopedia.org',
'memory-alpha.org',
'wowwiki.com',
]
);
/**
* Load environment-specific settings.
* @see https://github.com/Wikia/chef-repo/blob/master/cookbooks/common/attributes/default.rb
* @see $wgWikiaEnvironment
*/
require_once "$IP/../config/$wgWikiaEnvironment.php";
/**
* Example read-only settings.
* @see $wgLBFactoryConf
* @see includes/db/LBFactory.php
* @see includes/api/wikia/ApiFetchBlob.php
*/
// $wgLBFactoryConf['readOnlyBySection']['DEFAULT'] = 'We apologise, the site is temporarily in read-only state';
// $wgLBFactoryConf['readOnlyBySection']['central'] = 'We apologise, this wiki is temporarily in read-only state';
// $wgLBFactoryConf['readOnlyBySection']['semanticdb'] = 'We apologise, this wiki will be in read-only state till about 15:00 UTC';
// $wgLBFactoryConf['readOnlyBySection']['c4'] = 'We apologise, this wiki is temporarily in read-only state';
// $wgReadOnly = 'We apologize, database maintenance in progress. Editing is locked while we update our system.';
// $wgLBFactoryConf['readOnlyBySection']['mail'] = 'We apologize, database maintenance in progress.';
// $wgLBFactoryConf['readOnlyBySection']['specials'] = 'We apologize, specials database maintenance in progress.';
/**
* Calculate configuration for SwiftFileBackend.
* @see includes/filerepo/backend/SwiftFileBackend.php
* @var Array $wgFSSwiftServer
* @var Array $wgFSSwiftConfig
*/
$wgFSSwiftServer = $wgFSSwiftDC[$wgWikiaDatacenter]['server'];
$wgFSSwiftConfig = $wgFSSwiftDC[$wgWikiaDatacenter]['config'];
/**
* The URL path of the skins directory. Will default to "{$wgScriptPath}/skins"
* in Setup.php.
*/
$wgStylePath = "$wgResourceBasePath/skins";
/**
*
*/
$wgExtensionsPath = "$wgResourceBasePath/extensions";
/**
* Declare permission settings.
*/
require "$IP/lib/Wikia/src/Service/User/Permissions/data/PermissionsDefinesBeforeWikiFactory.php";
/**
* In some cases $wgMemc is still null at this point. Let's initialize it.
* It is needed for loading WikiFactory variables, as that code relies on WikiDataAccess which uses memcache
*/
$wgMemc = wfGetMainCache();
/**
* Apply WikiFactory settings.
*/
try {
$oWiki = new WikiFactoryLoader( $_SERVER, $_ENV, $wgWikiFactoryDomains );
$result = $oWiki->execute();
if ( !$result ) {
// wiki does not exist, is a redirect etc. — WikiFactoryLoader has already handled the case internally
// we can stop processing the request here
exit( 0 );
}
$wgCityId = $result;
// we do not need the loader and the result in the global scope.
unset( $oWiki, $result );
} catch ( InvalidArgumentException $invalidArgumentException ) {
echo $invalidArgumentException->getMessage() . PHP_EOL;
exit( 1 );
}
/**
* Disabled wikis do not have $wgDBcluster set at this point. We need to skip
* this check to allow update.php and other maintenance scripts to process
* those wikis.
* @see SUS-3589
* @see maintenance/update.php
*/
if ( is_string( $wgDBcluster ) && WikiFactoryLoader::checkPerClusterReadOnlyFlag( $wgDBcluster ) ) {
$wgReadOnly = WikiFactoryLoader::PER_CLUSTER_READ_ONLY_MODE_REASON;
}
/**
* Discard permission settings made by WikiFactory and extensions setups.
*/
require "$IP/lib/Wikia/src/Service/User/Permissions/data/PermissionsDefinesAfterWikiFactory.php";
// The above has originally been loaded before the statement below. Yet, the
// old comment brings confusion:
//
// this has to be fired after extensions - because any extension may add some
// new permissions (initialized with their default values)
if ( !empty( $wgGroupPermissionsLocal ) ) {
WikiFactoryLoader::LocalToGlobalPermissions( $wgGroupPermissionsLocal );
}
/**
* User attributes that show up on the Special:Preferences page.
* @see $wgPublicUserAttributes
* @see $wgPrivateUserAttributes
* @see includes/Preferences.php
* @var Array $wgUserAttributeWhitelist
*/
$wgUserAttributeWhitelist = array_merge( $wgPublicUserAttributes, $wgPrivateUserAttributes );
require_once "$IP/includes/wikia/Emergency.php";
if ( $wgDevelEnvironment && empty( $wgRunningUnitTests ) ) {
$wgDevBoxSettings = sprintf( '%s/../config/%s.php', $IP, gethostname() );
if ( file_exists( $wgDevBoxSettings ) ) {
require_once( $wgDevBoxSettings );
}
unset( $wgDevBoxSettings );
}
// No profiler configuration has been supplied but profiling has been explicitly requested
if ( !empty( $_GET['forceprofile'] ) && Profiler::instance() instanceof ProfilerStub ) {
Profiler::replaceStubInstance( new ProfilerXhprof( [
'flags' => TIDEWAYS_FLAGS_NO_BUILTINS | TIDEWAYS_FLAGS_CPU,
'threshold' => $wgProfileLimit,
'output' => [ 'text' ],
'visible' => isset( $_GET['showprofile'] ),
] ) );
}
require_once "$IP/includes/wikia/Extensions.php";