Commit graph

624 commits

Author SHA1 Message Date
C. Scott Ananian
f2e0516934 Include BCP 47 codes in $wgDummyLanguageCodes, but deprecate it
Add BCP 47 codes to $wgDummyLanguageCodes to ensure that
Language::factory() will return a valid MediaWiki-internal code if
given a BCP 47 alias.  We will want to make $wgDummyLanguageCodes a
private property of LanguageCode eventually, but let's start with
removing it from user configuration.

Setting $wgDummyLanguageCodes in LocalSettings.php has been deprecated
since 1.29.  Hard deprecate adding entries to $wgDummyLanguageCodes so
that we can eventually remove manual overrides from user
configuration.

This is a follow-up to 48ab87d0a3,
which described the various categories of codes, and
21ead7a98d, which added the correct
BCP 47 mappings.

Bug: T207433
Change-Id: I9f6dda3360f79ab65f6392f44c98926588d851c8
2018-10-19 14:31:21 -04:00
Brad Jorsch
4d74c8bf74 Fix Setup.php file-scope test
Way back in r8196, a test was added to assert that Setup.php is being
included at file scope.[1] That test was broken when I633a6ff23 moved the
inclusion of DefaultSettings.php into Setup.php itself.

This fixes the test by having it directly set a variable and see if that
variable is a global. Yes, there's several ways to bypass it, but we're
just trying to avoid accidents here rather than trying to be foolproof.

[1]: Or really, in the same scope as DefaultSettings.php. But it
intended to be checking for file scope.

Change-Id: I9b5f15bf01c2903e8d44d85c54465d90c047cb51
2018-10-04 16:40:15 -04:00
Timo Tijhof
ebec274f17 Remove support for StartProfiler.php
Bug: T201782
Bug: T189966
Change-Id: I6ef5af969b1d74a04d5d89370e6ac800c20be1ad
2018-08-26 02:09:44 +00:00
Kunal Mehta
49efdca8f5 Deprecate wfGetCache() and wfGetMainCache()
The former is already a wrapper around ObjectCache::getInstance().

The latter was identical to ObjectCache::getLocalClusterInstance().

Bug: T115890
Change-Id: Ib4e43bc8d3f4ac9f7a453e36dcce9b3d962666ba
2018-08-17 17:56:21 +00:00
Kunal Mehta
3f47d6df57 Deprecate $wgParser
Bug: T160811
Change-Id: I7bcf4bbd14268ec069d97848c016e0098eaf0be4
2018-08-17 10:51:52 -07:00
Aryeh Gregor
1e079652e0 Introduce ContentLanguage service to replace $wgContLang
Bug: T200246
Depends-On: I31c2e20fc70ba3cbc124b9f462f4924a139dd9bd
Depends-On: I4aaf1c641ec6abef214eb96c0e4b42a67488ac00
Depends-On: I461cf2f441a4040bb15d6c4bb93ce6114c143845
Depends-On: I4b1cc4257348d1773fd2ccf045966261f801e7d0
Depends-On: I9790b7efdd484366dc36eb8880778aea1a559e5e
Change-Id: I193f5b9a95430b0a05573c361715e053e5411e32
2018-07-31 21:42:53 -07:00
Timo Tijhof
50386d4325 Clean up docs around $wgUseSharedUploads
* Remove references to these old configuration variables
  from documentation. Rather than wgLocalFileRepo referring to
  these for more information, move the docs there, and point
  there from the old variables.

* Move all their declarations in DefaultSettings.php together,
  and be in the same order as used in Setup.php.

* Add missing @var type and @since version docs.

