Commit graph

22 commits

Author SHA1 Message Date
Umherirrender
f27c2433bb tests: Use namespaced classes (2)
Changes to the use statements done automatically via script
Addition of missing use statement done manually

Change-Id: I4ff4d0c10820dc2a3b8419b4115fadf81a76f7a2
2024-06-13 23:21:02 +02:00
Umherirrender
388b0374fa tests: Use namespaced classes
Changes to the use statements done automatically via script
Addition of missing use statements and changes to docs done manually

Change-Id: Ib326ae1e5c8409a98398c721e8b8ce42c73bd012
2023-12-11 15:59:55 +01:00
daniel
b88cd15be3 ActionFactory: don't choke on special pages
ActionFactory (and by extension, PermissionManager) should behave
gracefully when asked to determine whether an action requires the user
to be unblocked on a special page.

Actions are not defined for special pages, but we should not fail hard
when encountering a special page as context. This is particularly
important since getActionInfo will fall back to Title::newMainPage whn
no context is provided, and some wikis (e.g. Meta) use a special page as
their main page.

This should be considered a workaround until we have resolved T346036.

Bug: T348451
Followup-To: Ic30c36f82ab142130b5f4167c13284aeed899231
Change-Id: Ia301ac1f2e3fd812fd63aea83098cbc0270b80cc
2023-10-11 11:02:40 +00:00
daniel
7b8187f257 Introduce ActionFactory::getActionInfo
The new method encapsulates the fact that we currently have to
instantiate action objects to determine which permission the action
requires. This encapsulation reduces coupling in PermissionManager
and allows us to easily change to a better way to create ActionInfo
later.

Eventually, ActionInfo should be constructed based on the action's
object spec. This requires us to include the relevant information in all
specs, in core and extensions.

Change-Id: I707a165c41403ebd4a3edfc66c1595e1bd3a4087
2023-09-20 10:06:02 +10:00
James D. Forrester
a47f05e761 Drop Action::exists() and ActionFactory::actionExists(), deprecated since 1.38
Change-Id: Ie7bb32d6b28863e89f4ab7b1a37ce2756f7a03d9
2023-08-16 16:58:34 +08:00
Bartosz Dziewoński
25b40324f1 Remove SpecialPageAction and associated logic, route old URLs
Bug: T323338
Change-Id: I115ace5e82f55fd6652d61f05926e96ba569a8a9
2023-07-11 19:22:51 +00:00
Tim Starling
5e30a927bc tests: Make some PHPUnit data providers static
Just methods where adding "static" to the declaration was enough, I
didn't do anything with providers that used $this.

Initially by search and replace. There were many mistakes which I
found mostly by running the PHPStorm inspection which searches for
$this usage in a static method. Later I used the PHPStorm "make static"
action which avoids the more obvious mistakes.

Bug: T332865
Change-Id: I47ed6692945607dfa5c139d42edbd934fa4f3a36
2023-03-24 02:53:57 +00:00
DannyS712
14ae304e35 Tests: add ObjectFactory to DummyServicesTrait
Mocks a ContainerInterface to support a specific list of services,
with has() and get() working correctly, and uses that for a real
ObjectFactory object.

Change-Id: Ie49b5a34e0f449cc4b9f6b31d6cc1bc943d04b43
2023-01-23 19:35:50 +00:00
thiemowmde
c1127c013e Replace some more mock builders with createMock() shortcut
A few slightly obscure usages we missed before.

Change-Id: I9a4065dcf572ada1b51cdd332cdbdaacd53815be
2022-11-14 17:28:11 +01:00
Amir Sarabadani
bbe704b5c1 Reorg: Move some of request related classes to MediaWiki/Request
Redoing I5ea70120d74 but without moving WebRequest that caused issues
with phan-taint-plugin.

Moving:
 - DerivativeRequest
 - FauxRequest
 - FauxRequestUpload
 - PathRouter
 - WebRequestUpload

Bug: T321882
Change-Id: I832b133aaf61ee9f6190b0227d2f3de99bd1717b
2022-10-28 10:15:31 +00:00
Zabe
f6b9381d7f Revert "Reorg: Move some of request related classes to MediaWiki/Request"
This reverts commit 2bdc0b2b72.

Reason for revert: T166010#8349431

