Commit graph

13 commits

Author SHA1 Message Date
Bartosz Dziewoński
13289a1269 Use real type hints for services etc. in includes/block/
Mostly used find-and-replace:

Find:
/\*[\*\s]+@var (I?[A-Z](\w+)(?:Interface)?)[\s\*]+/\s*(private|protected|public) (\$[a-z]\w+;\n)((?=\s*/\*[\*\s]+@var (I?[A-Z](\w+)(?:Interface)?))\n|)
Replace with:
\3 \1 \4

More could be done, but to keep this patch reasonably sized, I only
changed the most obvious and unambiguously correct cases.

In some cases, I also removed redundant doc comments on the
constructor, and re-ordered the properties to match the constructor.

Change-Id: I819ed771c915293663856c577a481d607b76ed80
2024-07-31 08:54:31 +00:00
Tim Starling
09ffad6ce3 Improve the readability of test code by making the BlockActionInfo::ACTION_* constants public+internal
Also don't use @var for constants, that breaks Doxygen.

Change-Id: Ifb92406c3c5ad6f5bd0b35d07c8106cfa18a99e4
2023-10-12 10:17:19 +11:00
Daimona Eaytoy
c5a01d4b2e Replace some usages of MWException
These exceptions are not documented with @throws and they're really not
meant to be caught.

Bug: T86704
Change-Id: I07f32e42c6fd4bc8785bac91547858f15a9fc2a8
2023-01-26 00:10:34 +00:00
libraryupgrader
5357695270 build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 36.0.0 → 37.0.0
  The following sniffs now pass and were enabled:
  * Generic.ControlStructures.InlineControlStructure
  * MediaWiki.PHPUnit.AssertCount.NotUsed

npm:
* svgo: 2.3.0 → 2.3.1
  * https://npmjs.com/advisories/1754 (CVE-2021-33587)

Change-Id: I2a9bbee2fecbf7259876d335f565ece4b3622426
2021-07-22 03:36:05 +00:00
STran
4d9d73819a Throw if action codes in getAllBlockActions aren't unique
Duplicate action codes (eg. extensions assign colliding action ids)
will caused unexpected partial blocking behavior. This lets someone
know that there's a duplicate by throwing before that happens.

Bug: T281915
Change-Id: I34cab4360d40805a9259cf6f2b4cbf05cee6184c
2021-05-05 12:56:33 -07:00
Thalia
6cb1016594 Allow partial action blocks to be made via ApiBlock
Bug: T280522
Change-Id: I114e3c76cfb6dd2f79b5217aee4b3da34df00850
2021-05-04 17:48:21 +01:00
AnaïsGueyte
8b43d8ffda Block Creating page action
Add an option to prevent creating page on partial block

Bug: T199918
Change-Id: I1668da6c299373fb838d860e15d9ffee7aa6a269
2021-05-03 12:14:13 -07:00
DannyS712
378fd2a730 Fix grep comments in BlockActionInfo for messages
Should be ipb-action-*, not ipb-actions-*
Add missing comment for move

Bug: T194529
Change-Id: Ib95be01e7bd8b26b010cfae124a3730dba0abb53
Follow-up: Ice36ac41901ea85928c81aee45b22746b5867b03
2021-04-30 19:40:03 +00:00
jenkins-bot
644153cf39 Merge "Add action block to BlockList" 2021-04-30 19:24:53 +00:00
AnaïsGueyte
2a1baa8848 Add action block to BlockList
Add action blocks on Special:BlockList

Bug: T279559
Change-Id: I42d541270ca8b84b3c0469353708d94944f75f18
2021-04-29 13:33:18 -07:00
Thalia
b7c977f6d5 Allow users to be partially blocked from moving/renaming pages
This is done by adding the 'move' action to BlockActionInfo.

Bug: T194529
Change-Id: Ice36ac41901ea85928c81aee45b22746b5867b03
2021-04-29 15:00:51 +01:00
STran
df89e2fb49 Add GetAllBlockActions hook
Call onGetAllBlockActions to add to the blocked actions array.
This allows extensions to define blockable actions.

Bug: T279562
Change-Id: Ia72fdabba1dcca0e2f71e4c09400453295f0e05c
2021-04-28 08:59:18 -07:00
Thalia
c67f181dd4 Introduce infrastructure for partial blocks for actions
This adds a new type of block restriction for actions, which extends
AbstractRestriction. Like page and namespace restrictions, action
restrictions are stored in the ipblocks_restrictions table.

Blockable actions are defined in a BlockActionInfo service, with a
method for getting all the blockable actions, getAllBlockActions.

Action blocks are checked for in PermissionManager::checkUserBlock
using DatabaseBlock::appliesToRight. To make this work, this patch
also removes the 'edit' case from AbstractBlock::appliesToRight,
which always returned true. This was incorrect, as blocks do not
always apply to edit, so cases that called appliesToRight('edit')
were fixed before this commit. appliesToRight('edit') now returns
null (i.e. unsure), which is correct because it is not possible to
determine whether a block applies to editing a particular page
without knowing what that page is, and appliesToRight doesn't know
that page.

There are some flags on sitewide blocks that predate partial blocks,
which block particular actions: 'createaccount' and 'sendemail'.
These are still handled in AbstractBlock::appliesToRight, and are
still checked for separately in the peripheral components.

The feature flag $wgEnablePartialActionBlocks must set to true to
enable partial action blocks.

Bug: T279556
Bug: T6995
Change-Id: I17962bb7c4247a12c722e7bc6bcaf8c36efd8600
2021-04-27 21:53:13 +01:00