Bug: T25122
Change-Id: I4eb9490ed4e978b2c3954de0593a9d0d3c5fe73c
2018-07-13 18:22:44 -07:00
Fomafix
e1630b6a53 PHP: Use short ternary operator (?:) where possible
Change-Id: Idcc7e4fcdd4d8302ceda44bf6d294fa8c2219381
2018-06-11 11:26:35 +02:00
jenkins-bot
390d35a1af Merge "rdbms: include client ID hash in ChronologyProtector cookies" 2018-06-04 22:08:22 +00:00
jenkins-bot
369b34f0ae Merge "Record a log entry on page creation" 2018-06-03 07:43:35 +00:00
Aaron Schulz
fb51330084 rdbms: include client ID hash in ChronologyProtector cookies
Previously, if an internal service forwarded the cookies for a
user (e.g. for permissions) but not the User-Agent header or not
the IP address (e.g. XFF), ChronologyProtector could timeout
waiting for a matching writeIndex to appear for the wrong key.

The cookie now tethers the client to the key that holds the
DB positions from their last state-changing request.

Bug: T194403
Bug: T190082
Change-Id: I84f2cbea82532d911cdfed14644008894498813a
2018-06-02 03:57:30 +00:00
Timo Tijhof
a930bf7d7b Remove deprecated global $parserMemc and wfGetParserCacheStorage
Deprecated since 1.30, no longer used in core, bundled components,
and WMF-deployed extensions.

Change-Id: I09715f94750f083712719ef599a2ea4260297681
2018-05-31 14:28:42 +01:00
kaldari
9c387f5036 Record a log entry on page creation
This is controlled by a new config variable, $wgPageCreationLog,
which is set to false by default.

Bug: T12331
Change-Id: Ie3f6cc5ece0134433d5e4a572ea5eb0c3b700b8c
2018-05-29 09:10:40 -07:00
Kunal Mehta
88ea69f2f7 Remove deprecated utfnormal back-compat
Change-Id: Id8f497d0bbaab8282057c9d271a7c9b1e77d1a3f
2018-05-27 20:35:27 -07:00
Timo Tijhof
1796d99f70 Setup: Remove various Profile sections
Before:
- Setup.php
- - Setup.php-defaults
- - Setup.php-validation
- - Setup.php-defaults2
- - Setup.php-misc1
- - Setup.php-memcached
- - Setup.php-globals
- - - Setup.php-session
- - Setup.php-extensions
- - - Setup.php-extensions-{extensionName}
- - - Setup.php-autocreate

After:
- Setup.php
- - Setup.php-defaults
- - Setup.php-defaults2
- - Setup.php-misc
- - Setup.php-globals
- - Setup.php-extensions

The removed sections are mainly things were essentially sections
consisting of one invocation, which profilers already track
natively.

Bug: T189966
Change-Id: I1ed648cdcca9e5a9ea7013394381eacd67f327a3
2018-05-22 22:23:39 +00:00
Aaron Schulz
52af356cad Avoid unnecessary WaitConditionLoop delays in ChronologyProtector
Since it takes time for the agent to get the response and set the
cookie and, as well, the time into a request that a LoadBalancer is
initialized varies by many seconds (cookies loaded from the start),
give the cookie a much lower TTL than the DB positions in the stash.

This avoids having to wait for a position with a given cpPosIndex
value, when the position already expired from the store, which is
a waste of time.

Also include the timestamp in "cpPosIndex" cookies to implement
logical expiration in case clients do not expire them correctly.

Bug: T194403
Bug: T190082
Change-Id: I97d8f108dec59c5ccead66432a097cda8ef4a178
2018-05-18 13:43:05 -07:00
James D. Forrester
846f4f58f5 Remove $wgExperimentalHtmlIds and related code, deprecated in 1.30
Bug: T139744
Change-Id: Ia15d5ab6e7637fd40d5c3399822a3dbeb7b383b5
2018-05-01 14:34:02 -07:00
James D. Forrester
de6dab71e3 Remove $wgScriptExtension (deprecated and ignored since 1.25)
* Remove left-over mention of the .php5 entry points in docs.

* Remove dead logic in NoLocalSettings for php5 entry points.

* Remove dead match in WebRequest for php5 entry points (they'd
  redirect since 1.25, and not seen by PHP).

