Commit graph

1423 commits

Author SHA1 Message Date
jenkins-bot
447ba02601 Merge "Improve documentation for wfParseUrl" 2017-06-18 19:18:39 +00:00
Gergő Tisza
dc01555a3f Improve documentation for wfParseUrl
Change-Id: I84ef76d2e3b026ed38e02a82245b559324950ede
2017-06-18 13:33:34 +02:00
Gergő Tisza
016452cd09 ChangesList: Expose basic properties of lines as data attributes
We have several types of change lists (old RC/watchlist/related
changes, enhanced RC/watchlist, history) with slightly different
HTML, each with their own idiosyncracies. JavaScript code trying
to identify lines by log ID / revision ID has to jump through all
kinds of hoops to work with that.

To simplify the lives of frontend / gadget maintainers and provide
something approaching an API for these pages, we now expose the basic
attributes of each change line (revision ID for edits, log type/action
and ID for log events) as data attributes.

The OldChangesListRecentChangesLine, EnhancedChangesListModifyLineData,
EnhancedChangesListModifyBlockLineData, PageHistoryLine,
ContributionsLineEnding and DeletedContributionsLineEnding hooks
are updated accordingly. New hooks (LogEventsListLineEnding and
NewPagesLineEnding) are added for the change list pages which did
not yet have them.

Change-Id: I6dd006d0b1b0fd35c0020f0f9eea9113eca30b35
2017-06-08 23:19:45 +00: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
jenkins-bot
163381a091 Merge "Refactor Statsd classes to enable null collector to work." 2017-05-30 03:41:14 +00:00
Stanislav Malyshev
7fdc3d09a3 Refactor Statsd classes to enable null collector to work.
The following changes are added:
- Created MediawikiStatsdDataFactory interface
- Added hasData() method to see if there are any data to send
- Added getData() method to fetch data
- Made service infrastructure use MediawikiStatsdDataFactory interface
- Made wfLogProfilingData() use MediawikiStatsdDataFactory interface
- Added capability to enable/disable buffering collector

Bug: T166354
Change-Id: I2874175647e987996a9a399829b3319674471aaa
2017-05-29 15:33:02 -07:00
Kunal Mehta
ee8eb0fc94 wfIsBadImage: Avoid deprecated wfMemcKey()
Change-Id: I92133ed6a94902bdac2e9723f19a653a9962b757
2017-05-25 12:37:35 -07:00
Kunal Mehta
314cda9b0a Fix up deprecation of wfMemcKey()/wfGlobalCacheKey()
* Move @deprecated tags out of the header so the documentation comment
  still has a summary
* makeKey() and co. are part of BagOStuff, not ObjectCache

Follows up 1e5961dbf6.

Change-Id: I168ce97597f288f6345a404354d68371e57522d3
2017-05-23 14:58:54 -07:00
jenkins-bot
4d3b5d8440 Merge "GlobalFunctions: Avoid unnecessary fully-namespaced MediaWikiServices" 2017-05-23 05:28:04 +00:00
Kunal Mehta
1e5961dbf6 Deprecate wfMemcKey() and wfGlobalCacheKey()
For a while now these functions have called makeKey/makeGlobalKey() on
the default ObjectCache instances, and callers should now use those
functions directly instead.

There are other advantages to doing so, like in cases where the
ObjectCache instance being used has a different makeKey implementation
(e.g. memcache) than the default configured cache.

Change-Id: I9abf6badbf3ba800e591d2503b714433d5faf1e3
2017-05-22 21:32:52 -07:00
Kunal Mehta
f14f652347 GlobalFunctions: Avoid unnecessary fully-namespaced MediaWikiServices
There's already a "use" statement for MediaWikiServices so the full
class name isn't required.

Change-Id: Idabdd406a7c4afa1312fb45dea8499236fe3d6fd
2017-05-22 21:28:41 -07:00
Paladox
54c56da85a Fix php code style
Preparation change for updating mediawiki code sniffer to 0.8.0

