Commit graph

1664 commits

Author SHA1 Message Date
Max Semenik
0f50320502 Remove deprecated function wfInitShellLocale()
Deprecated in 1.30, never had more than 2-3 callers.

Change-Id: Ia023ede41affaf8e1b5fd1fed77cdbcefc9dc243
2018-04-18 18:35:41 -07:00
Max Semenik
efa586fddd Restrict shell commands by default
Before it's too late, let's boil the oceans
and just do it. This patch assumes that old code
calling wfShellExec() doesn't know about restrictions
so it doesn't restrict anything. New code, however,
needs to specify its restrictions or deal with defaults.

Change-Id: I58963901087202d4a405bcdb6bd12758bb6b0ff7
2018-04-16 11:50:13 -07:00
Max Semenik
5cf4575ea3 Deprecate wfShellWikiCmd()
Bug: T184339

Change-Id: Ic86a451e0e9d609e06865a4969560d151efa844c
2018-04-16 16:38:05 +00:00
Aaron Schulz
7f24eb5d78 Normalize and lower the default DB lag wait timeout
Bug: T190960
Change-Id: I49aca118583b20314e6bf82f196f3413571f5bd9
2018-03-28 13:49:25 -07:00
Timo Tijhof
665e9b7bf2 Convert OutputHandler functions to a class
* Convert OutputHandler.php from global functions to a class.

  - wfOutputHandler → OutputHandler::handle
    (no alias, no usage outside core)
  - wfGzipHandler → OutputHandler::handleGzip
    (private, no usage outside class)
  - wfRequestExtension → OutputHandler::findUriExtension
    (private, no usage outside class)
  - wfMangleFlashPolicy → OutputHandler::mangleFlashPolicy
    (private, no usage outside class)
  - wfDoContentLength → OutputHandler::emitContentLength
    (private, no usage outside class)
  - wfHtmlValidationHandler → OutputHandler::validateAllHtml
    (private, no usage outside class)

* Add the class to autoload.php for exposure outside WebStart.
  Specifically, for use in ApiFormatPhpTest. This also removes the
  need to manually load the class because this code runs after
  Setup.php loads AutoLoader.php.

Bug: T189966
Change-Id: I27a41ec0ae0ee30aeb313a616323b967605c4055
2018-03-20 21:11:32 -07:00
Kevin Israel
06ba5ca383 Remove internal use of deprecated $wgRequestTime
* Use $_SERVER['REQUEST_TIME_FLOAT'] unconditionally in WebRequest.php
  and libs/Timing.php. WebStart.php was doing this already without issue.
  The key existst since PHP 5.4, for both Web and CLI (we require 5.5).

* In wfDebug() and wfReportTime(), use $_SERVER['REQUEST_TIME_FLOAT'] instead.

* In ApiFormatBase and MWDebug, use WebRequest::getElapsedTime() instead.

* In Maintenance.php, remove setting of $wgRequestTime.

* In rebuildFileCache.php, update mocking to $_SERVER['REQUEST_TIME_FLOAT']
  so that we avoid re-introducing bug T24852.

Change-Id: I1b647da2862f815029caa533b592ec8a05b33806
2018-03-18 04:41:12 +00:00
Jayprakash12345
c48f489ba6 Remove deprecated function wfBaseConvert()
Bug: T189300
Change-Id: I5f05beb105dca8e8079e770df562c004a689c2ed
2018-03-09 16:41:54 +00:00
Umherirrender
554f9c857c Replace wfGetLBFactory
@deprecated since 1.27

Change-Id: I11a7253cebe525948a55cebee183e6de128fdc39
2018-02-27 20:02:48 +00:00
Umherirrender
b5dd5c769a Remove wfProfileIn/wfProfileOut
@deprecated since 1.25

Change-Id: Ie13c31816280fa577ef6bfb5fef172163f83c408
2018-02-24 10:45:31 +01: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
WMDE-Fisch
d9066cb5f9 Use MediaWiki\restoreWarnings in deprecated wfRestoreWarnings
This will give devs a better hint on how to replace this.

Change-Id: I2332b6173b7816aef11841725752745e174fa69f
2018-01-22 18:53:11 +01:00
Stanislav Malyshev
7efe60da09 Fix phpdoc since $proto can be int
In fact, some of the PROTO_* constants are ints,
some strings and one is null (PROTO_CURRENT).

Change-Id: I69c45ab87360ed1ab54b53b7e9e959ea566b4cba
2018-01-18 13:17:12 -08:00
jenkins-bot
a18476eab3 Merge "Remove @param comments that literally repeat what the code says" 2018-01-11 23:48:03 +00:00
Thiemo Mättig
ef470ebf7f Remove @param comments that literally repeat what the code says
These comments do not add anything. I argue they are worse than having
no comments, because I have to read them first to understand they
actually don't explain anything. Removing them makes room for actual
improvements in the future (if needed).

Change-Id: Iee70aad681b3385e9af282d5581c10addbb91ac4
2018-01-10 14:14:26 +01:00
jenkins-bot
bdf062a8e9 Merge "Treat phpdbg as run from the command line when checking PHP_SAPI" 2018-01-08 23:03:41 +00:00
Kunal Mehta
251a0b97e5 Treat phpdbg as run from the command line when checking PHP_SAPI
phpdbg is a gdb-style debugger for PHP that is run from the command
line. However, it has a different PHP_SAPI value, so it was impossible
to run maintenance scripts with it (until now).

To avoid having to check both PHP_SAPI values in a bunch of places,
introduce wfIsCLI() to easily check whether running from the
command-line or not.

We're (CI team) interested in generating code coverage with phpdbg
instead of xdebug, hence this patch.

Bug: T184043
Change-Id: Id1f994ca146d7858cd8bb6ab6cdbb7718ff524fb
2018-01-03 23:00:37 -08:00
Gergő Tisza
7ef448e97a
Fix RepoGroup caching bug
'bypassCache' was renamed in I9f79e5942ced4ae13ba4de0b4c62908cc746e777
to 'latest' but the cache bypass code was not updated.

Also fix an unrelated phpdoc error.

Change-Id: I141b97300853c60092363a90af063c3fd4941d27
2018-01-02 18:26:46 -08:00
Aaron Schulz
336454104d Try to opportunistically flush statsd data in maintenance scripts
This helps to avoid OOMs from buffer build-ups in the statsd
factory object. This piggy-backs on to the same checks used
for deferred update runs. In addition, the output() method
checks if the data size is getting large and emits if needed.

Bug: T181385
Change-Id: I598be98a5770f8358975815e51380c4b8f63a79e
2017-12-30 05:01:21 +00:00
WMDE-Fisch
b94a2829d4 Get conflict results from diff3
This patch extends the global wfMerge function to also return the
result of the first merge attempt that detects merge conflicts.

The additional output explicitly names the conflicting lines and
could help when solving edit conflicts.

Bug: T151320
Change-Id: I97acebdc87b31779200c7fde4dd4449cd1ee8ead
2017-12-06 13:25:35 +01:00
Stanislav Malyshev
194acaa0e0 Expose string->bool conversion as function
There is code in several places in extensions which converts
setting or parameter string (such as "true", "yes", "false", "no")
to boolean. Since we already have the code that does in global
functions in wfStringToBool(), it makes sense to expose this code
and reuse it.

Change-Id: I88d98b012ff4bf14fd64a05a9135a6e75cf2d4e7
2017-11-15 06:57:40 +00: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
Max Semenik
ca887b5301 Hard deprecate wfRunHooks()
Deprecated since 1.25, very few callers. Having to grep for 2
ways of calling a hook is harmful not only because it wastes developers'
time, but also because it makes it possible to forget to search for the
old way, resulting in mistakes. Better get rid of this.

Change-Id: Iab28bd5758475b780c2016847881757d64973862
2017-10-17 00:36:17 +00:00
jenkins-bot
2373a59e26 Merge "Hard deprecate wfBaseConvert()" 2017-10-13 18:15:34 +00:00
Max Semenik
ba3ced83a4 Hard deprecate wfBaseConvert()
No callers anywhere.

Change-Id: If804d1153ca8e9e82eda3af4d992e395ab112158
2017-10-12 19:38:26 -07:00
Max Semenik
0392d9bb57 Move wfCountDown() into Maintenance class
Doing this allows to restrict it to maintenance scripts and support
quiet mode.

Change-Id: Iad0858ce1fdd64f746d5f9d4a7d6ed96f21e94df
2017-10-12 17:24:46 -07:00
Max Semenik
009764c0ae Hard deprecate wfShellExecDisabled()
No users anywhere, only ever had 1 caller outside of core.

Change-Id: I1361d3b555b642b75ec58f071a02407a611b44f9
2017-10-11 19:42:18 -07:00
jenkins-bot
a7f7bc7981 Merge "Refactor global function wfBCP47 to static function LanguageCode::bcp47" 2017-10-05 17:55:50 +00:00
Fomafix
ea0bd74a94 Refactor global function wfBCP47 to static function LanguageCode::bcp47
Deprecate global function wfBCP47.

Change-Id: Ie6bb061b5d6ca67289bb18bc468a87421f38fc94
2017-10-05 09:54:45 +02:00
Max Semenik
31475c87b2 Hard deprecate wfInitShellLocale()
Soft deprecated since 1.30, no callers anywhere.

Change-Id: Ifec11eb3c2c25ea9d7e5ecb72c53127536ab6c30
2017-10-04 14:58:38 -07:00
Brad Jorsch
2c34fd6e0e Replace uses of each()
It's deprecated in PHP 7.2, may as well replace it now.

I note that, contrary to claims at
https://wiki.php.net/rfc/deprecations_php_7_2#each, none of our uses
were trivially replaceable with foreach.

