Commit graph

6700 commits

Author SHA1 Message Date
jenkins-bot
fec45ad99a Merge "resourceloader: Support passing extra arguments to packageFiles callback" 2019-10-21 22:08:09 +00:00
Andrew Otto
e35f53316c resourceloader: Support passing extra arguments to packageFiles callback
Currently packageFiles callbacks take 2 parameters, $context and $config.
This patch allows for specifying an extra parameter in the packageFiles
definition that will be passed to the callback.  Example:

  'callback' => function ( $context, $config, $extra ) { ... },
  'callbackParam => [ 'this is val 1', 'this is val 2' ],

The callback will be called with the usual $context and $config
parameters, and the extra array is passed as third parameter.

Bug: T233634
Change-Id: Ie11874665f4f9a557d4e394dcab3a972887e8126
2019-10-21 15:07:53 -04:00
jenkins-bot
abfea4c7ff Merge "Add faux SearchResult and SearchResultSet" 2019-10-21 09:37:50 +00:00
Tchanders
a6533885b8 Revert "Revert "Store block reasons as CommentStoreComments in block classes""
This reverts commit 5f06efb318, which
reverted 9335363789, which makes
the deprecated property AbstractBlock::mReason private.

After 9335363789, AbstractBlock::mReason is obsolete, since the block
reason is now stored as a CommentStoreComment, AbstractBlock::reason.

Change-Id: Ica0a74be90383689ca8e4cfe6d0fb25c9a5942c5
2019-10-20 10:41:17 +01:00
Daimona Eaytoy
5f06efb318 Revert "Store block reasons as CommentStoreComments in block classes"
This reverts commit 9335363789.

Reason for revert: It's full of code accessing AbstractBlock::mReason
out there, see [1]. Also, it was never hard deprecated. While that may
be acceptable under some circumstances, it's definitely not OK to remove
code when there are consumers around. I'd have fixed it right now without
reverting if it were a single repo, but there's just too many.

[1] - https://codesearch.wmflabs.org/search/?q=-%3EmReason&i=nope&files=&repos=

Change-Id: I8669f502b50cff89e28dada0f65fe2b130ae9b37
2019-10-19 18:55:45 +00:00
Thalia
9335363789
Store block reasons as CommentStoreComments in block classes
AbstractBlock::setReason now accepts a string, Message or
CommentStoreComment. The CommentStoreComment is accessed via
AbstractBlock::getReasonComment.

AbstractBlock::getReason returns the reason as a string, with
the language and format consistent with how block reasons were
built before this commit. This method is deprecated, since it
makes assumptions about the language and format needed. The
deprecated mReason property is no longer public.

Doing this (and T227005) will remove the implicit dependency of
BlockManager::getUserBlock on language, which causes a recursion
error if the block is checked before the user has loaded. It also
provides a mechanism for getting the block reason in a language
specified by the caller. (This does not apply to DatabaseBlock
reasons entered via the Special:Block form, which were not and
are still not translatable.)

This commit also updates authentication classes to return the
translated reason.

Bug: T227007
Change-Id: Iec36876e930dff96a256aebbdc39cbfb331c244e
2019-10-18 17:47:56 -04:00
jenkins-bot
e8e122a86a Merge "Parse type parameters in Accept headers" 2019-10-18 16:44:54 +00:00
jenkins-bot
7d93d261ac Merge "Move countRevisionsBetween from Title to RevisionStore" 2019-10-18 14:29:04 +00:00
jenkins-bot
7a9fbd750d Merge "Remove deprecated method ApiQueryUserInfo::getBlockInfo" 2019-10-17 15:19:36 +00:00
Petr Pchelko
6eb67c752e Move countRevisionsBetween from Title to RevisionStore
Bug: T235666
Change-Id: Ib404d29a662de7736b50a1d07380f651d332ad6b
2019-10-17 08:02:26 -07:00
jenkins-bot
644e0727d8 Merge "session: Add debug message for the used store class" 2019-10-17 11:05:23 +00:00
Timo Tijhof
f2e6fab93f session: Add debug message for the used store class
Follows-up 70cb266480.

Bug: T234361
Change-Id: Ifd6616b1a31f6cb915ec553865e999fcd974784e
2019-10-17 03:52:36 +00:00
daniel
e1f8a8148d SqlBlobStore HOT FIX: remove caching from getBlobBatch
This is a TEMPORARY HACK to fix a problem with cached values
getting mixed up when using getBlobBatch(). As of the creation of this
patch, the actual cause is unknown. Caching should be put back once the
cause of the problem has been found.

