Commit graph

4931 commits

Author SHA1 Message Date
Aaron Schulz
fb51330084 rdbms: include client ID hash in ChronologyProtector cookies
Previously, if an internal service forwarded the cookies for a
user (e.g. for permissions) but not the User-Agent header or not
the IP address (e.g. XFF), ChronologyProtector could timeout
waiting for a matching writeIndex to appear for the wrong key.

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

Bug: T194403
Bug: T190082
Change-Id: I84f2cbea82532d911cdfed14644008894498813a
2018-06-02 03:57:30 +00:00
jenkins-bot
285080c311 Merge "objectcache: make RedisBagOStuff pass all tests" 2018-06-02 01:35:26 +00:00
jenkins-bot
966e34619b Merge "objectcache: add setMockTime() method to BagOStuff/WANObjectCache" 2018-06-01 13:19:24 +00:00
Aaron Schulz
acace9a049 objectcache: add setMockTime() method to BagOStuff/WANObjectCache
Change-Id: I3e5760814fb7dbe628eb0d979d690c3275fc3c15
2018-06-01 03:46:58 +00:00
Aaron Schulz
13f7232bf4 objectcache: make RedisBagOStuff pass all tests
* Provide a default lock-based BagOStuff::cas implementation
* Make RedisBagOStuff::merge() use mergeViaCas()
* Use the raw unserialized string as the redis CAS token to
  avoid any bad interaction with __wakeup() methods changing
  field values every time
* Make RedisBagOStuff::incr() return false when there is no
  such key, not null
* Rewrite merge() test to make the order of write/cas phase
  of the parent and child merge() calls well defined instead
  of arbitrary usleep() calls
* Avoid cache key reuse in test runs

Change-Id: I388ec173cf3858bb2fc7a8c8a00cda68703074ce
2018-05-31 20:43:10 -07:00
Kunal Mehta
2ecb2c944f Use wikimedia/xmp-reader library
Bug: T100922
Depends-On: I9bec4e03c49baafda30fb44cc793fa31b36e400d
Change-Id: Ic9044bf3260d1a474a6c74844949602441ffc865
2018-05-31 19:24:39 -07:00
jenkins-bot
5a6c78c441 Merge "Use PHP 7 '??' operator instead of '?:' with 'isset()' where convenient" 2018-05-31 19:01:07 +00:00
Jforrester
9befbd38dc Revert "Strip soft hyphens (U+00AD) from title"
This reverts commit 6b8a5a137d.

Change-Id: Ica5abe69c316792aa2f7eafad9b1d63183b282a8
2018-05-31 10:45:11 -07:00
Jforrester
722ff7b1fc Revert "Strip Unicode 6.3.0 directional formatting characters from title"
This reverts commit 7564624d1c.

Change-Id: I5d596f8f3c784920829de6ae50b270b0396369e0
2018-05-31 10:45:11 -07:00
jenkins-bot
bf6e584464 Merge "registration: Initialize PSR-4 namespaces at same stage as normal autoloader" 2018-05-31 07:39:04 +00:00
Bartosz Dziewoński
485f66f174 Use PHP 7 '??' operator instead of '?:' with 'isset()' where convenient
Find: /isset\(\s*([^()]+?)\s*\)\s*\?\s*\1\s*:\s*/
Replace with: '\1 ?? '

(Everywhere except includes/PHPVersionCheck.php)
(Then, manually fix some line length and indentation issues)

Then manually reviewed the replacements for cases where confusing
operator precedence would result in incorrect results
(fixing those in I478db046a1cc162c6767003ce45c9b56270f3372).

Change-Id: I33b421c8cb11cdd4ce896488c9ff5313f03a38cf
2018-05-30 18:06:13 -07:00
Bartosz Dziewoński
4fd27f006f Use PHP 5.6 '**' operator instead of 'pow()' function
Change-Id: Ieb22e1dbfcffaa4e7b3dcfabbcc999e5dd59a4bf
2018-05-30 18:05:19 -07:00
jenkins-bot
b6e8e6b832 Merge "rdbms: make runOnTransactionIdleCallbacks() reset DBO_TRX on exceptions" 2018-05-30 21:47:27 +00:00
Antoine Musso
224864ebdd registration: Initialize PSR-4 namespaces at same stage as normal autoloader
readFromQueue() injects the content of AutoloadClasses to
$wgAutoloadClasses however it missed doing the same for
AutoloadNamespaces.

When using the installer with an extension having AutoloadNamespaces
set, its classes would not be found.

Make ExtensionRegistry append to AutoLoader::$psr4Namespaces, and add
a test to cover the new behavior.