Change-Id: Ib0b3fe4afea9096ffa3a1347b4f7e07d3398b0b2
2017-05-05 12:03:54 +00:00
Brad Jorsch
3b84e7f31c Change default $wgShellLocale to C.UTF-8, and use it to set LC_ALL
It's less likely to cause surprises than language-specific defaults.

Bug: T107128
Change-Id: Ife7673255798f3a3d72028a26607c56b9b7fb224
2017-05-04 05:53:47 +00:00
jenkins-bot
3bd5235bf6 Merge "Remove usages of RequestContext::getStats()" 2017-04-24 20:01:55 +00:00
Florian Schmidt
786e480f23 Remove usages of RequestContext::getStats()
Bug: T156810
Change-Id: Ic07896a68389e20ce0a35a06049b8c51b6c3f699
2017-04-24 19:49:38 +00:00
Tim Starling
820f46964f A service for read-only mode
Introduce a service to represent wfReadOnly() and friends.

It's necessary to have two service instances, one for wfReadOnly() and
one for wfConfiguredReadOnlyReason(), to avoid a circular dependency,
since LoadBalancer needs the configured reason during construction, but
wfReadOnly() needs to query the currently active load balancer.

Not having a cache of the configuration makes it possible to dynamically
change the configuration. Ideally things would not change the
configuration, and I removed such instances in core, but to support
extensions, I added a test ensuring that the configuration can be changed.

Change-Id: I9bbee946c10742526d3423208efd68cb3cc5a7ee
2017-04-19 12:27:06 -07:00
Aaron Schulz
dd359741cc Move DB errors to Rdbms namespace
Change-Id: I463bd86123501abc68fdb78b4cda6110f7af2549
2017-04-15 10:47:41 -07:00
Aaron Schulz
d735dc562d Move Database and subclasses to Rdbms namespace
Change-Id: I52bef87512f9ddd155d1f4cc0052f6b7a0db5b42
2017-04-12 10:43:57 -07:00
Bartosz Dziewoński
ecdef925bb Miscellaneous indentation tweaks
I was bored. What? Don't look at me that way.

I mostly targetted mixed tabs and spaces, but others were not spared.
Note that some of the whitespace changes are inside HTML output,
extended regexps or SQL snippets.

Change-Id: Ie206cc946459f6befcfc2d520e35ad3ea3c0f1e0
2017-02-27 19:23:54 +01:00
jenkins-bot
6ad363a177 Merge "Log a backtrace from the culprit location if headers were already sent" 2017-02-24 22:41:45 +00:00
Aaron Schulz
64df456b39 Move remaining LoadBalancer classes to Rdbms
The old names are left as aliases.

Change-Id: I52a327f2463a2ba7437324047b5b00d28cd1d758
2017-02-23 20:38:31 -08: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
Aaron Schulz
4a177b34ef Move LBFactory to Rdbms namespace
Change-Id: I5ae10783228d0252284807c9562bc8e328d4becb
2017-02-03 17:24:03 -08:00
Timo Tijhof
34060273e7 Move libs/time/defines.php inclusion from GlobalFunctions to Defines.php
* Verified none of these constants depend on each other.
* Move them to the top of Defines.php for consistency.

Change-Id: I19c77e706d69bff513e4abafd0300207de0dbb1d
2017-01-13 01:17:32 +00:00
Zhuyifei1999
c675393413 wfMessage: use Message::params() to handle all the message parameters
The old code was similar to Message::params(), but Message::params()
was unable to handle "special" parameters and received an overhaul
in 7f2663f, yet wfMessage remained broken. To avoid duplication,
wfMessage shall call Message::params() to correctly handle these
parameters.

CategoryMembershipChange::getChangeMessageText and its caller has
been updated so as not to take advantage of this bug.

Bug: T153747
Change-Id: I6667acf7e71c9db07fefc9fbb741c160e15823ff
2016-12-20 19:22:54 +00:00
jenkins-bot
9ac29c74ed Merge "Cleanup some incorrect return annotations" 2016-12-16 07:22:24 +00:00
Kunal Mehta
3413839cb8 API: Expose wfIsBadImage() in prop=imageinfo
If iiprop=badfile is set, expose the wfIsBadImage() status as a boolean.
This is mainly intended for use by Parsoid, but could be useful for
other API users too. The context title can be set by using the
badfilecontextitle parameter.