* wfArrayDiff2_cmp() is processing two arrays by value in parallel.
* MagicWordArray::parseMatch() is doing something funky with the data
  structure returned by preg_match().
* HashRing was using it like "nextKey()", replaced with calls to key()
  and next().
* FormatMetadata and IndexPager were both using it as a shorter way to
  get both key() and current() for the first element in the array. I
  suppose a foreach(){ break; } would do the same, but that's confusing.

Bug: T174354
Change-Id: I36169a04c764fdf1bfd6603395111c6fe0aae5eb
2017-09-20 09:51:28 -04:00
jenkins-bot
af09cc1088 Merge "Port BCP47 formatter from PHP to JavaScript" 2017-09-12 11:43:49 +00:00
Niklas Laxström
990c1f0ad2 Port BCP47 formatter from PHP to JavaScript
It can be accessed via mw.language.bcp47.
To be used in ContentTranslation, see T157212

Change-Id: I37d32ab8a55c7101b903b03869899f00a39afd11
2017-09-12 11:07:31 +00:00
Max Semenik
77ce3b98a0 Replace wfShellExec() with a class
This function has gotten so unwieldy that a helper was
introduced. Instead, here's this class that makes
shelling out easier and more readable.

Example usage:
  $result = Shell::command( 'shell command' )
       ->environment( [ 'ENVIRONMENT_VARIABLE' => 'VALUE' ] )
       ->limits( [ 'time' => 300 ] )
       ->execute();

  $exitCode = $result->getExitCode();
  $output = $result->getStdout();

This is a minimal change, so lots of stuff remains
unrefactored - I'd rather limit the scope of this commit.
A future improvement could be an ability to get stderr
separately from stdout.

Caveat: execution errors (proc_open is disabled/returned error) now
throw errors instead of returning a status code. wfShellExec() still
emulates this behavior though.

Competing commit: I7dccb2b67a4173a8a89b035e444fbda9102e4d0f
<legoktm> MaxSem: so you should continue working on your patch and I'll
          probably refactor on top of it later after its merged :P

Change-Id: I8ac9858b80d7908cf7e7981d7e19d0fc9c2265c0
2017-09-08 21:49:49 -07:00
Max Semenik
104d864425 Remove deprecated function wfFixSessionID()
Deprecated since 1.27, no callers anywhere.

Change-Id: I2d1019fdb21fe4a9d0aa767a71eb18739f841dfb
2017-09-08 18:26:11 -07:00
Max Semenik
5fd5f6dbba Deprecate wfUsePHP()
No callers anywhere.

Change-Id: I47256448d313983e3cebd713f7c149e3c3a9ab47
2017-09-08 18:03:09 -07:00
Umherirrender
ace44e2064 Use correct variable name in @param documentation
For some varargs a variable name is added with suffix ,... as seen for
many other varargs

Some @param are swapped, because there are in the wrong order

Enable Sniff MediaWiki.Commenting.FunctionComment.ParamNameNoMatch

Change-Id: I60fec6025bce824d5c67563ab7b65ad6cd628ad8
2017-08-11 19:27:19 +02:00
Umherirrender
a9007e8baf Add missing & to @param documentation to match functon call
Change-Id: I81e68310abcbc59964b22e0e74842d509f6b1fb9
2017-08-11 18:47:46 +02:00
Eddie Greiner-Petter
351a699180 Hide "hideuser" on Special:Block for non-infinite blocks
Users with the hideuser right have an extra checkmark on Special:Block
to hide user, however this functionality can only be used on registered
users (not IPs) and only if a block is set to never expire. With this js
enhancement, hide the "hideuser" checkbox and label if the block time is
not set to infinite (either as selected from the dropdown or written
into the "other" input box).

Attribution to meta.wikimedia.org/wiki/User:Margott who uploaded a
draft for this patch on the task a while ago.

