Commit graph

25 commits

Author SHA1 Message Date
James D. Forrester
eeb5a740b3 Namespace Message, move to appropriate directory
Bug: T353458
Change-Id: I088cbc53fbcdb974e5b05b45a62e91709dacc024
2024-02-14 15:10:36 -05:00
daniel
3d55397207 Move creation of BlockErrorFormatter into FormatterFactory
The idea is that all formatters that need the user language or
other request specific context should be instantiated by
FormatterFactory.

Change-Id: I8334cc89dcf0f293298b82e004116be50a90f0d1
2024-01-26 13:03:44 -05:00
jenkins-bot
d630a7f4f5 Merge "Add type hint for $ip in BlockErrorFormatter method" 2023-10-30 13:59:05 +00:00
Thalia
6da9d5b07f Add type hint for $ip in BlockErrorFormatter method
Change-Id: If9a48cb0b4e7c6a91ef6bd8123e70a1fe1f6fb65
2023-10-27 14:13:21 +01:00
Thalia
e521abbcd8 Display all error messages for a CompositeBlock
* Add getMessages method to BlockErrorFormatter that will get
  error messages for all the applicable blocks.
* Call getMessages from PermissionManager, UserAuthority and
  EditPage.
* ApiBase and UserBlockedError still call getMessage since
  they work with a single message.

Bug: T344463
Change-Id: If240562dd25435d9c6c824dd595d58bb8672de2b
2023-10-27 13:05:08 +01:00
Thalia
24a3dc58d6 Clean up BlockErrorFormatter and test
* Add type hint and return type
* Remove unnecessary request mock

Change-Id: I094090ca4d1314b8630220db3e720bc4ba39320e
2023-10-27 13:04:59 +01:00
James D. Forrester
b16be7a36c Namespace TitleFormatter under \MediaWiki\Title
One of the big ones, so doing this alone.

Bug: T166010
Change-Id: Ic2d59eb6764b1a273ed7162ecabf641f638b8f66
2023-09-19 05:17:18 +00:00
Tim Starling
31e3fd4329 Add UserIdentityUtils service
Add a service for convenient interpretation of UserIdentity instances,
especially relating to the TempUser migration.

Bug: T341976
Change-Id: I94e8620cd3187f41f04cdf24b5b553baadfbc22d
2023-07-24 09:52:10 +10:00
tsepothoabala
b44f6e459f Blocked temporary account user sees an appropriate block message
Bug: T324599
Change-Id: Ib30cc2e5b7aed010bd1b3cd857ae896c189bbc81
2023-02-24 16:16:49 +02:00
Alexander Vorwerk
f6bd18d6c2 Split a base class out of CommentStore
so that extensions (i.e. CheckUser) can implement their own comment
store without having a lot of code duplication

basically the comment store version of I3a6486532f2ef36

Bug: T233004
Change-Id: Ib40f99e00a514d41776ce521baf113e46d37e9cd
2023-01-01 22:34:36 +00:00
Thalia
1c58fc1949 GetBlockErrorMessageKey: Add typehints and improve documentation
Change-Id: I8f6ec421de5bde86e7f7a830069c3dc2c05ba0b7
2022-10-18 14:16:29 +01:00
AnaïsGueyte
cc55e848e4 Create Hook to check block's error messages from extensions
Bug: T317201
Change-Id: I1c20e7e62e0f2b453735689e3dc543164b5fd067
2022-10-14 11:43:21 -04:00
DannyS712
d8b69e2490 BlockErrorFormatter: use Message::plain() if blocked without a reason
Will make it easier to migrate away from using Message and use
MessageValue/TextFormatter if only a single type of formatting
is used - other messages in the class use plain() instead of text()

Change-Id: If2a7f5aa7aebedb2965ca6d3aa2b83d1b979bd37
2021-08-05 01:50:50 +00:00
DannyS712
66d676f163 BlockErrorFormatter: clean up handling of link to blocker's user page
Current code fetches a User based on their id, and then retrieves
a Title object for that User's user page via User::getUserPage().
That Title object is then used to retrieve the text and prefixed text.

Instead, retrieve the UserIdentity from the block directly,
and then create the PageReference manually. Use TitleFormatter to retrieve
the text and prefixed text.

Change-Id: Ic44bfb882523595566031a0fd788be4f15ef19e9
2021-07-27 22:13:28 +00:00
daniel
753b1bcaff Introduce Block interface and replace AbstractBlock.
In order to allow Authority to know about user blocks,
we need a narrow interface to represent such blocks.

This deprecates some methods on AbstractBlocks in favor
of new methods on the Block interface that avoid binding to
the User class.

Bug: T271494
Change-Id: I7bb950533970984a014de0434518fbbefb695131
2021-05-11 11:36:11 +02:00
Petr Pchelko
58385ac713 Convert users of BlockErrorFormatter to UserIdentity
Change-Id: Ib655179851101fc9d249be5839b343c9c8bd98d2
2021-03-17 19:37:08 +00:00
sahil
08a75b5ad9 Fixed typo "paramaters"
Changed from paramaters to parameters in mediawiki / core

Bug: T201491
Change-Id: I85caee07603c2599562b5719b45bb63184b74b49
2021-03-10 22:37:58 +05:30
Umherirrender
9284893744 Avoid unstubbing user in BlockErrorFormatter::getFormattedBlockErrorInfo
Allow to pass User object to Language::formatExpiry which does not
depend on global state when passing a user

Bug: T267445
Change-Id: Ibd2991b7f051f2a7635c5f4844c8cbfab473557e
2021-02-24 17:18:50 +01:00
Umherirrender
8de3b7d324 Use static closures where safe to use
This is micro-optimization of closure code to avoid binding the closure
to $this where it is not needed.

Created by I25a17fb22b6b669e817317a0f45051ae9c608208

Change-Id: I0ffc6200f6c6693d78a3151cb8cea7dce7c21653
2021-02-11 00:13:52 +00:00
DannyS712
500a13db73 Inject UserFactory into BlockErrorFormatter
Bug: T265311
Change-Id: Ifdd6669f95689aba67bf4eef337c49115a1a6d07
2020-10-13 20:09:52 +00:00
Thalia
52a029aace BlockErrorFormatter: Use language-specific comma separators
Change-Id: I2568c0ca7b8b696530b184ba5cef0194fd497c35
2020-02-28 11:09:58 +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
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