Note that getBlobBatch is only used in maintenance scripts.
Removal of caching in that method has no effect on web requests.

getBlobBatch() was introduced in I56306c50a661 and is used by
RevisionStore::getContentBlobsForBatch(), which in turn is needed
by the Translate extension to remove its dependency on the deprecated
rev_text_id field.

Bug: T235188
Change-Id: I94c6f9ba7b9caeebaa9b055916f15f7bbdcd8fb6
2019-10-16 23:02:52 +00:00
Thalia
7bbda9811b Remove deprecated method ApiQueryUserInfo::getBlockInfo
Change-Id: Ib291a7893cde780c3505f7cd499e222410e0efa9
2019-10-16 20:46:02 +01:00
Thalia
5310373336 Stop accessing User::mBlock and User::mBlockedby from tests
Update PermissionManagerTest and FormSpecialPageTestCase to use a
mock User object that returns a specified block.

Before this commit, these tests manipulate the public properties
User::mBlock and User::mBlockedby in order to change the user's
block. There is no advantage to doing this over mocking: it is not
more realistic, and is sensitive to changes in the code. These tests
need updating in order to deprecate public access to these properties
(see T229035).

Also, PermissionManager::testUserBlock is a large, complicated method
that tests three different things, so split it into three smaller
methods, each testing one thing:
* testCheckUserBlockActions: A blocked user is blocked/unblocked
  correctly from certain actions, depending on their block.
* testCheckUserBlockMessage: The correct block message key and
  parameters are returned, depending on the block.
* testCheckUserBlockEmailConfirmToEdit: A user is or isn't asked to
  provide email confirmation in order to edit, as specified by the
  config.

Change-Id: I0bb9252b476131c2b255d4c503c0dab5dfff94be
2019-10-15 15:05:53 +00:00
jenkins-bot
b98df63e65 Merge "UserTest: Don't assign mBlock manually, it's done by BlockManager" 2019-10-15 15:04:09 +00:00
Thalia
cf8516d427 UserTest: Don't assign mBlock manually, it's done by BlockManager
Before this commit, several tests in UserTest set User::mBlock, then
call BlockManager::trackBlockWithCookie, which indirectly sets
User::mBlock. These lines are safe to remove, ahead of deprecating
public access to the property (see T229035).

Change-Id: I36a833ee0904ed1573ac414c8524b60210d97feb
2019-10-15 14:50:20 +00:00
James D. Forrester
83d76f4cb5 phpcs: Enable MediaWiki.Commenting.PhpunitAnnotations.ForbiddenExpectedException* and make pass
Change-Id: I63f97497714a32236268be6965c5e181dade6c58
2019-10-14 12:48:48 -07:00
jenkins-bot
a03feb8ab0 Merge "SqlBlobStore: test caching behavior." 2019-10-14 14:24:26 +00:00
daniel
46bb49dbfd SqlBlobStore: test caching behavior.
Something is going wrong with the way we use WANObjectCache in
getBlobBatch. This patch introduces a test case that should help narrow
down the cause.

Bug: T235188
Change-Id: I2d06c09609874440992e6c90d3ebfa15400ac302
2019-10-14 14:01:06 +00:00
jenkins-bot
7d7b43aa7c Merge "rdbms: various cleanups to LoadBalancer::reallyOpenConnection()" 2019-10-12 05:26:54 +00:00
Umherirrender
f59e308097 Remove extra param comment and enable phpcs rule
Cleanup .phpcs.xml a bit

Change-Id: I65d99cc933c3fe22bbca3be3258761add4b2024f
2019-10-11 21:36:25 +02:00
Aaron Schulz
fb621c26a3 rdbms: various cleanups to LoadBalancer::reallyOpenConnection()
Move the DBO_TRX init logic out of Database::__construct() and into
LoadBalancer since the later already handles setting and clearing this
flag based on transaction rounds starting and ending.

Add 'lazyMasterHandle', 'topologyRole', and 'topologicalMaster' parameters
to Database::factory() and inject them via LoadBalancer all at once in order
to avoid worrying about call order. Move some type casting code to
Database::__construct().

Add IDatabase::getTopologyRole()/getTopologicalMaster().

Use constants for getLBInfo()/setLBInfo() for better usage tracking and
typo resistance.