Bug: T133036
Change-Id: Ia8c3e25d923e1df57d5afd69e9de3d6f2543f628
2017-07-26 19:28:42 +00: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
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
Bartosz Dziewoński
a49b3216fc Canonicalise '@deprecated since' doc comments
Change-Id: I440041512feb47a998efb45e76e3fd00e0655752
2016-08-02 22:21:57 +00:00
jenkins-bot
532364d46f Merge "Clean up array() in docs, Part I" 2016-07-29 00:19:45 +00:00
Amir Sarabadani
7fd83c2102 Clean up array() in docs, Part I
Change-Id: Ia6bb3944c05b056677979035cb38385554ee8a4f
2016-07-25 17:15:18 +04:30
Bartosz Dziewoński
ea43031b39 Improve how slashes are stripped from filenames
* Add slash and backslash ('/' and '\') to $wgIllegalFileChars.
* Replace illegal chars before removing paths in wfStripIllegalFilenameChars().

This way users trying to upload a file with slashes in the name will
get a better filename suggestion (e.g. for 'Foo part 1/3.jpg', you
previously got '3.jpg', now you'll get 'Foo part 1-3.jpg'). Uploading
tools that don't special-case slashes will also behave better.

Change-Id: Ib78f48a5f8c92e8ab2dc773ea6789b96b3662177
2016-07-25 00:24:36 +02:00
Kevin Israel
8175ac82dc Revert "wfShellExec: Work around PHP 5.3 stream_select() issue"
No longer needed. Currently, MediaWiki supports neither PHP 5.3
nor HHVM 3.4 or lower. The minimum HHVM version stated in the
Compatibility section of the RELEASE-NOTES file is 3.6.5.

This reverts commit 8bd6f698cc.

Change-Id: I2edd25c4ce00eb324f7f6e04b2034ad28f7c6964
2016-06-16 02:36:29 -04:00
umherirrender
72632115d6 Fix various phpcs error from last security patches
Found by tests:
https://integration.wikimedia.org/ci/job/mediawiki-core-phpcs-trusty/1069/console

Breaking merges

Change-Id: If01b94705cd7b939ac380053730b1b602c838a8e
2016-05-20 20:20:36 +02:00
Darian Anthony Patrick
43f70b84b3 Enforce upper limit on invocations of wfShellExec()
Enforce an upper limit of 100,000 bytes on commands executed via
wfShellExec() to avoid HHVM crash resulting from process spawned with
argument exceeding MAX_ARG_STRLEN, as defined in binfmts.h

Bug: T129506

Signed-off-by: Chad Horohoe <chadh@wikimedia.org>
2016-05-20 09:49:02 -07:00
Gergő Tisza
b203ec5fcd Make statsd sampling rates configurable
Change-Id: I6f5b0531ff5caf4b0fda38331fabad93a6a8a360
2016-05-16 14:37:30 +00:00
jenkins-bot
edcba98e35 Merge "wfTempDir try harder to get a tmp dir on Windows" 2016-05-12 19:10:25 +00:00
jenkins-bot
f7dad57c64 Merge "Allow reset of global services (redux)." 2016-05-04 22:07:44 +00:00
addshore
96e94d1c90 wfTempDir try harder to get a tmp dir on Windows
Bug: T44730
Change-Id: If6f93ed50dfd93a1ffe046218058674a2197a626
2016-05-04 19:42:22 +01:00
daniel
d7410db0fd Allow reset of global services (redux).
(This is part of I6ec374ac9 wich was a re-submit of Ie98bf5af5
which got reverted by Ide7ab563)

This change provides a mechanism to reset global service instances
in an orderly manner. There are three use cases for this:

* the installation process
* integration tests (which most of the existing phpunit tests are)

In contrast to I6ec374ac9, this change does not cause singeltons
of legacy services to be reset. It is assumed that legacy services
use global state to access services and configuration, so any
change in confuguration would affect them immediately.

NOTE: the original I6ec374ac9 would cause session information to
get lost if the user session was creatsed before initialization
was complete. This was apparently triggered by the MobileFrontend
extension under some circumstances. Check with Addshore and Catrope.

Change-Id: Ie06782ffb96e675c0aa55dc26fb8f22037e8517d
2016-05-04 19:18:29 +02:00
Roan Kattouw
99ece2db2b Support hash fragments in wfAppendQuery()
Change-Id: Icb99d5479836fea25a47451b5a758dd71f642f71
2016-05-02 19:18:24 -07:00
Catrope
1162ed5f88 Revert "Allow reset of global services."
Completely breaks login.

This reverts commit 8e7a0a0912.

Change-Id: Ide7ab5632e987e81374c21173df6ab3998649df7
2016-04-11 13:40:28 -07:00
daniel
8e7a0a0912 Allow reset of global services.
This change provides a mechanism to reset global service instances
in an orderly manner. There are three use cases for this:

* the installation process
* forking processes
* integration tests (which must of the existing phpunit tests are)

Depends-On: I5d638ad415fc3840186a0beaa09ac02ea688539b
Change-Id: Ie98bf5af59208f186dba59a9e971c72ea0b63e69
2016-04-11 16:22:40 +02:00
jenkins-bot
6bcdf27c74 Merge "Change \\ to \ in phpdoc" 2016-04-08 18:12:54 +00:00
Gergő Tisza
4085db348e Change \\ to \ in phpdoc
Remove "\\" in namespacing. This is a Doxygen compatibility hack but
does not seem needed anymore, Doxygen reads namespaced class names
correctly, see e.g. https://doc.wikimedia.org/mediawiki-core/master/php/classMediaWiki_1_1Services_1_1ServiceContainer.html

PHP IDEs, on the other hand, were broken by the double backslash.

As an unrelated small doc fix, add parameter docs to PermissionError
constructor (parent has different arguments so the inherited
documentation is wrong).

Change-Id: I6da0f512b8c84f65fd20e90e4617108fe6a8fcd2
2016-04-08 17:46:30 +00:00
Max Semenik
943563062f Kill mbstring fallbacks
In the age when we require PHP 5.5, pretending that mbstring emulation
is not slow and silly is silly.

Bug: T129435
Change-Id: Ic8235c9da9a926df63ec7388900c44eab454eebe
2016-04-06 22:14:48 +00:00
Siebrand Mazeland
5b119a0e44 Replace uses of join() by implode()
All of core uses implode() consistently now.

Change-Id: Iba50898c64c43f356d1caf8869f484e90d9ff651
2016-03-08 18:24:16 +00:00
jenkins-bot
3b17287bb8 Merge "Remove useless PHP version comparison from wfDebugBacktrace()" 2016-02-29 14:40:59 +00:00
Bartosz Dziewoński
c161c46d26 Improve code suffering from PHP 5.3's lack of support for foo()[]
I searched for /\$(\S+) = (.+?\(.*?\);)\n.*?\$\1\[/, ignored
everything involving isset(), unset() or array assigments, then
skimmed through the remaining results and changed things where they
made sense. These changes were not automated, so please review them.

Change-Id: Ib37b4c66fc57648470f151ad412210b3629c2538
2016-02-28 22:49:20 +01:00
Ricordisamoa
1a998ef523 Remove useless PHP version comparison from wfDebugBacktrace()
MediaWiki 1.27 only supports PHP 5.5.9 and above, therefore
it is no more necessary to check that the running PHP version
is equal to or greater than 5.4.0.

Change-Id: I819c625e173cbf2a54ef614d742fe01f70be8efc
2016-02-27 05:21:03 +01:00
jenkins-bot
2827bfbca5 Merge "Remove wfCheckEntropy() as unused and deprecated in 1.27" 2016-02-23 08:24:46 +00:00
Brad Jorsch
f61cb18b71 Enforce MW_NO_SESSION, add MW_NO_SESSION_HANDLER
When an entry point specifies MW_NO_SESSION, actually enforce that by
having both SessionManager and PHP's session handling (session_start()
and friends) throw exceptions.

If an entry point needs the old behavior of using PHP's default session
handling (as defined in php.ini), it should define
MW_NO_SESSION_HANDLER instead of or in addition to MW_NO_SESSION.

This also makes PHPSessionHandler be installed in CLI mode, where it
wasn't installed before.

Bug: T127233
Change-Id: I2a3db06ee8e44a044096c57a819b5fd5e51c5c5c
2016-02-22 12:17:31 -05:00
Reedy
6ad9e97182 Remove wfCheckEntropy() as unused and deprecated in 1.27
Change-Id: Ib2eda8c5ab7b124a283b9e0ec934c034d3da864c
2016-02-20 20:19:43 +00:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
Per wikitech-l consensus:
 https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Notes:
* Disabled CallTimePassByReference due to false positives (T127163)

Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
2016-02-17 01:33:00 -08:00
Kevin Israel
94e5b80fee Remove references to safe_mode INI setting
The feature no longer exists starting in PHP 5.4.0, and MediaWiki
now only supports PHP 5.5.9 or newer.

Change-Id: I3f2d1b564c50f0a28ec1ec0abd7d1b242e26953b
2016-02-12 19:18:26 -05:00
Reedy
bc23d6c490 We support 5.5.9...
Change-Id: I6ef6a21e6f5cd9cdd82227f100eb89a9f6122d98
2016-02-11 20:54:09 +00:00
Ricordisamoa
15d3b2b1f5 Remove gzdecode() polyfill from includes/GlobalFunctions.php
Unnecessary since PHP 5.4.0

Change-Id: I8423b792488e3b3326ef9b702f1b84c9a2137952
2016-02-11 19:01:40 +00:00
Bryan Davis
514725e7fe Disable automatic cache headers associated with starting a session
Follow up to 7491b52. The 'private, must-revalidate' argument to
session_cache_limiter() does not match any expected values for the
function. This results in the PHP runtime treating it like the
documented empty string argument which completely disables the automatic
addition of cache related headers. Change the implementation to use the
empty string argument explicitly rather than continuing to rely on
the undocumented and potentially confusing existing behavior.

session_cache_limiter( '' ) is called unconditionally in
MediaWiki\Session\PHPSessionHandler::install(). This is safe now that it
is understood that we are disabling the setting of the automatic
headers.

Bug: T124510
Change-Id: I63164f8b7a408e370ff01dead42be27a0135dd35
2016-02-03 21:45:28 +00:00
Brad Jorsch
2257fe4228 Revert "Remove SessionManager, temporarily"
This reverts commit 823db5d63dd5200d04c63da50ba6bf16f928e70b.

Change-Id: Ibb3e023e4eb6715295586dea87d0725c344a8271
2016-02-03 21:44:59 +00:00
Brad Jorsch
5083e810eb Remove SessionManager, temporarily
The plan here is to take it out of 1.27.0-wmf.12 and put it back in
1.27.0-wmf.13.

Since BotPasswords depends on SessionManager, that's getting temporarily
removed too.

This reverts the following commits:
* 6acd424e0d SessionManager: Notify AuthPlugin before calling hooks
* 4d1ad32d8a Close a loophole in CookieSessionProvider
* fcdd643a46 SessionManager: Don't save non-persisted sessions to backend storage
* 058aec4c76 MessageCache: Don't get a ParserOptions for $wgUser before the end of Setup.php
* b5c0c03bb7 SessionManager: Save user name to metadata even if the user doesn't exist locally
* 13f2f09a19 SECURITY: Fix User::setToken() call on User::newSystemUser
* 305bc75b27 SessionManager: Don't generate user tokens when checking the tokens
* 7c4bd85d21 RequestContext::exportSession() should only export persisted session IDs
* 296ccfd4a9 SessionManager: Save 'persisted' flag in session metadata
* 94ba53f677 Move CSRF token handling into MediaWiki\Session\Session
* 46a565d6b0 Avoid false "added in both Session and $_SESSION" when value is null
* c00d0b5d94 Log backtrace for "User::loadFromSession called before the end of Setup.php"
* 4eeff5b559 Use $wgSecureCookie to decide whether to actually mark secure cookies as 'secure'
* 7491b52f70 Call session_cache_limiter() before starting a session
* 2c34aeea72 SessionManager: Abstract forceHTTPS cookie setting
* 9aa53627a5 Ignore auth cookies with value 'deleted'
* 43f904b51a SessionManager: Kill getPersistedSessionId()
* 50c5256352 SessionManager: Add SessionBackend::setProviderMetadata()
* f640d40315 SessionManager: Notify AuthPlugin when auto-creating accounts
* 70b05d1ac1 Add checks of $wgEnableBotPasswords in more places
* bfed32eb78 Do not raise a PHP warning when session write fails
* 722a7331ad Only check LoggedOut timestamp on the user loaded from session
* 4f5057b84b SessionManager: Change behavior of getSessionById()
* 66e82e614e Fix typo in [[MediaWiki:Botpasswords-editexisting/en]]
* f9fd9516d9 Add "bot passwords"
* d7716f1df0 Add missing argument for wfDebugLog
* a73c5b7395 Add SessionManager

Change-Id: I2389a8133e25ab929e9f27f41fa9a05df8147a50
2016-02-01 22:06:49 +00:00
Florian
15c2401d0c wfMsgReplaceArgs: Don't use count(), if the actual amount of entries isn't needed
The only use of the return value of count() is, to check, if the array is empty or
not. This can be done in an easier way and a bit more performant, especially for
large arrays.

Change-Id: If119ead9230ba1783b8c853c18c379f174910e51
2016-01-30 21:31:08 +00:00
Bryan Davis
7491b52f70 Call session_cache_limiter() before starting a session
Call `session_cache_limiter( 'private, must-revalidate' );` before
starting a session to specify the cache control headers that PHP will
automatically emit. The calls are wrapped in MediaWiki\quietCall to
suppress "headers have already been sent" warnings that may come from PHP.

If not called explicitly PHP will default to using
the value of the session.cache_limiter ini setting. Some values of that
setting will cause PHP to add a "Pragma: no-cache" header to the
response. Certain user agents (e.g. Firefox) treat that particular
header as a signal to aggressively flush the response from local cache
to the point that back button navigation will not work.

The value used was present in `wfSetupSession` prior to a73c5b7.

Bug: T124510
Change-Id: I942f8420c39c8cec5781ea8f6cc5619fd15f13cd
2016-01-25 11:23:14 -07:00
Tim Starling
b7e65e555a Improve wfTempDir() fallback sequence
Validate the return value of sys_get_temp_dir(), and use upload_tmp_dir
if that is not writable. If nothing is writable, throw an exception.

Bug: T119934
Change-Id: I27d784f55c47277bbab1192853e2e04a9d8bd39a
2016-01-21 06:15:20 +00:00
jenkins-bot
a7f35b7859 Merge "Deprecate wfWaitForSlaves() with LBFactory::waitForReplication()" 2016-01-20 00:10:39 +00:00
Brad Jorsch
a73c5b7395 Add SessionManager
SessionManager is a general-purpose session management framework, rather
than the cookie-based sessions that PHP wants to provide us.

While fallback is provided for using $_SESSION and other PHP session
management functions, they should be avoided in favor of using
SessionManager directly.

For proof-of-concept extensions, see OAuth change Ib40b221 and
CentralAuth change I27ccabdb.

Bug: T111296
Change-Id: Ic1ffea74f3ccc8f93c8a23b795ecab6f06abca72
2016-01-12 21:57:01 +00:00
Florian
1ea4f23b05 Finally: wfMsg*() was removed
With the great help of:
@reedy <reedy@wikimedia.org>
@MtDu <justin.d128@gmail.com>
@Unicornisaurous <crazy4sb@gmail.com>
@Victorbarbu <victorbarbu08@gmail.com>

and anyone I forgot (sorry), we did our best to find and replace any usage
of the remaining extensions, that use these functions (as you can follow in
the linked task).

Now, finally, these functions were removed from MediaWiki :)

Bug: T70750
Change-Id: Ie9e3d247bf6ab1234ff4f11383d5a4fdf7563397
2016-01-05 15:10:23 -08:00
Florian
08478f550b Remove wfMsgNoTrans()
Bug: T70750
Change-Id: Ie8ac70454778b1af7f9dc7026e6dd9749c2abae0
2016-01-03 21:42:56 +01:00
Reedy
872d5a4739 wfMsgForContentNoTrans() was removed
Bug: T70750
Change-Id: I295b451ecbf765d4c10d90a8373a96b88b8f4115
2016-01-03 00:41:36 +00:00
Florian
6c70a2e5b2 Remove wfCheckLimits
Change-Id: Iae5614a82681317afd1b96bc9ab1709fa3588539
2016-01-03 00:01:29 +01:00
Reedy
389fcbe134 wfEmptyMsg() was removed
Bug: T70750
Change-Id: I8c641f5698da2b1ad18d3285b5705d3fe9a3e655
2016-01-02 17:00:21 +00:00
Bryan Davis
459c0e28bf Exclude debug log events marked "private" from MWDebug
Respect the "private" context variable for debug log events when passing
events from MediaWiki\Logger\LegacyLogger to MWDebug::debugMsg. Passing
debug log events marked as private to MWDebug  was a regression
introduced by the PSR-3 logging system.

Restore handling of $dest argument to wfDebug which was removed in 1.25
with the PSR-3 logging conversion. The documentation for $dest = 'log'
has also been removed. This third debug log event handling option was
not implemented in the PSR-3 logging conversion in 1.25. A follow up
change will remove known usage of $dest = 'log' in core.

Bug: T122644
Change-Id: Ib1d999b8b54e584e3944b46e9163a700f11c2e72
2015-12-30 13:01:37 -07:00
Aaron Schulz
fedfee628c Deprecate wfWaitForSlaves() with LBFactory::waitForReplication()
This has a cleaner interface and makes failure more explicit

Change-Id: I5480845196383df85ba7538e15e507fa1b64948a
2015-12-22 21:05:44 -08:00
Ori Livneh
d8964a05fe Remove wfIsConfiguredProxy(), deprecated since 1.24
No usage:
https://github.com/search?utf8=%E2%9C%93&q=%40wikimedia+wfisconfiguredproxy&type=Code&ref=searchresults

Change-Id: I3c1e1d00b93320cde9b39c183174e7a495f03854
2015-12-13 22:27:26 +00:00
Ori Livneh
70803a8fe1 Remove wfDebugTimer(), deprecated in 1.25
No remaining usage:
https://github.com/search?utf8=%E2%9C%93&q=%40wikimedia+wfDebugTimer&type=Code&ref=searchresults

Change-Id: I7b6516f82344f98aaec04bc3af3c208b63169a77
2015-12-13 22:26:34 +00:00
Ori Livneh
cd78210ee7 Remove wfIsTrustedProxy(), deprecated since 1.24
No usage outside of core:
https://github.com/search?utf8=%E2%9C%93&q=%40wikimedia+wfIsTrustedProxy&type=Code&ref=searchresults

Change-Id: I86439a772e036dcd5ebdd8b16010c7bacfd9463b
2015-12-13 22:07:41 +00:00
Ori Livneh
c0238a6b76 Remove wfGetIP(), deprecated since 1.19
No remaining usage:
https://github.com/search?q=%40wikimedia+wfGetIP&type=Code&utf8=%E2%9C%93

Change-Id: I3b8f4b034e23a56f586993549cc5460b28bf6fa7
2015-12-13 22:05:24 +00:00
Aaron Schulz
6af3c39c07 Replace "squid" with "CDN" in various comments
Change-Id: Idcc528daf28e119349155d36e30a9bcf61b2e7d5
2015-12-09 17:35:37 -08:00
jenkins-bot
a57d441fe7 Merge "Fix phpdoc of wfArrayToCgi" 2015-12-07 20:40:00 +00:00
addshore
d50ca32803 Fix phpdoc of wfArrayToCgi
Change-Id: I87db5c251310f6f56f0ec47cbb7f034ed43c31ac
2015-12-05 20:07:03 +01:00
Timo Tijhof
fbab4fecef tests: Clean up use of mt_rand()
* ApiQueryTest: One random is enough.

* FileBackendTest: More consistent and idiomatic via wfRandomString()

* MigrateFileRepoLayoutTest: Use getNewTempDirectory(). Similar to
  what FileBackendTest used already.
* UploadFromUrlTestSuite: Use getNewTempDirectory().

Change-Id: I772de2134be41506d8ed08367be8c18f354bfc72
2015-12-03 13:45:55 +00:00
Reedy
a916a25607 Mark wfBaseConvert() as deprecated.
Change-Id: I7c258d0844665dea8f93cce3d8dcf617c961c5f9
2015-11-24 23:13:28 +00:00
Timo Tijhof
41b5aa343f Remove redundant escaping for namespace references in documentation
Follows-up b264cee. No longer needed as of 0c9e9cc.

Change-Id: I31745f55885eeec2bb8cf2c9ffe9e98242cd5baa
2015-11-23 23:02:32 +00:00
jenkins-bot
0183ae1453 Merge "Allow passing detailed permission errors data to API" 2015-11-04 22:38:47 +00:00
Aaron Schulz
17c91ad610 Replace newAccelerator() with getLocalServerInstance()
The name is clearer and more consistent, with simpler arguments.

Change-Id: I7205a99ce033e8b086a52cd02c8a721e99c84b1e
2015-11-02 21:39:08 +00:00
Bartosz Dziewoński
92c29b8891 Allow passing detailed permission errors data to API
Using the new system introduced in
1c57794e37 (see T47843).

This change allows Title::getUserPermissionsErrors() to include
MessageSpecifiers instead of string message keys in its return value.
This doesn't seem to have any bad effects, and should work seamlessly as
long as callers aren't trying to do anything stupid and just pass the
value to PermissionsError or OutputPage::showPermissionsErrorPage()
or wfMessage() or some such.

If the callers *are* trying something stupid, nothing worse than
duplicated or otherwise less-than-perfect error messages (in code
which tries to handle some message keys specially) should happen.
(I fixed wfMergeErrorArrays(), but who knows what else lurks in all
this code.) Any problems should only affect new-style errors using
MessageSpecifier, though.

Since MessageSpecifiers tend to be stringable, we probably won't get
fatals, but might get incorrect checks. Should we try to log this
happening somehow?

Goes with I42a0c5b0ea7e61088dd609b764dd7d1396c60cd5 in TitleBlacklist.

Bug: T115258
Change-Id: I1334ba21a2862973a9d8ff5be2c9bec06a82698b
2015-11-02 17:11:50 +01:00
Kunal Mehta
525dd55065 Add and use wikimedia/base-convert 1.0.1
Change-Id: I3ae56e761ef6fb2b2d506bc2990b97f57183ccf1
2015-10-30 00:53:46 +00:00
Aaron Schulz
52010e6d21 Make DB handles inherit configured read-only mode
LBFactory inherits $wgReadOnly, the LBs inherit
any LBFactory read only mode, and Database objects
inherit any LB read-only mode.

Add some methods callers can use to check if
a DB/LB handle is read-only before trying writes.

Additionally:
* Fix 5ec1e47475 regression where readOnlyBySection
  read-only mode would not affect wfReadOnly() but only
  lagged-slave read-only mode for LBFactoryMulti.
* Catch errors when getLaggedSlaveMode() is called after
  master connection and object is established.
* Make getLaggedSlaveMode() a no-op if there are no slaves.
* Make string/false logic for read-only consistent everywhere.
* Remove mLaggedSlaveMode "m" prefix.

Change-Id: Ice3224caae564aa5ffb41b424c23d1593229117a
2015-10-20 23:27:14 +00:00
Aaron Schulz
cb862afaf3 Rename getMainClusterInstance() -> getLocalClusterInstance()
Also corrected some ObjectCache docs

Change-Id: I322f4cbd72fbd5d4c6887d90ee75d0baddb6ac25
2015-10-20 00:26:21 +00:00
jenkins-bot
7436cd31a2 Merge "Add makeKey and makeGlobalKey to BagOStuff" 2015-10-17 01:06:12 +00:00
csteipp
59b627b0b7 SECURITY: API: Improve validation in chunked uploading
This fixes a few shortcomings in the chunked uploader:
* Raises an error if offset + chunksize > filesize.
* Enforces a minimum chunk size for non-final chunks.
* Refuses additional chunks after seeing a final chunk.
* Status of a chunked upload in progress is now available with
  'checkstatus'.

Bug: T91203
Bug: T91205
Change-Id: I2262db1bc8460616b069c564475d2e4148001768
2015-10-16 14:10:44 -07:00
Alex Monk
23f633c5a6 Use the frame 'type' in wfFormatStackFrame, like MWExceptionHandler::prettyPrintTrace
Instead of assuming '::'

Change-Id: I2452bc5ebd3716eb61f53da41a0050f4833fb5a4
2015-10-14 16:40:02 +01:00
Alex Monk
9144554931 Handle $frame['function'] not being set in stack frames
Bug: T115107
Change-Id: I9fbfcd53fbcba1800a924acb1a1702c3c9037cc5
2015-10-14 13:05:29 +00:00
umherirrender
2320f5cfe2 Change some line comments to multi line comments
This allows empty lines inside the comment as found by the
MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.EmptyComment sniff

Change-Id: Iac155bbda4a84562db2b452baeae9b8973899453
2015-10-14 09:40:50 +02:00
Ori Livneh
6916548490 Add makeKey and makeGlobalKey to BagOStuff
* Add a string `keyspace` member to BagOStuff instances. The default
  implementation, meant for simple key/value stores, treats the key space
  as a string prefix to prepend to keys. By default, its value is `local`,
  but any instance created via ObjectCache::newFromParams() (or or one of
  its callers) will have that default to $wgCachePrefix / wfWikiID().
* Add `makeKey` and `makeGlobalKey` methods to the base BagOStuff class.
  These methods are not static to allow for BagOStuff types which require
  a configured instance to know the underlying storage engine's key semantics.
* Make wfMemcKey() and wfGlobalCacheKey() delegate to these methods on the main
  ObjectCache instance.

Change-Id: Ib7fc2f939be3decfa97f66af8c2431c51039905f
2015-10-13 09:32:48 -04:00
Bryan Davis
b264cee6d4 Fix namespaced class references for Doxygen
Doxygen doesn't quite grok PHP's use of the reverse solidus (backslash)
character as a namespace separator. The C++ based parser it uses needs
them to be escaped in comments just as if they were being used in
a literal string context in PHP.

Change-Id: I9aff9dd0fb74a95039da1091c2f247cf71fd085a
2015-10-08 11:10:33 -06:00
Ori Livneh
7628a11d8e Remove .php5 entrypoints and $wgScriptExtension
* The '.php5' entrypoints were deprecated in I68b1ae842, $wgScriptExtension
  in I3690f78bc.
* Drop the associated ResourceLoader configuration variable, too. `mwgrep`
  shows no usage in the MediaWiki namespace.
* Keep the scriptExtension configuration parameter for FileRepo for people who
  would like to interoperate with older MediaWiki installations that still use
  '.php5'.

Change-Id: I17c8a15484b7e82cd5970d34e688109a2aae3840
2015-10-08 15:45:31 +01:00
Aaron Schulz
8a3816529a Apply $wgReadOnly to all file backends
* Also added a wfConfiguredReadOnly() method
  to avoid DB_SLAVE connections

Change-Id: I9e7ec95c4b2f763505166d2345d27abaef6257a3
2015-10-03 00:15:28 +00:00
Aaron Schulz
e055d8abcd Removed wfDataCenter()/wfDataCenter() roles
* Follows-up 0a1c04bea
* The DC name ended up not being used in the cookie, 
  making these unused

Change-Id: I5f0d822a334102ee9596b1ec2a8d911010294e7c
2015-10-01 20:00:05 +00:00
Aaron Schulz
0a1c04beae Added $wgDataCenterId/$wgDataCenterRoles
* This is used to set sticky DC cookies to avoid
  session replication lag (which also makes sure
  ChronologyProtector works)

Bug: T91816
Change-Id: I7bc2f8185a3c05cb3ca5ccc42d300eccffae48e1
2015-10-01 00:52:54 -07:00
Aaron Schulz
6e115a7cc1 Optimized wfIsBadImage() redirect check
* Callers end up hitting wfFindFile() anyway, so we
  may as well use/prime the process cache. By trying
  to call checkRedirect() manually, it actually just
  caused an extra memcached query.
* 404 pages are often customized to show various
  icons file from sister sites, so this was taking
  up a significant portion of rendering time.

Change-Id: I7e2a1c6acf853629fcca3a8b3c2c810ebacd2acb
2015-09-27 14:43:39 +00:00
Vivek Ghaisas
c54766586a Fix issues identified by SpaceBeforeSingleLineComment sniff
Change-Id: I048ccb1fa260e4b7152ca5f09b053defdd72d8f9
2015-09-26 23:06:52 +00:00
Aaron Schulz
a607f11f94 Made wfIsBadImage() use APC
* Article 404s spend are large chunk of their time
  there and the method is also hit on page save

Change-Id: I26043f596195a8fe322bc154bf375a6c5d39c968
2015-09-25 22:38:04 +00:00
umherirrender
271da88127 Some bugzilla.wikimedia.org -> phabricator.wikimedia.org changes
Changed some old bugzilla links to new phabricator links in comments,
test data and error message. This reduces the need for redirects from
old bugzilla to new phabricator from our source code.

Change-Id: Id98278e26ce31656295a23f3cadb536859c4caa5
2015-09-24 17:17:25 +02:00
jenkins-bot
e491904eef Merge "Add new authentication-related hooks (and remove one) replacing some AuthPlugin methods" 2015-09-22 07:32:03 +00:00
jenkins-bot
35f61c7c4b Merge "registration: Allow extensions to specify which MW core versions they require" 2015-09-22 04:57:47 +00:00
Kunal Mehta
cef1f31167 registration: Allow extensions to specify which MW core versions they require
This adds a "requires" property to extension.json, which extensions and
skins can use to indicate which versions of MediaWiki core they support.
The hacky wfUseMW() is now deprecated in favor of this.

Rather than writing our own version constraint and parser library, we
can re-use composer's, which was recently split out into a separate
library named "composer/semver" for this patch.

Any syntax accepted by composer[1] is available for usage here. Test
cases have been provided to demonstrate how versions are parsed. For now
it is recommended that people stick to expressing compatability with
stable versions (e.g. ">= 1.26").

This patch does not support requiring specific MediaWiki core WMF
branches, since those do not follow the standard semver format that
composer parses. If we are unable to parse $wgVersion, all checking will
be skipped and reported as compatible.

[1] https://getcomposer.org/doc/01-basic-usage.md#package-versions

Bug: T99084
Change-Id: I7785827216e16c596356d0ae42d6b30f3f179f10
2015-09-21 09:56:53 -07:00
Brad Jorsch
37062a0c0d Add new authentication-related hooks (and remove one) replacing some AuthPlugin methods
* LocalUserCreated: Replaces AuthPlugin::initUser()
* UserGroupsChanged: Replaces AuthPlugin::updateExternalDBGroups()
** The similar UserRights hook is deprecated, mainly to get rid of the
   passing of $user by reference.
* UserIsHidden: Replaces AuthPluginUser::isHidden()
* UserIsLocked: Replaces AuthPluginUser::isLocked()
* UserLoggedIn: Replaces AuthPlugin::updateUser()

Also, AuthPlugin::updateExternalDB() is deprecated in favor of the
existing UserSaveSettings hook.

Also, 'ResetSessionID' has been removed. Nothing uses it, I don't know
why I even added it in the first place.

Also, replacing the User object passed to AuthPlugin::initUser() and
AuthPlugin::updateUser() will now raise a warning.

Change-Id: If7474cfb26a29b11c2e78147069419ca3b1cba95
2015-09-18 10:46:13 -04:00
Bartosz Dziewoński
aa511ccd86 Add '@since 1.25' annotation to wfLoad*() functions
Change-Id: I2cf9c2eddaa8b3449bd2852c496515b5bc133981
2015-09-16 15:55:13 +02:00
jenkins-bot
804cc6885a Merge "Revert "Do not encode "'" as %27 (redirect loop in Opera 12)"" 2015-09-10 15:36:10 +00:00
Bartosz Dziewoński
8477b1b277 Revert "Do not encode "'" as %27 (redirect loop in Opera 12)"
This seems to cause redirect loops in current Firefox instead.

This reverts commit a89a21990e.

Bug: T106793
Change-Id: I18fac8ab0f94e2df8476131b132c9866902a02c4
2015-09-10 15:23:25 +00:00
jenkins-bot
d891ffecbd Merge "Fix so wfResetOutputBuffers doesn't break unit tests" 2015-09-10 00:14:21 +00:00
jenkins-bot
e3a3f2293b Merge "Unbreak wfResetOutputBuffers" 2015-09-10 00:03:45 +00:00
Bartosz Dziewoński
a89a21990e Do not encode "'" as %27 (redirect loop in Opera 12)
Similar to 7b4df0e12e,
but for apostrophe instead of tilde and for Opera
instead of Chrome.

Bug: T106793
Change-Id: Ic54390434cebcc76a6c8ab49acc164d36e0cdff6
2015-09-05 21:17:33 +01:00
Florian
20f2df9c9f Implement wfArrayPlus2d which combines 2d arrays
Moved the logic of ExtensionRegistrations array_plus_2d merge method out
to it's own global function wfArrayPlus2d, so any other function in mediawiki
core and it's extensions can use this method when they need to union
a 2d array.

Change-Id: I56afdf306e399a4a1505828ed76c60c1bfd033b6
2015-09-01 20:53:54 +02:00
Timo Tijhof
62e3da7e58 objectcache: Document the primary entry points people should use
There are imho too many ObjectCache methods, $wg*Cache* variables,
CACHE_ types, and wfGet*Cache() functions to know which ones
should actually be used publicly. This should make it easier to
know which ones should be used.

The difference between them was also harder to understand with the
main documentation sections about each of these living in
conceptually different places:
- classes (WANObjectCache)
- methods (ObjectCache::getMainStashInstance)
- variables (DefaultSettings: wgMainCacheType, wgMainWANCache, wgMainStash)

Also:
* Correct wfGetCache() documentation.
* Add the missing keywords for 'public' visibility.

Change-Id: I3b05fdb8b7888bf7e3f05bdca36538f3484556b8
2015-08-25 03:11:15 +02:00
Timo Tijhof
86c701f290 objectcache: Remove use of deprecated $wgSessionsInMemcached
Deprecated since MediaWiki 1.20.

Change-Id: I3b431714e0d2b21b3911c80bbf2b4b4868634510
2015-08-24 22:11:22 +02:00
Brad Jorsch
4379362154 Fix so wfResetOutputBuffers doesn't break unit tests
If something being unit tested calls wfResetOutputBuffers(), it'll break
PHPUnit's attempt to capture output in order to fail tests. In the old
version we're currently using for Jenkins it will throw a warning
"ob_end_clean(): failed to delete buffer. No buffer to delete", while in
newer versions it'll detect that its buffer was removed and fail the
test as risky instead.

The solution here is to have MediaWikiTestCase add a buffer with a known
name in setUp() (and remove it in tearDown()), and have
wfResetOutputBuffers() stop when it sees that known name on the stack.

Bug: T109843
Change-Id: I8acd91ec9dd9c6d78a5d91d96202249f571d5d83
2015-08-21 12:24:07 -04:00
Brad Jorsch
8c76a6f0ff Unbreak wfResetOutputBuffers
Sometime between 5.3 and 5.6, PHP changed from considering the default
output buffer (ob_start() or ob_start( null )) as "user" to considering
it as "internal", which prevents wfResetOutputBuffers() from removing
any buffers.

What we really should do here is test directly for whether the buffer
can be deleted, using the 'del' flag in PHP 5.3 or 'flags' in PHP 5.4+.
As for HHVM, we'll need to continue falling back to testing 'type' for
now thanks to https://github.com/facebook/hhvm/issues/5563.

Bug: T109842
Change-Id: If0163257a8fb471fd594a3754a20c65274f84a4c
2015-08-21 12:23:32 -04:00
Brad Jorsch
093a0c1106 Fix return value comment on wfMemoryLimit()
It was changed incorrectly in I893ddd77.

Change-Id: I1f1e3c53a2cefe69b42ef338aa2a6b126e3d5526
2015-08-17 11:42:10 -04:00
Aaron Schulz
9bba2d169e Added wfTransactionalTimeLimit() method and applied it
* Potentially long running POST requests often use multiple transactions,
  talk to multiple services, or defer updates. Try to make sure they have
  a chance to complete all of the work. WMF already sets ignore_user_abort()
  across the board in config, but this applies it to key spots for all
  installs, in addition to bumping the time limit. 
* Eventually this can lower the need for high overall time limits.

Bug: T102890
Change-Id: I893ddd773064dcd63b5b24c84c6391974f4b5aee
2015-08-12 22:09:40 +00:00
Aaron Schulz
203d2c9c11 Moved ObjectCacheSessionHandler renewal logic to wfSetupSession()
* This should trigger more reliably than the shutdown function
  callback, which is really only there for sanity to make sure
  session close/write happens.

Change-Id: I9a1aa76de121ba8de33b3fa850bd223929fae404
2015-08-10 19:10:38 +00:00
addshore
acf2130bc5 Remove unused StatsdClient use from GlobalFunctions
Change-Id: I5a773590e229f891298ff3d2eda5e4a258cc1f25
2015-08-06 18:00:43 +01:00
Gergő Tisza
e56f7b6c63 Sample StatsD messages when instructed
Bug: T106457
Change-Id: I8ddb5a53dcbaf398f5a114d2a4a862842e980db4
2015-08-03 22:09:18 +00:00
Gergő Tisza
3ebb384513 Log exceptions in the StatsD process
Change-Id: Iff14cbbfbe81d38c55b41ff115c66156323df035
2015-07-23 21:26:29 +00:00
jenkins-bot
012248fc5a Merge "Allow constructing a Message from a MessageSpecifier" 2015-07-20 23:05:26 +00:00
jenkins-bot
08db2b721e Merge "Hygiene: Use strtr() instead of str_replace() for character swapping" 2015-07-15 09:39:45 +00:00
Brian Wolff
7b4df0e12e Do not encode '~' as %7E. Fixes redirect loop in chrome.
As of 155d555b83, we now redirect variations on hex escapes
into their canonical form. This was causing '~' to be redirected
to %7E. However google chrome seems to canonicalize %7E back
into ~, causing a redirect loop.

RFC 3986 says ~ is unreserved, so not hex encoding it should be
fine. To quote: "For consistency, percent-encoded octets in the
ranges of...tilde (%7E) should not be created by URI producers"

Bug: T105265
Change-Id: I01556eee496e2fb540de8ff09c082c1fedddb5f7
2015-07-09 11:52:24 +01:00
Timo Tijhof
c318e3a265 Hygiene: Use strtr() instead of str_replace() for character swapping
strtr() is marginally faster as it runs through the string only
once. A better fit for one-for-one character translation.

The strtr() function also supports an associative array as second
parameter for entire string replacements. This, too, has the same
performance and predictable behaviour (starts with the longest key).
Whereas str_replace is for more aggressive needs where you want
multiple passes until there are no further matches.

The associative array form is arguably also easier to understand
and harder to mess up since the needle/replacement pairs are
explicitly connected instead of two separate arrays.

Also:
* Use getFormattedNsText instead of strtr( getNsText, .. ) which
  reduces duplication of this fact through a more semantic intent.

Change-Id: Ie23e4210a5b6908dd79eebc8a2b931d12fe31af6
2015-07-06 20:25:19 +00:00
Timo Tijhof
4ef96ff1f2 Declare and document $wgStatsdServer and $wgStatsdMetricPrefix
Follows-up 87dfc20.

Change-Id: Ie1b799a8f2a73b974ba8c930cfabc00e377d6eee
2015-07-02 08:03:21 +00:00
Timo Tijhof
0f64b61271 Implement wfGlobalCacheKey() for database-agnostic keys
Some code paths abuse wfForeignMemcKey() for this purpose. This is semantically
incorrect and seems fragile. Also the empty second argument (for db-prefix) is
either misused or akwardly set to the empty string.

It also creates a namespace conflict between arbitrary application keys (from
the software) and any database names (from users). This commit reduces the
conflict surface down to a single key (namely, "global").

Also added unit tests to assert the implicit restrictions and
assumptions between these cache key functions are valid.

Change-Id: Ia0953b51005fe3de3b881dd1bd64c9d3c85e8c66
2015-06-23 07:52:18 +01:00
Vivek Ghaisas
9f5b6f5aeb Fix whitespace issues around parentheses
Fix issues found by MediaWiki.WhiteSpace.SpaceyParenthesis sniff.

Bug: T102617
Change-Id: Iec7f71e64081659fba373ec20d9d2006306a98f4
2015-06-16 22:14:02 +03:00
Kunal Mehta
f6e5079a69 Use mediawiki/at-ease library for suppressing warnings
wfSuppressWarnings() and wfRestoreWarnings() were split out into a
separate library. All usages in core were replaced with the new
functions, and the wf* global functions are marked as deprecated.

Additionally, some uses of @ were replaced due to composer's autoloader
being loaded even earlier.

Ie1234f8c12693408de9b94bf6f84480a90bd4f8e adds the library to
mediawiki/vendor.

Bug: T100923
Change-Id: I5c35079a0a656180852be0ae6b1262d40f6534c4
2015-06-11 18:49:29 +00:00
Timo Tijhof
70429dc8a2 Use HttpStatus::header instead of manually crafting header()
Also:
* Update wfHttpError() to use uppercase DOCTYPE, to match other code
  such as Html.php, wfThumbError(), HttpError.php, etc.

Change-Id: I4027e7fe1a138b03f78797b6d1bfe7bd1064d360
2015-06-04 02:27:35 +00:00
Kevin Israel
cfaaff1068 wfBaseConvert(): Avoid PHP warning when converting zero
The warning occurs when gmp_init() tries to convert the empty string
that came from ltrim(). This is causing tests to fail under HHVM 3.6.1.

Follows-up 5957856c46.

Bug: T98882
Change-Id: Ica86c91d7897db979e09d7cfc82fb3a20b95d4ce
2015-05-13 15:52:49 +00:00
Ed Sanders
cf2678e24d Allow override of extension directory
Also sets default paths immediately (not in Setup.php) so
they are available before extensions register.

Bug: T98319
Change-Id: I41a8aec7a3e9c576ec7344abf51f8106248ade4b
2015-05-06 19:22:55 +01:00
Thiemo Mättig
0b79eebfa6 Add @var LoadBalancer[] type doc
This avoids a good amount of type warnings in certain IDEs, e.g. in
my PHPStorm.

Change-Id: Id2b99ad48fa2c0d924a1f51b7d2e382eaac7347d
2015-04-29 19:16:50 +00:00
Aaron Schulz
aef1c677f1 Made wfReadOnlyReason catch DB connection errors
Change-Id: I4e960d9bd751b2a6f95f08861fc8ed360af4a04a
2015-04-24 13:52:32 -07:00
jenkins-bot
979681f488 Merge "Use PHP_OS rather than php_uname, which may be disabled" 2015-04-22 20:19:52 +00:00
Brad Jorsch
3a878b81be Allow constructing a Message from a MessageSpecifier
Bug: T91986
Change-Id: Id6a9862d23c2b71da2c8b34acdd19b8247ac5301
2015-04-21 11:48:39 -04:00
Aaron Schulz
95cfa54557 Made wfWaitForSlaves check all master connections for writes
* Previously it just checked the main connection

Change-Id: If63498e4fa2800f8ffbde4c570c556f21b554473
2015-04-16 22:27:24 -07:00
jenkins-bot
6733f81d33 Merge "Only need one check for is_dir" 2015-04-12 18:29:36 +00:00
Kunal Mehta
dda1696b7f Remove unused "swap" global function
Deprecated in 26e1e083e8, unused since r12411.

Change-Id: If328f09114ac5a5d23a300d9b0bbcd7d67e051c8
2015-04-10 18:07:38 +01:00
Ori Livneh
e0e6c9c746 Use PHP_OS rather than php_uname, which may be disabled
A user just logged on to the #mediawiki channel to ask for help because his
webhost disallowed php_uname(), causing wfIsWindows() to crash. Google
autocompletes 'php_uname()' to 'php_uname() has been disabled for security
reasons', so it is probably not uncommon. Consulting the PHP_OS constant
instead side-steps the problem nicely.

Change-Id: I8d63826db4fc5d142eac53717d4f9fbbf9928de9
2015-04-09 12:16:17 +00:00
Aaron Schulz
01a5c6013e Made wfReadOnly() more robust at handling the lagged-slave case
* Previously if it was called before a DB_SLAVE connection, it would not
  be set. This is fixed now.
* Also set mLaggedSlaveMode in LoadBalancer as appropriate. Before, it
  was only set in the "too lagged for ChronologyProtector" case.

Change-Id: Ic4dc555cf762653f157df1795f53f3577c1e587a
2015-04-08 18:41:57 +00:00
Bryan Davis
1195e11a8a Move MWLogger classes to MediaWiki\Logger namespace
Move the MWLogger PSR-3 logging related classes into the
MediaWiki\Logger namespace. Create shim classes to ease migration of
existing MWLoggerFactory usage to the namespaced classes.

Bug: T93406
Change-Id: I359cc81fbd2dcf8937742311dcc7d3dee08747b0
2015-04-03 11:32:24 -07:00
Ori Livneh
97a9c65895 PHPCS lint fixes
Change-Id: I16288db03f34439bdb16940a86720d2511f46467
2015-04-03 11:08:19 -07:00
Ori Livneh
1b6f70089d Introduce ProfilerOutputStats
* Associate Profiler objects with a request context by adding a $context
  property with a getter and a setter.
* Introduce ProfilerOutputStats, which writes profiling data to the stats
  buffer associated with the current request context.
* Make it the Profiler class's responsibility to enforce $wgProfilerLimit.
* Deprecate $wgProfilerLimit in favor of the (more aptly named, IMO)
  $wgProfiler['threshold'] config setting.
* Tidy up Profiler instance creation code in Profiler::instance().
* Add Profiler::getOutputs, which returns an array of ProfilerOutput instances
  which are configured for the current profiler and whose canUse() method
  returns true.
* Make ProfilerStub not log by creating a stub ProfilerStub::logData() method
  which does not call the parent. Previously the parent class checked if $this
  was an instance of ProfilerStub and returned early if so.

Task: T90623
Task: T85641
Change-Id: Icf644ad3435c1f30d0a49957a97b481808a3153d
2015-04-02 01:32:46 +00:00
Ori Livneh
667fa3e264 Make WebRequest objects time-aware
* Deprecate $wgRequestTime in favor of $_SERVER['REQUEST_TIME_FLOAT'], which is
  more accurate. Because $_SERVER['REQUEST_TIME_FLOAT'] is only set for PHP
  5.4+, set it to microtime( true ) in WebStart.php for back-compatibility.
* Add a 'requestTime' property to WebRequest objects, set to
  $_SERVER['REQUEST_TIME_FLOAT'] for WebRequest or the instance creation time
  for FauxRequest instances.
* Use that to provide WebRequest::getElapsedTime(), which gets the time since
  the request was initiated.
* In wfLogProfilingData(), get the user and request objects from the context
  object rather than from global scope.

Opportunistic clean-up: move the magic quotes check to WebStart.php and make
the error message more helpful.

Change-Id: I7e07e22eaf16b5141b80ad9f843285c542a127b7
2015-04-01 18:21:26 -07:00
Kunal Mehta
78fbe31c2b registration: Have wfLoadExtension() (and similar) use the queue
Right now wfLoadExtension() and related functions explicitly load
extensions immediately, bypassing the queue. This was done to be
extremely backwards-compatible with the old require_once style of
loading which does the same.

However, for a future configuration database to work, we need to be able
to reliably load extensions after configuration (LocalSettings.php) is
loaded, which is currently at the top of Setup.php. Rather than doing
this later, we should do this now to make sure the registration system
will be able to handle it.

In Wikimedia production, excentions are currently being loaded with
direct calls to:
  ExtensionRegistry::getInstance()->queue(...);
so we know that this should work, but that is not a nice API for sysadmins
and developers to be entering into LocalSettings.php.

If for some reason an extension really needs to be loaded immediately,
they can still call:
  ExtensionRegistry::getInstance()->loadFromQueue();
But that should be the exception, not the norm.

Change-Id: I72672e5c9541ede02d09f548c39ef6c8df0ec78a
2015-03-31 00:47:15 +00:00
Max Semenik
4b28391820 Deprecate wfDiff()
This function is backwards:
* The stated purpose is to generate a list of differences for callers to parse,
  however we already have DiffEngine that returns a list of differences that you
  don't need to parse manually shooting your feet off in process.
* With improvements in PHP performance in the last 10 years, shelling out instead of using
  a pure-PHP diff has a doubtful performance benefit.
* Even in configurations where it's faster on predominant diffs (which have to be huge),
  shelling out has its own security implications.

This function is not used in core. The only extensons using it are Echo (which just parses
its output so would be better off with DiffEngine) and AbuseFilter, let's not add more users
by tolerating this function.

Also, add error checking while I'm at it.

Change-Id: Ia67debce39de8252312fd887ebfbe6fb89f9edc9
2015-03-25 21:19:32 -07:00
Kunal Mehta
8911a8d0b7 Send messages logged via MWLoggerLegacyLogger::log() to the debug toolbar
Bug: T93145
Change-Id: Ia96525faf4ffcbd2b5beae9716d6be009f2b6074
2015-03-18 23:57:47 +00:00
JuneHyeon Bae
511525a136 Refactor out 'infinity' variants
Refactor out 'infinity' vartiant values which used in blocking and
protecting actions. This patchset adds GlobalFunction wfIsInfinity.

Bug: T68646
Change-Id: I60cc55a5bbd43c72916a1c2ea3807457d4e33765
2015-03-12 16:38:02 +00:00
Ori Livneh
87dfc20b1e Add StatsD metric logging
This patch adds a metric data service object to the IContextSource interface,
with full support for StatsD meters, gauges, counters and timing metrics, via
the liuggio/statsd-php-client, which this patch also introduces.

Usage example:

    $stats = $context->getStats();
    $stats->increment( 'resourceloader.cache.hits' );
    $stats->timing( 'resourceloader.cache.rtt', $rtt );

The metrics are flushed to a StatsD server, which may be specified via the
'StatsdServer' configuration key. If no such configuration key exists, the
metrics are discarded.

The StatsD client supplants MediaWiki's StatCounter class. wfIncrStats()
will continue to work, but it will delegate to the StatsD data object.

Change-Id: Ie10db1c154d225971398e189737de7c560bf0f90
2015-03-09 16:57:14 -07:00
Yuri Astrakhan
7c75ee3976 Remove duplicate param escaping code
wfEscapeShellArg() can handle multiple params, escaping each.
This patch changes wfShellExec() to call wfEscapeShellArg() directly
instead of doing the gluing itself.

This patch also extends wfEscapeShellArg() to accept an array parameter
optionally instead of as separate args, which is often useful.

Added also unit test cases for single, multiple args, and single array args.

Change-Id: I7a0761cc2ba98c210a9eacadd12da407d933e42a
2015-03-05 17:06:04 +00:00
jenkins-bot
0bf1384b16 Merge "Made the "bypassCache" flag for file locator methods use the master DB" 2015-03-05 16:28:31 +00:00
Aaron Schulz
7508b86ad3 Made the "bypassCache" flag for file locator methods use the master DB
* Added a File::load() stub method
* Cleaned up the File loading flags bitfield a bit

bug: T89184
Change-Id: I1aa4b096c0cad5f5ca34321cc897019005c53a76
2015-03-04 17:02:05 -08:00
jenkins-bot
1318ac9ac0 Merge "Profile wfShellExec() calls by caller" 2015-03-04 23:32:17 +00:00
Chad Horohoe
615d513f87 Profile wfShellExec() calls by caller
Change-Id: Ide437ec586b9e123ca73b5abd17278a72375dfb0
2015-03-04 15:04:45 -08:00
Chad Horohoe
9eefeaed6d Remove unused alias/layer of test abstraction wfShellMaintenanceCmd()
Change-Id: I28d303f9b89ffad052d06eb2dbb9e6f8cfaeea24
2015-03-03 22:15:52 -08:00
Chad Horohoe
9971834131 Delay language conversion cache construction until needed
Instead of instantiating this on every single request. Removes
wfGetLangConverterCacheStorage() and $wgLangConvMemc which were
otherwise unused.

Change-Id: Ic500944a92c2a94bc649e1b492c33714d81dca00
2015-03-03 21:12:28 -08:00
Elliott Eggleston
7d8f8ae84d Only need one check for is_dir
It implicitly includes file_exists test.

Change-Id: I25a6e609801455f2102d14035900248192e49f39
2015-03-02 18:38:16 +00:00
Brion Vibber
2922b7f34f Account for HiDPI variants in thumb.php rate limiting
If $wgResponsiveImages is on, include the 1.5x and 2x multipliers
in the wfThumbIsStandard() standard image size comparisons.

Change-Id: I79d866387730cdd4d7c7a976e691192b2335b7ce
2015-02-04 19:55:44 -08:00
Timo Tijhof
39ac4fa5a4 Move wfThumbIsStandard() to GlobalFunctions and add tests
Change-Id: Ife9c011a476a4022cd72d433497944cbd7258e67
2015-02-04 19:50:06 -08:00
Bryan Davis
56b70b61af Replace MWLogger with MWLoggerFactory
Time wounds all heels. During the code review for the PSR-3 logging
introduction, several people asked me why we needed a wrapper
for Psr\Log\LoggerInterface if the point was to use the standard. At the
time I was convinced that it would be better to introduce the dependency
via a wrapper class so that we could use the wrapper to patch over any
deficiencies that we might find in the PSR-3 API. After going on to work
on a project to disentangle other MediaWiki components from internal
project dependencies I have suddenly and clearly seen the error of my
ways.

We still need a logger factory as PSR-3 does not specify
a standard mechanism for creating Psr\Log\LoggerInterface instances. My
solution is to convert MWLogger into MWLoggerFactory to retain a static
factory interface for creating PSR-3 loggers but remove the MWLogger
wrapper class itself in favor of direct exposure of
Psr\Log\LoggerInterface to the MediaWiki consumer classes.

Change-Id: Ie47467657dcf341991ada00827dca5e8eff95438
2015-01-22 22:10:49 +00:00
jeroendedauw
ea9612e947 Document alternative to deprecated function
Change-Id: I89ae5f5062f8e3eb8dac38d7efcca7723d6b62b1
2015-01-21 01:30:14 +01:00
Brad Jorsch
7d91612411 Don't call $wgOut->disable() from wfHttpError if $wgOut isn't set up yet
For example, if the database cannot be connected to, the language is
something other than 'en', and the l10n cache is LCStoreDB, then the
call to Language::factory() in Setup.php line 604 will do it when it's
trying to get the fallback list.

Bug: T86398
Change-Id: Ia0e9ea440dcc4c8ab7bab1f33802aeff487eb3f0
2015-01-12 16:48:40 -05:00
Aaron Schulz
6921770414 Updated some try-catch statements: MWException -> Exception
Change-Id: I76601a86e30f4984e3b1a8c8ec5ef5a0f652433a
2015-01-09 17:20:22 -08:00
Kunal Mehta
bfe4ddd810 Implement extension registration from an extension.json file
Introduces wfLoadExtension()/wfLoadSkin() which should be used in
LocalSettings.php rather than require-ing a PHP entry point.

Extensions and skins would add "extension.json" or "skin.json" files
in their root, which contains all the information typically
present in PHP entry point files (classes to autoload, special pages,
API modules, etc.) A full schema can be found at
docs/extension.schema.json, and a script to validate these to the
schema is provided. An additional script is provided to convert
typical PHP entry point files into their JSON equivalents.

The basic flow of loading an extension goes like:
 * Get the ExtensionRegistry singleton instance
 * ExtensionRegistry takes a filename, reads the file or tries
   to get the parsed JSON from APC if possible.
 * The JSON is run through a Processor instance,
   which registers things with the appropriate
   global settings.
 * The output of the processor is cached in APC if possible.
 * The extension/skin is marked as loaded in the
   ExtensionRegistry and a callback function is executed
   if one was specified.

For ideal performance, a batch loading method is also provided:
 * The absolute path name to the JSON file is queued
   in the ExtensionRegistry instance.
 * When loadFromQueue() is called, it constructs a hash
   unique to the members of the current queue, and sees
   if the queue has been cached in APC. If not, it processes
   each file individually, and combines the result of each
   Processor into one giant array, which is cached in APC.
 * The giant array then sets various global settings,
   defines constants, and calls callbacks.

To invalidate the cached processed info, by default the mtime
of each JSON file is checked. However that can be slow if you
have a large number of extensions, so you can set $wgExtensionInfoMTime
to the mtime of one file, and `touch` it whenever you update
your extensions.

Change-Id: I7074b65d07c5c7d4e3f1fb0755d74a0b07ed4596
2015-01-08 01:40:01 +00:00
Chad Horohoe
aa21e125a3 Remove obvious function-level profiling
Xhprof generates this data now. Custom profiling of various
sub-function units are kept.

Calls to profiler represented about 3% of page execution
time on Special:BlankPage (1.5% in/out); after this change
it's down to about 0.98% of page execution time.

Change-Id: Id9a1dc9d8f80bbd52e42226b724a1e1213d07af7
2015-01-07 11:14:24 -08:00
jenkins-bot
d34a6ca677 Merge "Fix some stuttering in comments and documentation" 2014-12-17 22:28:27 +00:00
Ricordisamoa
12dec5d85d Fix some stuttering in comments and documentation
Change-Id: I9c0088b9aab37335203cad45a1d6fa8ac3f43321
2014-12-17 19:44:10 +00:00
Bryan Davis
6aa3c4fe84 Logging related comment updates
* Pretty up some logging related comments.
* Send wfDebugLog messages to logger at info level

Change-Id: I97b8629095e8d6168dbeb791dfb5e7753d281cbe
2014-12-16 17:12:23 -07:00
Bryan Davis
6a8c686c7a Deprecate wfErrorLog
When a logging service other than MWLoggerLegacySpi is used, the
behavior of wfErrorLog is not guaranteed.

Change-Id: I8543bfd556aa752665f7a3daa855d3c2f7fc8956
2014-12-15 16:26:03 -07:00
Kunal Mehta
e27ae6b5ec Convert more wfRunHooks() --> Hooks::run()
Change-Id: I1b1e3cb6871721fc05dda881a8020c9a5d30a514
2014-12-12 14:47:31 -08:00
Bartosz Dziewoński
c819a558fe GlobalFunctions: Fix 'Undefined index' notice in wfBacktrace
Notice: Undefined index: line in
/var/www/wiki/includes/GlobalFunctions.php on line 1840

Caused by fc2e6df64f, previous versions
used isset here.

Change-Id: Ie9434f09e0905346ace19909fb316d47c75e0440
2014-12-12 21:35:36 +00:00
Ricordisamoa
fc5fd5c37a Typo fixes and non-code tweaks
Skipped replacements:
* prefered → preferred
* prolly → probably

Skipped files:
* resources/lib/jquery.ui/jquery.ui.mouse.js
* resources/lib/jquery/jquery.form.js

Change-Id: Ib7923f362ddfca1b892bf5d601785d6b5aa5d44c
2014-12-12 18:31:15 +00:00
jenkins-bot
d8ab903223 Merge "Cleaned up LoadBalancer::getConnection" 2014-12-12 02:47:39 +00:00
Aaron Schulz
e369f66d00 Replace wfRunHooks calls with direct Hooks::run calls
* This avoids the overhead of an extra function call

Change-Id: I8ee996f237fd111873ab51965bded3d91e61e4dd
2014-12-10 12:26:59 -08:00
Aaron Schulz
52e6121447 Cleaned up LoadBalancer::getConnection
* It will also no longer call getReaderIndex( false, ... ) twice
* Removed various related ampersands

Change-Id: Ia79e2007dbf84e7437f9439aa6371333aa3e1b23
2014-12-10 00:27:48 -08:00
Chad Horohoe
52f3b13312 Remove Profiler::isStub()
Just check for ProfilerStub directly.

Change-Id: I503916599f182df4206da5282193ae6ec9324ee6
2014-12-03 20:19:56 -08:00
Bryan Davis
9be737caef Decorate deprecated functions with wfDeprecated()
Change-Id: Iaa7d11a9fdd1c68dc7ff1b3138fe8c9ba229cc69
2014-11-24 16:41:10 -07:00
Bryan Davis
2792ea9783 Add logging context to database logs
* Add optional $context parameter to wfDebug, wfDebugLog, wfLogDBError
  and wfErrorLog that will be passed to MWLogger.
* Add support for PSR-3 style log message parameter interpolation in
  MWLoggerLegacyLogger.
* Add context information to wfLogDBError calls made from DatabaseBase,
  DatabaseMysqlBase and LoadBalancer instances.
* Deprecate wfDebugTimer() which now appears to be unused.

Change-Id: Ic90d593d00a2b0b5b80ed205908cbe624042603c
2014-11-19 17:59:55 +00:00
Bryan Davis
0b91f622a3 Prettier wfLogProfilingData() log message
Make the profiler logging output introduced in Iae11e1e a little nicer.
Stop adding the Profiler::getRawData() information and add the URL and
textual report to the default log message. When testing with a Monolog
logger and Logstash the getRawData output from the Xhprof profiler was
found to be too big to be usable. The default message output was found
to be less informative than desirable when a PSR-3 logger other than
MWLoggerLegacyLogger was used. MWLoggerLegacyLogger implements special
backwards compatible formatting for the profileoutput channel that will
not be effected by this change.

Change-Id: Id326aed4f72a3489fac30661c101ac3bb3af2530
2014-11-17 10:41:49 -07:00
Bartosz Dziewoński
3e85dfb8ad Standardize indentation of multiline 'if'/'elseif' conditions
Always indent the continuation one level deeper, and always place the
closing parenthesis on the next line, per coding conventions.
https://www.mediawiki.org/wiki/Manual:Coding_conventions#Indenting_and_alignment
https://www.mediawiki.org/wiki/Manual:Coding_conventions#Line_continuation

Regexp used: (\t+)(if|while|\} elseif|foreach).+(?<![;}])\n\1\S

Also:
* Change to just one line if line length stays under 100 characters.
* Add "// Do nothing" comment in empty 'if' bodies.
* Change '#' comments to '//' comments near affected code.

Change-Id: I4f62658fddb5a0ed18bbf9b2231cd794683d6402
2014-11-17 15:33:34 +00:00
Aaron Schulz
fc2e6df64f Added wfLogDBError() call to LoadBalancer::doWait()
Change-Id: Ida0970754a2a7287c129bb5ad633765dab97133a
2014-11-13 21:34:54 +00:00
umherirrender
6f50f1bee5 Remove unused global in wfLogProfilingData
Change-Id: I873efb8967cd17c89de5b32fcde6c738eefa03e6
2014-11-07 14:33:24 +00:00
jenkins-bot
fd92d3cd5f Merge "wfDebugLog(): remove unused global" 2014-11-04 21:17:30 +00:00