Change-Id: Ia0ee8588591860b8fe34030c8503f38e9bce31f3
2018-04-19 01:11:23 +01:00
Timo Tijhof
5c94aed0c3 Setup: Move mbstring.func_overload from WebStart to Setup
Follows-up 26c2d03c17, 41d1fa1c3a and r11547 (c7f363f886).

Also add references to the relevant tasks about why the check
exists.

Bug: T189966
Change-Id: Ic1f0c79a1b5638bb30351a0cab55699931d1fded
2018-04-17 23:09:58 +01:00
Timo Tijhof
7efb7f357e RELEASE-NOTES: Add note for StartProfiler deprecation
Follows-up 5209adff6c which just missed the 1.31 boat.

Change-Id: Ia7501e07ccd6498c24ff02f407be1c39414ab97e
2018-04-17 22:29:36 +01:00
Timo Tijhof
5209adff6c Setup: Deprecate StartProfiler, move default to DefaultSettings
$wgProfiler was introduced in 3ea576aa25 (r15605; 2006; MW 1.8).
The global was used from the Profiler.php class file, which
would be manually from StartProfiler.php, which then (if enabled)
assigned the global an actual instance of the Profiler class.

We needed it that way because we actually instantiated and used
the Profiler object (via wfProfileIn) very early on in WebStart.
Specifically, before any settings and classes load.

This first changed in 5a6d1ee2d3 (r86228; 2011; MW 1.17).
That commit deprecated use of $wgProfiler as an object in favour
of assigning it an array that MediaWiki would use to construct
the class. Profiling methods were also changed to lazy-instantiate
the class, which would first happen via a wfProfileIn() call two
lines before loading DefaultSettings and LocalSettings.

Some more relevant clean up happened in a0123d0549 (r89206; 2011).

Now, in 2018, we don't actually lazy-instantiate the Profiler
until after DefaultSetting and LocalSettings load. As such, I
think we can finally get rid of its out-of-bound load strategy.

Instead, we can simply set the default in DefaultSettings, and
recommend admins to set their value in LocalSettings.

Bug: T189966
Change-Id: I4e8dd9558132a5e38c22b26fed9c4b54cd324da7
2018-03-29 21:29:03 +00:00
jenkins-bot
89843b44ce Merge "Update suppressWarning()/restoreWarning() calls" 2018-02-11 22:06:29 +00:00
Reedy
fbc0347466 Update MediaWiki\quietCall() -> Wikimedia\quietCall()
Bug: T182273
Change-Id: Id7d8e176fcd93040e30e46cb64fc6a3d36bc8230
2018-02-10 10:49:33 +00:00
Reedy
39f0f919c5 Update suppressWarning()/restoreWarning() calls
Bug: T182273
Change-Id: I9e1b628fe5949ca54258424c2e45b2fb6d491d0f
2018-02-10 08:50:12 +00:00
Aaron Schulz
d5354b4a3a Make interim WAN cache key deactivation logic broader
* This is how it was before d5aa846d8, which accidentally changed
  the behavior. The WAN cache call in Setup.php was too coupled to
  the ChronologyProtector cookies. It made the assumption that DB
  positions and cookies are stored even when there are no replica
  databases setup (which changed in that patch).
* Check the "UseDC" cookie instead, which is already set in exactly
  the cases this logic should apply.

Bug: T185328
Change-Id: I4dd2a6ca6cdead0052d59be86e6030dbe01f141b
2018-02-01 00:57:05 +00:00
Umherirrender
3124a990a2 Use ::class to resolve class names in includes files
This helps to find renamed or misspelled classes earlier.
Phan will check the class names

Change-Id: I07a925c2a9404b0865e8a8703864ded9d14aa769
2018-01-27 20:34:29 +01:00
Max Semenik
2639f33501 Set default fragment mode to [ 'legacy', 'html5' ]
This is step one in migration, 1.35 LTS should make it
[ 'html5', 'legacy' ].

Also issue deprecation warnings for $wgExperimentalHtmlIds.

