Commit graph

1377 commits

Author SHA1 Message Date
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