Commit graph

6598 commits

Author SHA1 Message Date
jenkins-bot
1194189297 Merge "docs: Remove 'code-coverage' placeholder directory" 2019-01-31 00:01:57 +00:00
jenkins-bot
ab50a9fbf6 Merge "RemexCompatMunger: Don't split p-wrapping on style/link tags" 2019-01-30 23:39:34 +00:00
jenkins-bot
b7499cecc6 Merge "Password: replace equals() with verify()" 2019-01-30 23:04:08 +00:00
Thiemo Kreuz
4b71077646 Remove a few obscure "done" and "empty" comments
These don't add any knowledge to what is already obvious from the
code, I find.

Change-Id: Ia613b6a059f78dbeefdfd020899bd1a6e239a731
2019-01-30 20:35:14 +00:00
Brad Jorsch
4597559d84 RemexCompatMunger: Don't split p-wrapping on style/link tags
<style> and <link> tags are metadata tags, they shouldn't split the <p>
tag when p-wrapping content.

Bug: T208901
Change-Id: I2ef5da68c9ccde4477d8295dfe4abf8497c5d26e
2019-01-30 09:10:24 -08:00
Kunal Mehta
b6b10bb58f Require ClassMatchesFilename sniff to pass for most of tests/
phpunit-patch-coverage assumes that the filename matches the classname
as a performance optimization. And for most test cases, this is true. We
should enforce this with PHPCS, mostly to help developers not make
mistakes.

Test cases that have mock classes will need to ensure that the test case
class that matches the filename comes first, since that's the only class
the sniff will look at.

Tests in GlobalFunctions/ and maintenance/ are still exempted for now,
since they don't match yet.

Change-Id: Iede341504290f5ba2da1c81908069ba9d465600f
2019-01-29 23:57:12 -08:00
Kunal Mehta
7eb3d87742 Rename UncategorizedCategoriesPageTest to match class name
Change-Id: Iedf32a15e0a8cb79a2823ccffa3b486a38fb1dc6
2019-01-29 23:21:13 -08:00
Kunal Mehta
951690c02e Rename tests/phpunit/includes/media files to match class names
The classes were renamed in 9bf39163, this updates the test cases to
match. Also take care of XCF while we're at it too.

Change-Id: Iaaeee93e496af6cdd610df5bc75302ecfe273f64
2019-01-29 23:21:13 -08:00
Kunal Mehta
8ff88cc4d2 Use TestingAccessWrapper in FormOptionsInitializationTest
Avoids the need for an extra wrapper class just to make a property
public.

Change-Id: I08ae2fb24604a2bde352525abdcadf6251045f5b
2019-01-29 21:33:42 -08:00
David Barratt
e865b57cbe Add Namespace Restrictions to Special:BlockList
The editing restrictions will be split by type and add a heading for each type.
The namespace will be linked to Special:AllPages with the namespace set so the
user can see what pages the user is blocked from.

Bug: T204990
Change-Id: Idb1de20c1a780562b072ea350e5ba7dd1518d177
2019-01-28 18:37:58 +00:00
zoranzoki21
c54be9ac6b Fix typo in tests/phpunit/includes/Revision/MainSlotRoleHandlerTest.php
Bug: T201491
Depends-On: I47530e01d8061d6826deaf0b9111d77a0b269d0a
Change-Id: Iaf1abd06cd35444cf4c6c4edef65f973089579c1
2019-01-28 10:19:50 +00:00
Timo Tijhof
73be70fca1 docs: Remove 'code-coverage' placeholder directory
In 8 years, this is the first time I see this directory exists
and that there is a Makefile that would write to it.

I don't know if anyone uses that, but PHPUnit auto-creates this
directory as needed. Hence, it need not exist ahead of time.

It seems most contributors generate code coverage by invoking
PHPUnit directory, which requires a path to be specified.

Per https://mediawiki.org/wiki/Manual:PHP_unit_testing/Code_coverage,
this tends to be docs/coverage, not docs/code-coverage.

Change the Makefile to write there as well, as better example,
and also add it to gitignore.

Change-Id: I0a4cf716ea9b7fae89c282945b160b0dc7b2d02f
2019-01-25 18:35:46 -08:00
Dayllan Maza
85c91cfbf0 Add namespace restrictions to block's log messages
Currently, there are 3 block messages: sitewide, partial with restrictions, and
non-editing partial blocks. This will add namespace restrictions to the
partial editing blocks message type.

