Commit graph

17 commits

Author SHA1 Message Date
Kosta Harlan 3b195090fe SimpleCaptcha: Allow invoking CAPTCHA display from other extensions
Why:

- In the production WMF deployment of AbuseFilter and ConfirmEdit, we
  load ConfirmEdit first, then AbuseFilter. That means that
  ConfirmEdit's onEditFilterMergedContent hook fires before
  AbuseFilter's. The problem is that AbuseFilter uses
  onEditFilterMergedContent to evaluate its rules and consequences, so
  an AbuseFilter rule that defines a "showcaptcha" consequence becomes a
  no-op, as it fires after ConfirmEdit has already decided to show or
  not show a CAPTCHA to a user.
 - All of that is to say: we need a way to tell ConfirmEdit to show a
   CAPTCHA at the time that AbuseFilter's consequences are invoked,
   which could be before or after ConfirmEdit's EditFilterMergedContent
   hook invocation, depending on how the wiki has decided to load the
   extensions

What:

- Define a flag for "shouldForceShowCaptcha", that other extensions can
  set on the SimpleCaptcha base class to indicate that ConfirmEdit must
  show a CAPTCHA (users with "skipcaptcha" right are still exempt)
- Check the isCaptchaSolved() and shouldForShowCaptcha() flags in
  ::triggersCaptcha, and also check if ConfirmEdit's
  EditFilterMergedContent hook already ran
- In CaptchaConsequence, set the forceShowCaptcha property on the
  SimpleCaptcha base class
- [misc] Add getter/setter for the captchaSolved property and the other
  new class properties

Depends-On: I7dd3a7c41606dcf5123518c2d3d0f4355f5edfd3
Bug: T20110
Change-Id: Idc47bdae8007da938f31e1c0f33e9be4813f41d7
2024-06-26 16:07:44 +00:00
Umherirrender 81d0c7bcd4 Use namespaced classes
Changes to the use statements done automatically via script
Addition of missing use statement done manually

Change-Id: I325f5bab163cddf76dbf8d5a6eca35a7ed7b6df7
2024-06-08 23:46:45 +02:00
Umherirrender 92bc1f3d2f Use namespaced classes
Changes to the use statements done automatically via script
Addition of missing use statements done manually

Change-Id: Id44f211320e56bc83e4c8f243369dc4eb562cf37
2023-12-11 00:07:55 +01:00
gerritbot 4bc5e7ed8f Replace some moved Title class uses, now MediaWiki\Title\Title
Bug: T321681
Change-Id: I639a03a5f828d7036e29a11a8a45d8d1e8923590
2023-08-19 04:14:21 +00:00
Umherirrender 1a440848fa tests: Make PHPUnit data providers static
Initally used a new sniff with autofix (T333745)

Bug: T332865
Change-Id: I74e62a477cb8657da93180cd71432a95e70fff4b
2023-05-20 11:59:50 +02:00
Reedy 30cd1d8a23 Namespace base classes
Change-Id: I3fa9747e0ea970c5de39e2da8603e1bba9388a69
2022-07-30 18:13:03 +00:00
daniel 5770d44639 tests: Remove access to private ExtensionProcessor::globalSettings variable
It's internal, extensions should not rely on it. And now it is being removed.

Needed-By: I85324d04ecde38aad5f827c7aa33d989089e6d33
Change-Id: Id981f5f110789c5b7daa64185ec8ad952914ab48
2022-03-11 21:50:21 +00:00
Alexander Vorwerk 9ee7caa78e MediaWikiTestCase -> MediaWikiIntegrationTestCase
MediaWikiTestCase has been renamed to MediaWikiIntegrationTestCase in 1.34.

Bug: T293043
Change-Id: Iba498b9107753233b4fbb1f8d435663199635507
2021-11-29 19:54:25 +00:00
libraryupgrader 81a524e2e9 build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 36.0.0 → 37.0.0