Bug: T195783
Change-Id: Id61155867a4ca7d9bc4a347f8671da74b0fa490b
2018-05-30 13:07:42 -07:00
jenkins-bot
ade631c612 Merge "Call Database::timestamp in some tests" 2018-05-30 19:32:02 +00:00
jenkins-bot
9da597821b Merge "rdbms: do not silently rollback empty transactions on error" 2018-05-30 19:19:22 +00:00
Timo Tijhof
5f8a94a0b3 resourceloader: Improve coverage of ResourceLoader::respond()
- Cover case of simple module load.
  The bulk of this use case is already covered by a lower-level
  test for makeModuleResponse(). The added case here exists
  to cover the wrapper method, ResourceLoader::respond().

- Cover logic for catching and logging internal errors.

Change-Id: I4315bb00137ff80ee2b790c6b4d4b5fbd93f6bc1
2018-05-30 18:30:42 +01:00
Aaron Schulz
0b5ed025e9 rdbms: do not silently rollback empty transactions on error
Since there might be important view snapshots, temp tables, or effects
from SET statements or the like, go into TRX_ERROR state for "possible
transaction level errors" even if no recognized writes took place and
the transaction was not explicit.

Change-Id: I32c34bc28b845e343d0167a220412824838eaed8
2018-05-30 03:10:02 +00:00
Reedy
6b6c71558e Fix PreferencesForm alias
Change-Id: I6f24c6283b4165b9209e53f8fc3b8ecb5feb9ca4
2018-05-29 21:44:18 +00:00
Umherirrender
1cee41b9dc Call Database::timestamp in some tests
Also add non-optional database fields to insert.
The fields are defined with a default in mysql,
but not in postgres or oracle.

Bug: T195807
Change-Id: I201638e3438cb0e5004f8da121e64a770e6a8fca
2018-05-29 22:28:36 +02:00
jenkins-bot
9a987e3c44 Merge "Xml.php: Do not escape double quotes in $contents of Xml::element()" 2018-05-29 19:26:33 +00:00
jenkins-bot
e19e52c8e0 Merge "API: ApiBase::getParameter() shouldn't throw on other params' errors" 2018-05-29 19:04:28 +00:00
jenkins-bot
ae9898e536 Merge "Remove deprecated wgResourceLoaderLESSImportPaths" 2018-05-29 17:19:23 +00:00
jenkins-bot
7ee4dbd7e6 Merge "Improve ExtensionRegistry test coverage" 2018-05-29 17:18:20 +00:00
Timo Tijhof
eaf40e6dd5 Remove deprecated wgResourceLoaderLESSImportPaths
The last remaining users of this feature were MobileFrontend and Minerva,
which have been migrated to direct imports.

Bug: T140807
Change-Id: I1a66a2ad314bde332297798520e5ec3e0e3d4c9b
2018-05-29 15:49:28 +01:00
Timo Tijhof
af340d58b7 resourceloader: Add coverage for empty case in makeModuleResponse
Adds coverage for line 1049-1056.

Also, follow-up 6292d54dff by simpliying the regex by using /s modifier to
enable PCRE_DOTALL which includes matching of new lines.

Change-Id: Icec34dfe107d418951b3d155234295c79410ffaa
2018-05-29 03:05:41 +01:00
Brad Jorsch
24be43b9aa API: ApiBase::getParameter() shouldn't throw on other params' errors
This regression was introduced in Ia19a1617b7.

Bug: T195777
Change-Id: I1e1eb3861ced83f79e56d2325ab693ef4e393999
2018-05-28 18:45:24 -04:00
jenkins-bot
7bfc0f42a3 Merge "Send a cookie with IP/IP-Range blocks when blocking logged-out users" 2018-05-28 13:35:21 +00:00
jenkins-bot
474daae531 Merge "resourceloader: Include global LESS variables in LESS cache key" 2018-05-28 11:36:32 +00:00
Kunal Mehta
b165908616 Improve ExtensionRegistry test coverage
Change-Id: Id1b87e020a220c96b42d86485da67d47b9d565f9
2018-05-27 20:36:41 -07:00
Timo Tijhof
6292d54dff resourceloader: Add coverage for non-js error case in makeModuleResponse
Adds coverage for line 1170-1175.

Change-Id: I2208264d3fca306b2740b243d7cdc209b224ebca
2018-05-28 00:48:40 +00:00
jenkins-bot
ea4807d64e Merge "Complete test coverage of Hooks class" 2018-05-27 20:28:21 +00:00
Kunal Mehta
cac3ce5668 Complete test coverage of Hooks class
Change-Id: I9e720c44e6d6c9c5d726a8a147e07ee9b638913f
2018-05-26 23:38:28 -07:00
Kunal Mehta
dc4fb23cfa Improve AutoLoader test coverage
Change-Id: Iddb24cad41979a4798392ab08d104dac41ed736d
2018-05-26 21:29:36 -07:00
jenkins-bot
468690e036 Merge "Rename ApiQueryContributions to ApiQueryUserContribs to match api module name" 2018-05-26 23:57:30 +00:00
Kunal Mehta
e298f548f6 Split AutoloaderTest into a structure and class test
AutoloaderTest covers the AutoLoader class, and AutoLoaderStructureTest
covers the structure part of the test.