Bug: T152540
Bug: T139744
Change-Id: I8780bb589002a4f836ba90bd18093a56cddc3ddf
2018-01-19 18:36:30 -08:00
Aaron Schulz
d5aa846d84 Replace cpPosTime cookie/parameter with cpPosIndex
This handles multi-DB transactions properly, instead of causing wait
timeouts in the WaitConditionLoop. It also is more correct in using
a counter instead of relying on wall clocks.

In addition:
* Refactor related code in MediaWiki.php to be comprehensible.
* Always send the cookie even the "remote wiki redirect" case.
* Renamed ChronologyProtector field and constant to avoid any
  confusion of "wait for server X to reach Y" with "wait for Y
  to show up in position store".
* Add an "asOfTime" field to the position keys for debugging.

Bug: T182322
Change-Id: I5c73cd07eaf664f02ba00c38fab9f49b609f4284
2018-01-02 17:00:32 -08:00
Umherirrender
255d76f2a1 build: Updating mediawiki/mediawiki-codesniffer to 15.0.0
Clean up use of @codingStandardsIgnore
- @codingStandardsIgnoreFile -> phpcs:ignoreFile
- @codingStandardsIgnoreLine -> phpcs:ignore
- @codingStandardsIgnoreStart -> phpcs:disable
- @codingStandardsIgnoreEnd -> phpcs:enable

For phpcs:disable always the necessary sniffs are provided.
Some start/end pairs are changed to line ignore

Change-Id: I92ef235849bcc349c69e53504e664a155dd162c8
2018-01-01 14:10:16 +01:00
Aaron Schulz
e90eafdf61 objectcache: Make WANObjectCache interim caching not interfere with ChronologyProtector
Also removed useless line from testLockTSE(). That would have needed
to be using $this->internalCache and those locks are freed immediately.

Bug: T180035
Change-Id: Ida1a923f779aaf8410da76643457d2200da6cb20
2017-11-30 23:54:22 +00:00
Aaron Schulz
c46fa4c474 Make ChronologyProtector actually use cpPosTime cookies
Setup.php was only injected the value from $_GET. LBFactory used
to check both before 0e5cd18b74, with the cookie check left
in LBFactoryMW. After d175b391ae, LBFactoryMW class switched to
the default LBFactory method for making a ChronologyProtector
instance, so the cookie check was lost there too.

This means that an HTTP GET request due to a redirect from a POST
request will still make sure the DB position store is up-to-date.
This only matters is that store uses replication (e.g. cross DC).

Also refactor LBFactory handling of the cpPosTime URL parameter.

Change-Id: Ie5744577609f4c193cacd71334f92b30f02e3846
2017-11-30 22:26:57 +00:00
Timo Tijhof
25d3185dde Setup: Include StartProfiler before others
Bug: T180183
Change-Id: Ibcf78d094cf4dcf09bc919a5f8168f45ae225ebc
2017-11-09 16:35:19 -08:00
Timo Tijhof
fbfc69f5da Merge ProfilerFunctions into GlobalFunctions
Even if people use these (deprecated) functions in the earliest hooks or in
LocalSettings.php, it will keep working because GlobalFunctions is loaded
between DefaultSettings.php and LocalSettings.php.

The only places affected would be files in core: AutoLoader.php, Defines.php,
and DefaultSettings.php, which don't use these functions.

Change-Id: If4c0e8cbe1ea918283df22d72f792a3806569216
2017-11-09 16:31:55 -08:00
Timo Tijhof
8b7bafec21 Setup: Merge PreConfigSetup into Setup.php
Follows-up 41ea7e2fef.

The following previously happened between PreConfigSetup and Setup
and must now happen either before it, after it, or moved inside it.

* WebStart: Detect missing composer.
  This must be after Autoloader/Vendor but before the first call to
  wfDebugLog (or other loggers) so that we can output a more descriptive
  error instead of a generic "Unknown class" fatal error.
  Moving it to before Setup is too early, and after is too late.
  Move it to within Setup.php and make it work in CLI mode.