Bug: T166010
Change-Id: Idcd3025647aec99532f5d69b9c1718c531761283
2022-10-27 13:14:16 +00:00
Amir Sarabadani
2bdc0b2b72 Reorg: Move some of request related classes to MediaWiki/Request
Moving:
 - DerivativeRequest
 - FauxRequest
 - FauxRequestUpload
 - PathRouter
 - WebRequest
 - WebRequestUpload

Bug: T166010
Change-Id: I5ea70120d745f2876ae31d039f3f8a51e49e9ad8
2022-10-26 16:49:10 +02:00
jenkins-bot
6fd4c95f5e Merge "Use updated ObjectFactory namespace" 2022-03-12 00:19:53 +00:00
Alexander Vorwerk
9b09bf3112 Use updated ObjectFactory namespace
Depends-On: I99c5e5664d2401c36a9890f148eba7c25e6e8324
Depends-On: I48ab818b2965da14af15ef370aa83ad9455badd9
Depends-On: I018371e4b77911e56152ca7b2df734afc73f58a5
Change-Id: I04ebdb52102f6191d49a9cc70b1f98308299e72f
2022-03-09 23:04:51 +00:00
Tim Starling
1ae3b0ca86 Allow ContentHandler to "override" non-existent actions
Flow defines a lot of custom actions which are only implemented for its
own content type. This use case is not what we had in mind when
getActionOverrides() was introduced, but allowing it in ActionFactory
removes the need for Flow to write dummy ignored config to $wgActions.

Bug: T303237
Change-Id: I67c1ae95344b0004eb93023fae7e93de4e47888b
2022-03-08 14:17:22 +11:00
Legoktm
93f79a9122 Revert "Replace deprecated methods IContextSource::getWikiPage && IContextSource::canUseWikiPage"
This reverts commit ef458e8948.

Reason for revert: Causes page tabs to disappear on Special:WhatLinksHere.

Bug: T297744
Change-Id: I0ee282a9f7a5a9b2cfdc3261d800d9e27eaf977e
2021-12-14 12:43:15 -08:00
Roman Stolar
ef458e8948 Replace deprecated methods IContextSource::getWikiPage && IContextSource::canUseWikiPage
Bug: T275710
Change-Id: I74b8f76a525793bc029d9ee1f7297b46ac0a9174
2021-11-16 13:58:39 +02:00
DannyS712
4818a2e2ad ActionFactory: restore missing check for non-existent classes
Missed this part of the old Action::factory() method

Bug: T253078
Bug: T289190
Change-Id: Idb8fca0bc306ee9402ef7871b313d11eef176510
2021-08-19 14:22:11 +00:00
DannyS712
0450da0f52 Inject services into InfoAction
Bug: T253078
Change-Id: I23022089f20695f88665a2990627e8f655266efa
2021-08-04 18:04:37 +00:00
Bartosz Dziewoński
6d361d61bd Add a hook 'GetActionName' to allow overriding the action name
The use case is to change action=edit into action=view in some
scenarios where we want to offer a more limited interface or a
gentler introduction to editing than MediaWiki provides, for example
I2e7b2682da7beb3c1c469bb784a9a8ec3998aeb9 in DiscussionTools.

Bug: T282204
Change-Id: Ib9302e2fda7dadf1edc43c0107db7234eb4bdf7a
2021-08-02 09:44:27 -05:00
DannyS712
5b5763e230 SpecialPageAction: inject action name and SpecialPageFactory
Instead of trying to figure out the name based on the
context, which duplicates the handling in ActionFactory,
make use of ObjectFactory specs' `args` feature to inject
the name.

Also inject the SpecialPageFactory service.

Bug: T253078
Change-Id: Iec223583f93d45184152862d9eee735737453417
2021-07-31 03:43:56 +00:00
DannyS712
20293e4c99 Add an ActionFactory and start converting to DI
$wgActions used to map string action names to true,
false, a string, a callable, or an object. Now it can also
be an array (that isn't a callable) corresponding to an
ObjectFactory spec for DI.

This patch converts the revisiondelete and rollback actions to
use DI, with the rest to be converted later. The new structure
of $wgActions is fully backwards-compatible.

We don't yet deprecate Action::factory(), ::getActionName(),
and ::exists(), those will be deprecated in a follow-up.

Additionally, we no longer impose a rule that only some
actions can be overridden on a per-article basis via
Article::getActionOverrides().

Bug: T253078
Change-Id: I0fc3c53d671eced1758458f9a0148180b40c6c9b
2021-07-29 01:32:43 +00:00