Change-Id: Ic4e7bfd670e1c3413631bda31260cc1cc825b1a2
2018-05-26 16:16:02 -07:00
Reedy
0be39da9b0 Rename ApiQueryContributions to ApiQueryUserContribs to match api module name
Change-Id: I865628b87eda7be349522fcfaf94f5563142026e
2018-05-26 23:07:15 +00:00
Aaron Schulz
8880a25112 rdbms: make runOnTransactionIdleCallbacks() reset DBO_TRX on exceptions
Change-Id: Ibbb2a3ebf9dd970772ee704aa643a3843f20a3b5
2018-05-25 23:40:47 +00:00
Brad Jorsch
ad5d360a61 MediaWiki\Auth\Throttler: Change "ip" key name
Apparently 'ip' is overwritten by logstash at some level, so use 'ipKey'
instead.

Change-Id: I0547acdbb9f3fc7a990bd4baa2d748e89bac8c3b
2018-05-25 15:55:19 -04:00
Alexia E. Smith
8a1da0a43b resourceloader: Include global LESS variables in LESS cache key
This prevents cache churn when the wiki-global LESS variables vary
between wikis because the cache key is used as a "global" instead of
db-local. This is good for the common case, but should still explicitly
vary if the vars differ between wikis.

Bug: T191937
Change-Id: If12fd07a7062792205384150d6f5fd9a83f996cc
2018-05-25 18:13:10 +00:00
James D. Forrester
9d875febd5 Bump PHP version requirement to 7.0.0+
Bug: T172165
Change-Id: I740f32ac859d9bb3787fdf8414f82ae6f410492f
2018-05-24 16:15:56 +01:00
jenkins-bot
9957322e44 Merge "resourceloader: Move style deprecation warnings to <body>" 2018-05-24 13:03:21 +00:00
jenkins-bot
b37772a991 Merge "Add ability to filter based on rc_title in API" 2018-05-24 10:13:06 +00:00
Dayllan Maza
e8063a0846 Send a cookie with IP/IP-Range blocks when blocking logged-out users
A cookie will be set when ip users try to edit and their IP has been
blocked or if they try to create an account and the block prevents
account creation

This feature is disabled by default and can be enabled by
setting the new $wgCookieSetOnIpBlock config variable to true.

Note: this is meant to discourage vandals that try to avoid blocks by
switching their ip address while editing anonymously.

Bug: T152462
Change-Id: I0b78a5e174bcd882edea39e868a08f9a347f5aba
2018-05-24 00:48:05 -04:00
jenkins-bot
ce166f1031 Merge "IP: Fix sanitization of IPv4 ranges" 2018-05-24 00:31:31 +00:00
Kunal Mehta
e0193327bd Fix MediaWiki.Commenting.LicenseComment.InvalidLicenseTag errors
Change-Id: I936c3f5fca1a0061f215e80469f5d882cb32ee29
2018-05-23 16:23:42 -07:00
Fomafix
37789ebf45 Xml.php: Do not escape double quotes in $contents of Xml::element()
There is no need to escape double quotes in content of XML.
Html::element() also does not escape double quotes in content.

ENT_NOQUOTES escapes '<', '>' and '&' but not "'" and '"'.
https://secure.php.net/manual/en/function.htmlspecialchars.php

Change-Id: I3b585c43e532cca1a8951d6c9e8b4825fc3b012d
2018-05-23 20:03:54 +00:00
Florian Schmidt
32be7421b1 WatchAction::onSubmit return correct value, not always true
The onSubmit method documentation states, that the caller can expect either
true for a successfull run, false if not tried and an array of error messages
in case of an failure. WatchAction however always returned false, even though
a Status object is availble with all needed information.

The behaviour of WatchAction::onSubmit is now changed to return the appropriate
value taken from the returned Status object of WatchAction::doSelf.

Also:
 * Added WatchAction test class to higher test coverage, especially for the
   static methods
 * Marked getUnwatchToken as deprecated, it's not used and a caller can easily
   switch to getWatchToken with "unwatch" as the action parameter

Change-Id: I2c1b91e1884a0d5f27f5e7ab9eafd6173642c21c
2018-05-23 20:36:37 +02:00
Brad Jorsch
57445f0425 IP: Fix sanitization of IPv4 ranges
'000.000.000.000/24' should sanitize to '0.0.0.0/24', not
'0.0.0.000/24'.

Change-Id: I9364cb268dcc9b9b24aa1c627a87482978c4cf34
2018-05-23 10:34:20 -04:00
jenkins-bot
1c62e5784b Merge "ContentSecurityPolicy: Add trailing & to report urls" 2018-05-23 11:22:12 +00:00