* WebStart: Install header callback
  Moving it to before Setup is too early, and after is too late.
  Move it to within Setup.php (no-op in CLI mode).

* WebStart/Maintenance: Load LocalSetings.
  Must be between PreConfigSetup and Setup.
  Move to Setup.php to maintain execution order.
  Utilise MW_CONFIG_File for custom handling in Maintenance.php.

* WebStart: Initialise output buffering
  Utilise (new) MW_SETUP_CALLBACK hook.

* WebStart: Display NoLocalSettings.php
  Utilise MW_CONFIG_CALLBACK hook.

* Maintenance: Setting $wgLocalisationCacheConf, calling Maintenance::finalSetup.
  Utilise (new) MW_SETUP_CALLBACK hook.

Change-Id: I633a6ff235b4275391c48034c0525d2fbfa3fecd
2017-10-24 23:50:54 +00:00
Max Semenik
63f17fadda Make $wgExperimentalHtmlIds fall back on modern HTML5 mode
This is a first step of deprecation, next would be to swap the two
modes, making html5 fall back on html5-legacy. No separate release
notes are required as this is part of deprecation already documented.

Change-Id: I132cffbc70bf76f9863d61fd109c73da7bdaeb18
2017-09-11 18:28:51 -07:00
Max Semenik
fd6e9ef2d4 Human-readable section ID support
It adds the ability to replace the current section ID escaping
schema (.C0.DE) with a HTML5-compliant escaping schema that is
displayed as Unicode in many modern browsers.

See the linked bug for discussion of various options that were
considered before the implementation. A few remarks:
* Because Sanitizer::escapeId() is used in a bunch of places without
  escaping, I'm deprecating it without altering its behavior.
* The bug described in comments for Parser::guessLegacySectionNameFromWikiText()
  is still there in some Edge versions that display mojibake.

Bug: T152540
Change-Id: Id304010a0342efbb7ef2d56c5b8b244f2e4fb2c5
2017-08-01 20:32:20 -07:00
Kunal Mehta
d1cf48a397 build: Update mediawiki/mediawiki-codesniffer to 0.10.1
And auto-fix all errors.

The `<exclude-pattern>` stanzas are now included in the default ruleset
and don't need to be repeated.

Change-Id: I928af549dc88ac2c6cb82058f64c7c7f3111598a
2017-07-22 18:24:09 -07:00
Kunal Mehta
399adec9ad Turn ParserCache into a service, deprecate $parserMemc
ParserCache is already a singleton, making it a good candidate for a
service. $parserMemc is an odd global (it lacks the "wg" prefix) and is
ripe for deprecation.

The following are now deprecated:
* $parserMemc global
* ParserCache::singleton()
* wfGetParserCacheStorage()

A ParserCache::getCacheStorage() method was added for cases where direct
access to the underlying BagOStuff object is necessary.

Usage of $parserMemc will emit deprecation warnings through the
DeprecatedGlobal class mechanism. All usage in core was migrated.

Also take this opportunity to inject the $wgCacheEpoch global value into
ParserCache. This will require an update to the FlaggedRevs extension.

Change-Id: I2ac7afff0d8522214329248c3d1cdccd0f72bbd4
2017-07-05 19:56:49 -07:00
Matthias Mullie
8ea782202d Set $wgGalleryOptions in Setup.php
Defaults will be added to the config array at a later point,
without overriding any that have already been set.
This'll make it less prone to errors in case $wgGalleryOptions
is incomplete.

Bug: T168479
Change-Id: I5f127e5ac8c8a1583301dd7aed2ae8e434987950
2017-06-23 13:33:23 +02:00
Brad Jorsch
fb6f4d35e7 Apply $wgShellLocale in Setup.php
While most of MediaWiki ignores the shell's/C library's locale setting,
there are some things other than shell execs that use it (e.g. the
luasandbox PHP extension).

