Debian Codegraph @

includes/DevelopmentSettings.php

raw symbols SCIP
1 <?php
2 /**
3 * Extra settings useful for MediaWiki development.
4 *
5 * To enable built-in debug and development settings, add the
6 * following to your LocalSettings.php file.
7 *
8 * require "$IP/includes/DevelopmentSettings.php";
9 *
10 * @file
11 */
12
13 use Wikimedia\FileBackend\FSFile\TempFSFile;
14
15 /**
16 * Ad-hoc debugging
17 *
18 * To keep your Git copy clean and easier to work with, it is recommended
19 * to copy this to your LocalSettings.php and enable them as-needed.
20 * These are not enabled by default as they make the wiki considerably
21 * slower and/or significantly alter how things work or look.
22 *
23 * See https://www.mediawiki.org/wiki/How_to_debug
24 */
25
26 // $wgDebugDumpSql = true;
27 // $wgDebugRawPage = true;
28 // $wgDebugToolbar = true;
29
30 /**
31 * Debugging for PHP
32 */
33
34 // Enable logging of all errors
35 error_reporting( -1 );
36
37 // Enable showing of errors, but avoid breaking non-HTML responses
38 if ( MW_ENTRY_POINT === 'index' ) {
39 ini_set( 'display_errors', '1' );
40 }
41
42 /**
43 * Debugging for MediaWiki
44 */
45
46 global $wgDevelopmentWarnings, $wgShowExceptionDetails, $wgShowHostnames,
47 $wgDebugLogFile,
48 $wgDBerrorLog, $wgDebugLogGroups;
49
50 // Use of wfWarn() should cause tests to fail
51 $wgDevelopmentWarnings = true;
52
53 // Enable showing of errors
54 $wgShowExceptionDetails = true;
55 $wgShowHostnames = true;
56
57 // Enable log files
58 $logDir = getenv( 'MW_LOG_DIR' );
59 if ( $logDir ) {
60 if ( !file_exists( $logDir ) ) {
61 mkdir( $logDir );
62 }
63 $logFileNames = [
64 'debug-cli' => 'mw-debug-cli',
65 'debug-web' => 'mw-debug-web',
66 'db' => 'mw-dberror',
67 'ratelimit' => 'mw-ratelimit',
68 'error' => 'mw-error',
69 ];
70 // For PHPUnit tests run in parallel via ComposerLaunchParallel,
71 // there will be an environment variable containing the group ID
72 // of the batch of tests being run in a process. Use this to group
73 // those logs together.
74 $splitGroupLogId = getenv( 'MW_PHPUNIT_SPLIT_GROUP_ID' );
75
76 foreach ( $logFileNames as $key => $logFileName ) {
77 if ( $splitGroupLogId ) {
78 $logFileNames[$key] = "$logDir/$logFileName.split-group-$splitGroupLogId.log";
79 } else {
80 $logFileNames[$key] = "$logDir/$logFileName.log";
81 }
82 }
83
84 if ( MW_ENTRY_POINT === 'cli' ) {
85 $wgDebugLogFile = $logFileNames['debug-cli'];
86 } else {
87 $wgDebugLogFile = $logFileNames['debug-web'];
88 }
89 $wgDBerrorLog = $logFileNames['db'];
90 $wgDebugLogGroups['ratelimit'] = $logFileNames['ratelimit'];
91 $wgDebugLogGroups['error'] = $logFileNames['error'];
92 $wgDebugLogGroups['exception'] = $logFileNames['error'];
93 }
94 unset( $logDir );
95
96 /**
97 * Make testing possible (or easier)
98 */
99
100 global $wgRateLimits, $wgEnableJavaScriptTest, $wgRestAPIAdditionalRouteFiles,
101 $wgPasswordAttemptThrottle, $wgForceDeferredUpdatesPreSend,
102 $wgParsoidSettings, $wgMaxArticleSize;
103
104 // Set almost infinite rate limits. This allows integration tests to run unthrottled
105 // in CI and for devs locally (T225796), but doesn't turn a large chunk of production
106 // code completely off during testing (T284804)
107 foreach ( $wgRateLimits as $right => &$limit ) {
108 foreach ( $limit as $group => &$groupLimit ) {
109 $groupLimit[0] = PHP_INT_MAX;
110 }
111 }
112
113 // Enable Special:JavaScriptTest and allow `npm run qunit` to work
114 // https://www.mediawiki.org/wiki/Manual:JavaScript_unit_testing
115 $wgEnableJavaScriptTest = true;
116
117 // Enable development/experimental endpoints
118 $wgRestAPIAdditionalRouteFiles[] = 'includes/Rest/coreDevelopmentRoutes.json';
119 $wgRestAPIAdditionalRouteFiles[] = 'includes/Rest/content.v1.json';
120 $wgRestAPIAdditionalRouteFiles[] = 'includes/Rest/specs.v0.json';
121
122 // Greatly raise the limits on short/long term login attempts,
123 // so that automated tests run in parallel don't error.
124 $wgPasswordAttemptThrottle = [
125 [ 'count' => 1000, 'seconds' => 300 ],
126 [ 'count' => 100000, 'seconds' => 60 * 60 * 48 ],
127 ];
128
129 // Run deferred updates before sending a response to the client.
130 // This ensures that in end-to-end tests, a GET request will see the
131 // effect of all previous POST requests (T230211).
132 // Caveat: this does not wait for jobs to be executed, and it does
133 // not wait for database replication to complete.
134 $wgForceDeferredUpdatesPreSend = true;
135
136 // Set size limits for parsing small enough so we can test them,
137 // but not so small that they interfere with other tests.
138 $wgMaxArticleSize = 20; // in Kilobyte
139 $wgParsoidSettings['wt2htmlLimits']['wikitextSize'] = 20 * 1024; // $wgMaxArticleSize, in byte
140 $wgParsoidSettings['html2wtLimits']['htmlSize'] = 100 * 1024; // in characters!
141
142 // Enable Vue dev mode by default, so that Vue devtools are functional.
143 $wgVueDevelopmentMode = true;
144
145 // Disable rate limiting of temp account creation and temp account name
146 // acquisition, to facilitate local development and testing
147 $wgTempAccountCreationThrottle = [];
148 $wgTempAccountNameAcquisitionThrottle = [];
149
150 /**
151 * Experimental changes that may later become the default.
152 * (Must reference a Phabricator ticket)
153 */
154
155 global $wgSQLMode, $wgDBStrictWarnings, $wgLocalisationCacheConf, $wgCiteBookReferencing,
156 $wgCacheDirectory, $wgEnableUploads, $wgUsePigLatinVariant,
157 $wgVisualEditorEnableWikitext, $wgDefaultUserOptions, $wgAutoCreateTempUser;
158
159 // Enable MariaDB/MySQL strict mode (T108255)
160 $wgSQLMode = 'STRICT_ALL_TABLES,ONLY_FULL_GROUP_BY';
161 $wgDBStrictWarnings = true;
162
163 // Localisation Cache to StaticArray (T218207)
164 $wgLocalisationCacheConf['store'] = 'array';
165
166 // Experimental Book Referencing feature (T236255)
167 $wgCiteBookReferencing = true;
168
169 // The default value is false, but for development it is useful to set this to the system temp
170 // directory by default (T218207)
171 $wgCacheDirectory = TempFSFile::getUsableTempDirectory() .
172 DIRECTORY_SEPARATOR .
173 rawurlencode( MediaWiki\WikiMap\WikiMap::getCurrentWikiId() );
174
175 // Enable uploads for FileImporter browser tests (T190829)
176 $wgEnableUploads = true;
177
178 // Enable en-x-piglatin variant conversion for testing
179 $wgUsePigLatinVariant = true;
180 // Enable x-xss language code for testing correct message escaping
181 $wgUseXssLanguage = true;
182
183 // Enable the new wikitext mode for browser testing (T270240)
184 $wgVisualEditorEnableWikitext = true;
185 // Currently the default, but repeated here for safety since it would break many source editor tests.
186 $wgDefaultUserOptions['visualeditor-newwikitext'] = 0;
187
188 // Enable creation of temp user accounts on edit (T355880, T359043)
189 $wgAutoCreateTempUser['enabled'] = true;