Change-Id: I437ce434326601e6ba36d9aedc55db396dfe4452
2019-10-11 11:35:02 -07:00
James D. Forrester
9be9e77b51 build: Upgrade mediawiki-codesniffer from 26.0.0 to 28.0.0
Newly-disabled general rules:
* MediaWiki.Commenting.FunctionComment.MissingSplatVariadicArg
* MediaWiki.Commenting.FunctionComment.SuperfluousVariadicArgComment
* MediaWiki.Commenting.PhpunitAnnotations.ForbiddenExpectedException
* MediaWiki.Commenting.PhpunitAnnotations.ForbiddenExpectedExceptionMessage
* MediaWiki.Commenting.PhpunitAnnotations.ForbiddenExpectedExceptionMessageRegExp
* MediaWiki.Usage.NullableType.PHP71NullableStyle
* MediaWiki.Usage.PHPUnitTypeHints.MissingTypehint
* PSR12.Files.ImportStatement.LeadingSlash
* PSR12.Properties.ConstantVisibility.NotFound

Change-Id: Ifcf8c6d5fecc47a32741114b5a5b746a41510045
2019-10-11 10:05:43 -07:00
Arlo Breault
e14158d6d7 Parse type parameters in Accept headers
Change-Id: I421cfd8b2271dff50b5de747700b0a8d0cbf849c
2019-10-10 22:16:23 -04:00
James D. Forrester
b83a3e3e3a Follow-up Ifa346c8a92: LanguageNameUtils: CONSTRUCTOR_OTPIONS, not constructorOptions
Change-Id: I357dddf39834e9eed4b173245033d2f27edab329
2019-10-10 17:01:49 -07:00
Umherirrender
5bd311b1a2 Add public as visibility in tests folder
Add public, protected or private to function missing a visibility
Enable the tests folder for the phpcs sniff

Change-Id: Ibefce76ea9984c47e08c94889ea2eafca7565e2c
2019-10-10 21:55:37 +02:00
jenkins-bot
b02b2704b9 Merge "NameTableStore: ensure consistency upon rollback." 2019-10-10 15:40:17 +00:00
daniel
135673b98e NameTableStore: ensure consistency upon rollback.
This ensures consistent behavior when an ID for a name is first acquired
within a transaction that is rolled back. The documentation for acquireId
now reads:

@note If called within a transaction, there is a chance for the acquired ID to be lost
if the transaction is rolled back. A best effort is made to re-insert the mapping
after a rollback, and consistency of the cache with the database table is ensured
by re-loading the map after a failed transaction. However, there is no guarantee
that an ID returned by this method is valid outside the transaction in which it
was produced. This means that calling code should not retain the return value beyond
the scope of a transaction, but rather call acquireId() again after the transaction
is complete. In some rare cases, this may produce an ID different from the first call.

Bug: T224949
Change-Id: I6d05e4112a649675bfb9083cab2d1bbe394e65b3
2019-10-10 12:03:29 +02:00
jenkins-bot
daab23d1b3 Merge "Clear block cookie when tracking block, not when checking block" 2019-10-09 22:32:40 +00:00
jenkins-bot
85f022b7eb Merge "Export $wgMainPageIsDomainRoot in siteinfo API" 2019-10-09 16:17:19 +00:00
Thalia
235cade5a3 Clear block cookie when tracking block, not when checking block
Before this commit, clearing a block cookie happens as a
side-effect of checking for a block cookie. After, a block cookie
is cleared if trackBlockWithCookie finds that there should be no
block cookie, but there is one.

Bug: T233595
Change-Id: Id5777361f95c60d2849cacba82f2ed9add647abf
2019-10-09 14:09:34 +01:00
jenkins-bot
a543d68c65 Merge "New LanguageFallback service" 2019-10-08 22:58:22 +00:00
Aryeh Gregor
8c4f59db64 New LanguageFallback service
This replaces the static Language methods getFallbackFor(),
getFallbacksFor(), and getFallbacksIncludingSiteLanguage(). There is
100% unit and integration test coverage for the new class.

One deliberate functional change: I changed one place where we threw
MWException to InvalidArgumentException.