Also be a little more paranoid and make sure wfIsBadImage() always
returns a boolean.

Bug: T148343
Change-Id: I3432ead92b8d2a17de5243285f2760fc39b501ae
2016-12-14 00:29:32 -08:00
Erik Bernhardson
d67197fa11 Cleanup some incorrect return annotations
Most of these are simply changing annotations to reflect
reality. If a function can return false to indicate failure
the @return should indicate it.

Some are fixing preg_match calls, preg match returns 1, 0 or false,
but the functions all claim to return booleans.

This is far from all the incorrect return types in mediawiki, there
are around 250 detected by phan, but have to start somewhere.

Change-Id: I1bbdfee6190747bde460f8a7084212ccafe169ef
2016-12-12 10:15:05 -08:00
jenkins-bot
69ae945e8d Merge "Update weblinks in comments from HTTP to HTTPS" 2016-11-08 21:32:00 +00:00
Fomafix
202f695f67 Update weblinks in comments from HTTP to HTTPS
Use HTTPS instead of HTTP where the HTTP link is a redirect to the HTTPS link.

Also update some defect links.

Change-Id: Ic3a5eac910d098ed5c2a21e9f47c9b6ee06b2643
2016-11-07 15:24:46 +01:00
Kunal Mehta
643b1b40a8 Don't cache replacement patterns in wfEscapeWikitext() during tests
Parser tests depend upon being able to change the value of
$wgEnableMagicLinks at runtime, so skip caching the replacement patterns
while parser tests or phpunit tests are being run.

Change-Id: Ic9fe4fe898aa353bdefa2bf8207b77d2ac14887f
2016-11-04 02:27:13 +00:00
jenkins-bot
bdfe022232 Merge "Add documentation for wfClientAcceptsGzip()" 2016-10-25 21:45:03 +00:00
nicoco007
7bd97758f7 Add documentation for wfClientAcceptsGzip()
Change-Id: I18b9311d71278ca4c843908a11f77270f03cf534
2016-10-25 21:29:27 +00:00
Kunal Mehta
5320f0835e Use wikimedia/scoped-callback
The ScopedCallback class was moved into a separate library. This updates
all callers to use the namespaced version, and provides a
backwards-compatibility class wrapper under the old name.

Bug: T146258
Change-Id: I2dd0a66fe2f510f26bdfef6b0a975c1beb3fd93c
Depends-On: Iea0c40bdd7776372ccf72db8f088a2abaa4d3721
2016-09-29 10:41:40 +00:00
Aaron Schulz
30f4b3c103 Replace DatabaseBase => Database in more places
Change-Id: If37a7909056bf2c31a8228cbc84f0fbbf5f1c517
2016-09-28 15:53:02 -07:00
Aaron Schulz
af946ac245 Update wfEscapeShellArg() comments
Change-Id: Ib62a51186aee0967ba4420054ee69b83dcae4d59
2016-09-24 00:05:00 +00:00
jenkins-bot
eb53a231a7 Merge "Revert "Move wfEscapeWikiText() to Parser::escapeWikitext()"" 2016-09-23 00:35:47 +00:00
Legoktm
3172dfe21e Revert "Move wfEscapeWikiText() to Parser::escapeWikitext()"
Apparently it is possible for Parser::mParserOptions 
to not be set in some cases. I'll try again later.

This reverts commit bda74bff6e.

Bug: T146433
Change-Id: Idb6d1b20995d5f86b712abb386ab987356c4f560
2016-09-23 00:29:21 +00:00
jenkins-bot
eb2f439768 Merge "Move wfEscapeWikiText() to Parser::escapeWikitext()" 2016-09-22 22:02:36 +00:00
Kunal Mehta
316b4a404b time: Implement ConvertableTimestamp::now()
Shortcut for ConvertableTimestamp::convert() for the current time.