Bug: T204985
Change-Id: Ic17d5459e67c267fdee1fb2513d67428148ac85d
2019-01-25 15:46:11 -05:00
jenkins-bot
247724d82c Merge "Don't check anon permissions for maint scripts in autoCreateUser()" 2019-01-25 02:22:32 +00:00
James Montalvo
ddf37fec6d
Don't check anon permissions for maint scripts in autoCreateUser()
AuthManager::autoCreateUser() causes createAndPromote.php to give error
"Automatic account creation is not allowed." when
$wgGroupPermissions['*']['createaccount']=false is set. Anonymous user
checks should be skipped for maintenance scripts.

Change-Id: Ib61889a758e542abe991707d8b7853a25cfed8e9
2019-01-24 17:45:10 -08:00
Bill Pirkle
e8cb9f5f83 http: Support callback functions in GuzzleHttpRequest
Provide backward compatibility for callback functions in
GuzzleHttpRequest, which was missing in T202110, and restore
GuzzleHttpRequest as the default provided by HttpRequestFactory.

Bug: T212175
Depends-On: I4b45e79d35252d13f714f3271b87301ca515121a
Change-Id: I60d1a034b44874f6d24a04058db264eeb565f5e1
2019-01-24 22:05:10 +00:00
Max Semenik
7a7976ba7a Password: replace equals() with verify()
So far, our key derivation code assumed that it has control over
the salt used by the derivation routines, however I want to add Argon2
support and it doesn't work this way: password_hash() generates the
salt itself, and the only way to verify a password is by using
password_verify(). Current way the things are done doesn't support it
because it relies on the result of password hashing with parameters we
provide to be deterministic.

Therefore, I'm deprecating Password::equals(), as well as whole concept
of comparing Password objects - it's used only in tests anyway. It's
getting replaced with verify() that only accepts password strings.
Uses of old function are fixed with exception of a few calls in tests
that will be addressed in my Argon2 patch.

Change-Id: I2b2be9a422ee0f773490eac316ad81505c3f8571
2019-01-24 13:40:40 -08:00
David Barratt
8631ea7bf6 Add tests to ensure that NamespaceRestrictions are returned from Block APIs.
Bug: T204989
Change-Id: Ibe44da41e9efa6688615dc9b0712f9713d4e8158
2019-01-23 21:31:12 +00:00
jenkins-bot
904049846c Merge "Fix Title::getFragmentForURL for bad interwiki prefix." 2019-01-23 20:02:52 +00:00
jenkins-bot
24b5967313 Merge "Add namespace restrictions to Special:Block and API" 2019-01-23 17:04:55 +00:00
jenkins-bot
dfa8b14e21 Merge "Add NamespaceRestriction class so that BlockRestriction can handle namespaces." 2019-01-23 12:39:55 +00:00
daniel
337311662d Fix Title::getFragmentForURL for bad interwiki prefix.
Calling Title::getLinkURL or any other method that relies on
getFragmentForURL on a title with an unknown interwiki prefix
was triggering a fatal error. With this patch, that situation is
handled more gracefully.

Bug: T204800
Change-Id: I665cd5e983a80c15c68c89541d9c856082c460bb
2019-01-23 11:17:21 +01:00
jenkins-bot
f7ead5d3ca Merge "Better detection for old MS Office files" 2019-01-23 01:01:43 +00:00
Tim Starling
f12db38048 Better detection for old MS Office files
* Introduce MSCompoundFileReader, which reads the CFB directory and
  detects the file type from well-known names in the root directory
* Do not detect a ZIP file if the EOCDR is not at the end. Other
  containers, especially CFB files, may contain ZIP files embedded
  within them in the last 64KB, but this is not a security concern
  unless the EOCDR is exactly at the end of the file.

Bug: T40432
Change-Id: Id5b1a258ccf3c3c8951e32f6b7a5b1bafe941082
2019-01-23 09:23:17 +11:00
jenkins-bot
bf5050d564 Merge "Convert RandomImageGenerator to use the new execution framework" 2019-01-22 19:33:49 +00:00
Thalia
f589214d0f Add namespace restrictions to Special:Block and API
This adds a UI for blocking namespaces to Special:Block
and a namespacerestrictions parameter to the block API.

The number of namespace restrictions in a single block
is not limited as page restrictions are.