To provide a consistent environment, set the locale in Setup.php instead
of letting it be changed mid-request depending on whether something else
happened to have called certain functions.

Bug: T107128
Change-Id: I02943803d26d5b1b3ac00ef9216f69cdfa149585
2017-06-01 15:11:01 +10:00
TTO
6a7a973b73 Avoid breaking wikis that were modifying $wgDummyLanguageCodes
Follow-up to If73c74ee87d8235381449cab7dcd9f46b0f23590.

Change-Id: I51b7ecf51860bfddea87fcf7cad17295088e1dd9
2017-03-09 01:15:58 +00:00
jenkins-bot
bdfa96eb72 Merge "Break up $wgDummyLanguageCodes" 2017-03-08 20:46:47 +00:00
This, that and the other
48ab87d0a3 Break up $wgDummyLanguageCodes
$wgDummyLanguageCodes is a set and mapping of different language codes:

* Renamed language codes: ['als' => 'gsw', 'bat-smg' => 'sgs',
                           'be-xold' => 'be-tarask', 'fiu-vro' => 'vro',
                           'roa-rup' => 'rup', 'zh-classical' => 'lzh',
                           'zh-min-nan' => 'nan', 'zh-yue' => 'yue'].
  The old language codes are deprecated because they are invalid but
  should be supported for compatibility reasons for a while.
* Language codes of macro languages, which get mapped to the main
  language: ['bh' => 'bho', 'no' => 'nb'].
* Language variants which get mapped to main language:
  ['simple' => 'en'].
* Internal language codes of the private-use-area which get mapped to
  itself: ['qqq' => 'qqq', 'qqx' => 'qqx']

This is a very strange conglomeration which should get differentiated,
and were split up in the following ways:

* Renamed language codes are available from
  LanguageCode::getDeprecatedCodeMapping().
* Language codes of macro languages and the variants that are mapped to
  the main language are available as $wgExtraLanguageCodes and are set
  in DefaultSettings.php.
* Internal language codes are set in $wgDummyLanguageCodes in Setup.php.

Change-Id: If73c74ee87d8235381449cab7dcd9f46b0f23590
2017-03-08 12:11:30 -08:00
jenkins-bot
17eda64357 Merge "includes: Replace implicit Bugzilla bug numbers with Phab ones" 2017-02-28 00:51:57 +00:00
Tim Starling
f193271cff Log a backtrace from the culprit location if headers were already sent
Install the backtrace collector very early, so that we can get the
backtrace even if headers were sent from LocalSettings.php.

Bug: T157392
Change-Id: I9bc732b34481c95afb5362e135a87bd4302498e2
2017-02-23 14:10:12 +11:00
James D. Forrester
9635dda73a includes: Replace implicit Bugzilla bug numbers with Phab ones
It's unreasonable to expect newbies to know that "bug 12345" means "Task T14345"
except where it doesn't, so let's just standardise on the real numbers.

Change-Id: I6f59febaf8fc96e80f8cfc11f4356283f461142a
2017-02-21 18:13:24 +00:00
jenkins-bot
5b1dcdc344 Merge "InstantCommons: do not cache thumbs" 2017-01-25 22:39:33 +00:00
Gergő Tisza
a75973d883 InstantCommons: do not cache thumbs
There is no point in local thumb caching when we set apibase
and thumbUrl to the remote wiki. It will only confuse MediaWiki
into creating local thumbnails for certain LinksUpdate tasks
even though the rendered page will reference thumbnails hosted
on Commons.

Bug: T145496
Change-Id: I0bd4b539f575036dd865bdd946660f10a9ee8801
2017-01-25 12:04:39 -08:00
Chad Horohoe
8c43707004 What's %MediaWiki? Remove random % from comment
Change-Id: I5e13a7b408885c390bb0b7b3cc1f585d43e327b2
2017-01-12 20:44:32 -08:00
jenkins-bot
2f71b491d1 Merge "Remove fully initialized debug message, dubiously useful" 2017-01-13 01:26:31 +00:00