Bug: T201405
Depends-On: Ie7a89f6ed7d52a0bc01672019ff92e7ee105a1f3
Change-Id: I49222eb55f1feec5b1dcd40f364cffe0c8801855
2019-10-08 15:11:39 -07:00
Max Semenik
fb252d5565 TextFormatterTest: Use mocks instead of manually creating classes
Change-Id: I85cb709f277f37279f2edbe58a441b8a4043fb27
2019-10-08 21:32:25 +00:00
jenkins-bot
52b44696ba Merge "Split some Language methods to LanguageNameUtils" 2019-10-08 21:10:07 +00:00
jenkins-bot
7982ca36bc Merge "Services: Convert DefaultPreferencesFactory's static to a const now HHVM is gone" 2019-10-08 20:45:53 +00:00
jenkins-bot
8db7eb1139 Merge "Introduce a formatter service for block errors" 2019-10-08 19:42:53 +00:00
James D. Forrester
17f3f9cee3 Services: Convert DefaultPreferencesFactory's static to a const now HHVM is gone
Change-Id: If24c5f120cb96311b50750c5b3022664dc6b20e5
2019-10-08 11:28:15 -07:00
James D. Forrester
662b27776b Services: Convert PasswordReset's static to a const now HHVM is gone
Change-Id: I77e0d9ce86cf96824eb672d0f35c32b5f4c484be
2019-10-08 11:26:17 -07:00
James D. Forrester
ebac0247cf Services: Convert LocalisationCache's static to a const now HHVM is gone
Change-Id: If5c015debed7efc034613b976bc5292ac30036d7
2019-10-08 11:25:30 -07:00
James D. Forrester
40c35286cb Services: Convert BlockManager's static to a const now HHVM is gone
Change-Id: I01d6e18fc30bd61ba7ea5ce1c7c646524579c4ba
2019-10-08 11:24:22 -07:00
James D. Forrester
9cba9f8567 Services: Convert PermissionManager's static to a const now HHVM is gone
Change-Id: Ib75b6f5d6b3e793ddbce42951693d8c99e6b7e57
2019-10-08 11:23:08 -07:00
jenkins-bot
05ce3b7740 Merge "Title: make newFromText, isValid, and canExist behave consistently." 2019-10-08 13:54:57 +00:00
jenkins-bot
2796f33ff5 Merge "Make Status::wrap and StatusValue::splitByErrorType work together" 2019-10-08 12:03:08 +00:00
Thalia
df20197250 Introduce a formatter service for block errors
The main reasons for adding this service layer are:
* It allows error messages to be more consistent, by defining
  a set of reportable information that can describe any block
  type and is consistently formatted.
* It decouples formatting from the block classes, removing
  their dependency on language, for the most part.

The service provides one public method, getMessage, which
returns a Message object whose key and parameters are
determined by the type of block. This should be used instead
of the deprecated AbstractBlock::getPermissionsError and
AbstractBlock::getBlockErrorParams.

Calls to AbstractBlock::getPermissionsError are replaced in
this patch.

Bug: T227174
Change-Id: I8caae7e30a46ef7120a86a4e5e6f30ae00855063
2019-10-08 12:29:23 +01:00
daniel
9171cbe4ca Title: make newFromText, isValid, and canExist behave consistently.
This patch fixes the documentation of newFromText and makeTitleSafe to
no longer state incorrectly that any Title they return is guaranteed to
be valid. That has never been true.

It also makes canExist() checks a lot stricter, to match the assumptions
of current callers, namely that the title can exist as a wiki page.

Finally, it replaces several existing calls to isValid() with calls to
canExist().

Bug: T229705
Change-Id: I2a483136ec6acca49afb5eb32cb94616672b8fb2
2019-10-08 11:16:11 +02:00
Aryeh Gregor
6d80b6c082 Split some Language methods to LanguageNameUtils
These are static methods that have to do with processing language names
and codes. I didn't include fallback behavior, because that would mean a
circular dependency with LocalisationCache.

In the new class, I renamed AS_AUTONYMS to AUTONYMS, and added a class
constant DEFINED for 'mw' to match the existing SUPPORTED and ALL. I
also renamed fetchLanguageName(s) to getLanguageName(s).

There is 100% test coverage for the code in the new class.

This was previously committed as 2e52f48c2e and reverted because it
depended on e4468a1d6b, which had to be reverted for performance
issues. There should be no changes other than rebasing.

Bug: T201405
Change-Id: Ifa346c8a92bf1eb57dc5e79458b32b7b26f1ee8a
2019-10-07 15:20:52 -07:00
jenkins-bot
32a33742b2 Merge "Make LocalisationCache a service" 2019-10-07 21:01:48 +00:00
jenkins-bot
2bf3cd85e6 Merge "Linker: Kill HHVM and PHP5 special case" 2019-10-07 20:57:22 +00:00