The checkbox allowing the blocker to specify whether
the target can edit their own user page is normally
disabled for a partial block, but is re-enabled if
the block is to the user talk namespace.

If the config $wgBlockAllowsUTEdit is set to false, the
checkbox will not appear, and the target will not be
able to edit their own user talk page if they are
sitewide-blocked, namespace-blocked from the user talk
namespace, or page-blocked from their user talk page.

Bug: T204986
Change-Id: I9e231ad109d7285486ec332b26780339592b8df7
2019-01-22 12:48:55 +00:00
Timo Tijhof
aed9f32e04 tests: Remove use of $IP and MediaWikiTestCase in libs/composer tests
Reference the fixture files relatively instead of absolutely,
this is done for most other references to data files as well
I believe.

Use plain arrayEquals(), which seems to suffice here. In PHP 7 at
least, regular == doesn't require the declaration order of the
keys to be the same in order to evaluate to true.

Change-Id: Iddc874ec811f5c960e13d480d70bcb20334cfa1e
2019-01-22 08:01:36 +00:00
Max Semenik
f735507bfc Convert RandomImageGenerator to use the new execution framework
Introduces a stringifier for Command, useful for debugging.

Change-Id: Ifcfccaef5a609e0cf30186e39a6bd0fa971c2dbd
2019-01-21 22:33:02 -08:00
David Barratt
be27181956 Add NamespaceRestriction class so that BlockRestriction can handle namespaces.
This begins work on making namespaces a valid restriction type. The CRUD
operations of BlockRestriction can now handle namespaces. Since
NamespaceRestriction implements Restriction, enforcement should start working
immediately, but testing enforcement will come in a subsequent patch since it's
impossible to create them.

Bug: T204991
Change-Id: I7264b452d9ad788c146d6ea25d01d4d7cb5ac4f6
2019-01-21 14:19:39 +00:00
daniel
54c70c3551 Deprecate Content::getNativeData, add TextContent::getText
getNativeData() is under-specified - callers can do nothing with the
value returned by getNativeData without knowing the concrete Content
class. And if they know the concrete class, they can and should use
a specialized getter instead, anyway.

Basically, getNativeData is overly generic, an example of polymorphism
done poorly. Let's fix it now.

Bug: T155582
Change-Id: Id2c61dcd38ab30416a25746e3680edb8791ae8e8
2019-01-16 11:57:50 -08:00
Lucas Werkmeister
7585985a46 Fully extract services framework as a library
This code doesn’t use any MediaWiki-specific code, so rename
MediaWiki\Services to Wikimedia\Services and move it below libs/. (Of
course, this does not apply to the MediaWikiServices subclass.)

Class aliases are added to retain backwards compatibity for now.