Change-Id: I1c34c0a59bb57652c7a2e959836c8ba400a25f49
2016-09-21 21:26:18 -07:00
Timo Tijhof
c46aa59dad time: Implement ConvertableTimestamp::convert()
* This method is analogous to wfTimestamp(). Optimise for the common
idiom of just converting a timestamp without having the caller hold
on to any object.

* Make wfTimestamp() use this (it could already since it didn't
use any MWTimestamp methods). Use via MWTimestamp. While this is
the same as direct access, it allows future changes.

* Add tests covering this new method.

Change-Id: I7f9104f1701d92fe25d72c7943581c64e1d093fa
2016-09-22 03:38:07 +00:00
Aaron Schulz
f7e3ac3f95 FSFile and TempFSFile cleanups
* Remove wf* function dependencies. This includes wfTempDir().
  Callers now should specify the directory, though it will try to do
  most of the wfTempDir() logic anyway if they do not.
* Update callers to inject wfTempDir() so $wgTmpDirectory is used by
  TempFSFile instead of it probing to find a valid directory itself.
* Move most of the wfTempDir() logic to TempFSFile::getUsableTempDirectory().
* Remove unused getMimeType() method.

Change-Id: Idd55936b07f9448a6c90577708722b7b52b8fe66
2016-09-19 19:55:09 +00:00
Aaron Schulz
e10f272a05 Split out ConvertableTimestamp class
* Make TimestampException a regular exception.
* Make DatabaseBase use ConvertableTimestamp.

Change-Id: I849737c9c187e8e0c6e080887ec0656e034f80d2
2016-09-16 03:00:09 +00:00
Kunal Mehta
bda74bff6e Move wfEscapeWikiText() to Parser::escapeWikitext()
wfEscapeWikiText() used $wgEnableMagicLinks, but that could result in an
inconsistency when something modifies the magic link related
ParserOptions.

In general, most uses of wfEscapeWikiText() are in parser functions or
when message parsing, so the Parser is a logical place for it.

A future patch will make it easy to use Parser::escapeWikitext() in
message parameters.

Change-Id: I0fd4d5c135541971b1384a20328f1302b03d715f
2016-09-13 22:34:24 -07:00
Kunal Mehta
78debba3aa Parser: Allow disabling magic link functionality
The magic link functionality is "old backwards-compatibility baggage"
that we probably want to get rid of eventually. The first step to doing
so would be making it configurable and allowing it to be turned off on
wikis that don't use it.

This adds each of the 3 magic link types as individual parser options,
which can be controlled by the $wgEnableMagicLinks setting.

Additionally, wfEscapeWikiText() was updated to only escape enabled
magic link types.

Bug: T47942
Change-Id: If63965f31d17da4b864510146e0018da1cae188c
2016-09-12 22:00:05 -07:00
Sébastien Santoro
5211995b69 Update Bugzilla references to Phabricator references
Change-Id: I28dbaf05d29062c485042d432fec5d11e9c6d193
2016-09-11 21:41:26 +00:00
Aaron Schulz
950cf6016c Rename DB_SLAVE constant to DB_REPLICA
This is more consistent with LoadBalancer, modern, and inclusive
of master/master mysql, NDB cluster, and MariaDB galera cluster.

The old constant is an alias now.

Change-Id: I0b37299ecb439cc446ffbe8c341365d1eef45849
2016-09-05 22:55:53 -07:00
Aaron Schulz
16266edff3 Change "slave" => "replica DB" in /includes
Change-Id: Icb716219c9335ff8fa447b1733d04b71d9712bf9
2016-09-05 21:01:01 +00:00
jenkins-bot
a303296f27 Merge "Make statsd sampling rates configurable" 2016-09-05 08:52:54 +00:00
Kunal Mehta
b8a41ea451 Document that wfParseUrl() can also return false
Change-Id: I6927ee13c35ecccc45c392b77d426380cc7a5c53
2016-08-16 20:48:02 -07:00