npm:
* postcss: 7.0.35 → 7.0.36
  * https://npmjs.com/advisories/1693 (CVE-2021-23368)
* glob-parent: 5.1.0 → 5.1.2
  * https://npmjs.com/advisories/1751 (CVE-2020-28469)
* trim-newlines: 3.0.0 → 3.0.1
  * https://npmjs.com/advisories/1753 (CVE-2021-33623)

Change-Id: I57837ebf8054a2e968d207fecb3f12397c18e2a2
2021-07-22 14:24:25 +00:00
Umherirrender 91ecfa4ddd Remove incomplete @param from test function
the @dataProvider should be a enough here

Change-Id: Id9396e8baf734a028eda5dde5caeb8ac98cf1606
2021-01-23 01:36:10 +01:00
Daimona Eaytoy f85f9f14f8 Remove PPHUnit 4 bc stuff
Bug: T192167
Change-Id: I825b694550c11942cd9aa352f370894133b12c7b
2019-10-13 11:34:12 +02:00
James D. Forrester 86246f0172 build: Upgrade mediawiki-codesniffer to v28.0.0
Change-Id: I12c3660e74e42937f6cfb31ec4771a67d8651f42
2019-10-09 15:45:51 -07:00
Aryeh Gregor 4228dbd2b7 Do not reset extension registry in tests
This breaks later tests, e.g.:

https://gerrit.wikimedia.org/r/c/mediawiki/core/+/450433
https://gerrit.wikimedia.org/r/c/mediawiki/core/+/465423

The only reason this didn't cause test failures until now is because the
namespace data was getting (incorrectly) cached in between tests.  As
soon as we start resetting namespaces for each test, namespaces set by
the extension registry get wiped out by these tests.

Change-Id: Icb7a4a2a5d19fb1f2453b4b57a5271196b0e316d
2019-04-09 20:29:49 +03:00
Kunal Mehta 9fc9337fca Use new ExtensionRegistry::setAttributeForTest() in tests
So we don't need to hackily deal with ExtensionRegistry internals.

Depends-On: I9e62a02ed2044c847e9ab2dcdfab094001f88986
Change-Id: Id6ca6eb49db789dbb3f227533c4442506cc61bc4
2019-01-14 10:34:22 -08:00
Eddie Greiner-Petter 2848a699db Move "can user skip captchas" check to own function
As a direct effect
- sending emails and creating accounts now respects $wgAllowConfirmedEmail
- log messages get a bit less verbose for mail sending and creating
  accounts (but should be clear from the context what action was
  performed)
- less code duplication \o/

Indirectly, this should make solving the attached bug easy(tm), because it
just needs to add a hook to the canSkipCaptcha function.

Bug: T176589
Change-Id: Id27b0eadbab7300b9e6969d406fa6f00ef0888bf
2018-05-19 13:27:04 +00:00
Kunal Mehta e1f45829d4 Add @covers tags
Change-Id: I1e99261acb13c86e96c1b2dd1cb61918ebc660c2
2018-01-23 15:59:08 -08:00
Florian Schmidt 50bc57a200 Allow other extensions to setup triggers using attributes
Instead of misusing the config section of extension.json to declare
captcha triggers in the ConfirmEdits CaptchaTriggers config variable,
other extensions can now use the CaptchaTriggers attribute for the
exact same thing. E.g., to declare a new trigger, the following
addition to the own extension.json will register the trigger in
ConfirmEdit:

  "CaptchaTriggers": {
    "wikiforum": true
  }

This also removes the CaptchaClass config from the main extension.json
config section, and automatically sets the SimpleCaptcha module in the
getInstance() method of ConfirmEditHooks, which is a pre-requirement for
the mediawiki/core change Ieeb26011e42c741041d2c3252238ca0823b99eb4.

Bug: T152929
Change-Id: I4c5eaf87657f5dc07787480a2f1a56a1db8c714f
2017-09-02 17:45:26 +02:00