Bug: T211608
Change-Id: Ic14ea28ef21c359695b309d4293dbaaf5deedc09
2019-01-16 17:31:05 +01:00
Bartosz Dziewoński
1805fd3be5 resourceloader: Avoid unnecessary xmlns attributes in ResourceLoaderImage
We were creating the `<g>` element without specifying a namespace,
which caused the library to add `xmlns` attributes with the document's
default SVG namespace to elements that we appended underneath it.
(At least, that's what I think was happening.)

Specify the SVG namespace when creating it to avoid the mess and
reduce resulting file size.

Change-Id: Ida27494aeae9dece16f878c16cf9aa582e6deac3
2019-01-16 02:22:45 +00:00
jenkins-bot
bda1de61c2 Merge "resourceloader: Avoid toplevel <title> under <g> in ResourceLoaderImage" 2019-01-16 00:39:29 +00:00
Bartosz Dziewoński
d6043347c3 resourceloader: Avoid toplevel <title> under <g> in ResourceLoaderImage
While it shouldn't be causing any rendering problems,
doing so is semantically incorrect.

Bug: T213507
Change-Id: Ic86cd2bf3028eb24ad60db7ffa9498dd86edd4a5
2019-01-15 22:48:54 +00:00
Thiemo Kreuz
c3dfa88966 Add missing empty lines between methods
This might hint at an edge-case in the PHP CodeSniffer sniff that should
detect if methods are separated by a single empty line. Feel free to
investigate. I, personally, can't invest more time in this than
suggesting this quick fix.

Change-Id: Ib3c60eac76f255b4fe929f7933de256222716576
2019-01-15 19:14:35 +00:00
Kunal Mehta
2ff1827b6e registration: Allow overriding attributes in tests
ExtensionRegistry is a rather special singleton that can't use the normal
MediaWikiServices reset due to its early initialization, so introduce
a ->setAttributeForTest method to override attributes that are typically
loaded from extension.json.

Bug: T200013
Change-Id: I9e62a02ed2044c847e9ab2dcdfab094001f88986
2019-01-14 12:47:10 -08:00
zoranzoki21
c3f45c864a Fix Revison typo
Bug: T201491
Change-Id: I4a91d64dafdafd022462730c221cdf2a113d2ef2
2019-01-11 05:18:20 +00:00
Amir Sarabadani
a4880e9bbf Fix order of arguments in ChangeTags::getPrevTags
Bug: T212703
Change-Id: I9e38c999718762daeb5c155ea8eaaa5d16dd85c1
2019-01-09 10:14:40 +01:00
Brian Wolff
8c7b635162 Relax filter attribute filtering to allow self-referential urls
The filter attribute will often have things like filter="url( #foo )"
These local to the file filters in svgs should be fine (We already
disallow non-local xlink:href attributes on <filter> elements). In
fact, users can already do the exact same thing by doing:
style="filter: url( #foo )"

Bug: 67044
Change-Id: Ib25328c160c0d5ea7e01dc84616b76e1b9dcd0eb
2019-01-08 14:37:53 +00:00
jenkins-bot
b2017a11a8 Merge "Revert "Revert "Title::checkUserBlock should call User::isBlockedFrom for every action""" 2019-01-08 07:00:20 +00:00
jenkins-bot
dae39db4e3 Merge "Add force option to password policy" 2019-01-07 16:59:55 +00:00
Tchanders
58938095e2
Revert "Revert "Title::checkUserBlock should call User::isBlockedFrom for every action""
This reverts commit 91fc748030.

Hence it reapplies I6312a36911e5b73d773452fefef7ff25b9af08a4.

The changes made by this commit are (excluding the cases
checked for earlier):
* An action can only be blocked if prevents() is true/null and
isBlockedFrom() is truthy. Previously, any action other than
'edit' or 'create' would be blocked if prevents() was true/null,
regardless of isBlockedFrom().
* If an Action can be constructed, and requiresUnblock() is
false, the action won't be blocked. Previously, requiresUnblock()
wasn't checked.

This commit was previously reverted because it exposed that
EditEntityAction::requiresUnblock in Wikibase wrongly returned
false (fixed in I99061230023da2bbd0f98190a2907ca2e9717a4c).
Other potentially similar cases were audited in T211048.

Bug: T208862
Change-Id: If74a1d422290b8c62b7a7a8922621c73c9598269
2019-01-07 09:40:12 -05:00
jenkins-bot
5289374989 Merge "Remove duplicate assertion in SpecialBlockTest" 2019-01-03 19:25:50 +00:00
Thalia
34bf9ac381 Remove duplicate assertion in SpecialBlockTest
Change-Id: I55d0112a8e3acf06fdfca979552a2746ae928c4f
2019-01-03 17:06:50 +00:00
jenkins-bot
c81e1506c6 Merge "Unbreak Pbkdf2PasswordTest" 2019-01-02 21:48:11 +00:00
Gergő Tisza
f15ecc60cd
Add force option to password policy
Adds a way to set an array of options for a password policy. Currently
there is one option, 'forceChange', which forces the user to change
their password (if it fails the given check) before logging in.

Bug: T118774
Change-Id: I28c31fc4eae08c3ac44eff3a05f5e785ce4b9e01
2019-01-02 12:38:11 -08:00
jenkins-bot
d13dab17a9 Merge "Add missing property declarations to LocalFileTest" 2019-01-02 16:22:06 +00:00
Thiemo Kreuz
c0e27fba86 Add missing property declarations to LocalFileTest
Change-Id: I518a7a939042110f7ca67b0697e35e2e35105a08
2019-01-02 15:25:44 +01:00
Max Semenik
9c5174669e Unbreak Pbkdf2PasswordTest
Due to https://github.com/sebastianbergmann/phpunit/issues/3459 it was
looking for a wrong function name and was skipping the test even when PHP
support was present.

Change-Id: I2508f192a76275286e95bd6a06e4628d98b11737
2019-01-02 00:21:13 -08:00
Max Semenik
032f640afb Remove unused line
Change-Id: I4bc6ec69b84b5f29e3c4c7833697f4d2be82e29a
2019-01-02 00:15:57 -08:00