Commit graph

45 commits

Author SHA1 Message Date
Kunal Mehta
ec0be22116 Update Legoktm's email address
Change-Id: Icd58c93bb0cff5b0a4e7b7f02873a271bab8964f
2021-05-02 05:39:37 +00:00
Func
278e195ab7 Set $status->value in EditFilterMergedContentHookConstraint::checkConstraint() properly to display error message
When hook handler return false and use $status->fatal() to put up a error,
we should set $status->value to self::AS_HOOK_ERROR_EXPECTED to show edit form
and display error message.

Bug: T273354
Change-Id: I02d643c5cb1978da8ab749856493d75137b6cb02
2021-04-15 22:01:30 +02:00
DannyS712
fb22076f1f Update creation of edit constraints following switch to Authority
No longer need the factory for many of them

Bug: T271977
Bug: T157658
Follow-up: I12a2f71f52a1ba7e94bf325621e62ed0e255601b
Change-Id: I5019ea46bccb1f23643424c2798061a25eb3f623
2021-03-22 23:11:46 +00:00
Petr Pchelko
1e50ec98ed Convert ChangeTagsConstraint to Authority
Change-Id: Ib31f3d590fcd0d609cc11f06183da8283cfe7673
2021-03-15 21:38:42 -06:00
Petr Pchelko
ea185c872e Rename Authority::getPerformer() to ::getUser()
We started to call Authority argument $performer everywhere,
and $performer->getPerformer() doesn't look that good.

Change-Id: Id2cf3f27b18340314e4ed1ea9931ad9404b4df6f
2021-03-04 12:45:28 -07:00
Petr Pchelko
595d605e34 Convert EditConstraints to Authority
Bug: T271977
Change-Id: I12a2f71f52a1ba7e94bf325621e62ed0e255601b
2021-03-03 17:12:07 -07:00
DannyS712
c4b1396e0d ImageRedirectConstraint: accept Content objects
More common interface for constraints

Bug: T157658
Change-Id: Ia50c3fb647ed803a69f5e4511047f1ab88e43bf7
2020-12-09 21:41:13 +00:00
DannyS712
f75f3c75ea UserRateLimitConstraint: move detection of content model change to constraint
A step towards a more common interface between the different
constraints, detect whether the content model changes within the
UserRateLimitConstraint rather than relying on EditPage to inject
the answer

Bug: T157658
Change-Id: Ifa35cbabe74df458784a10b3d2815a1e8e7dcdf8
2020-12-01 23:08:47 +00:00
DannyS712
883199bc98 Move more logic into edit constraints
Specifically, remove the conditional processing of
ContentModelChangeConstraint and ChangeTagsConstraint in
favor of early returns within the constraints

Bug: T157658
Change-Id: I377c0e3d9611d2da0a2d0f9bca055d65a1bec7e6
2020-12-01 18:44:03 +00:00
Umherirrender
3f1c5d0eea Document list of change tags as string[]
Change-Id: I0ce2a8154af82a363fef126033b5819c4ee84842
2020-11-20 14:12:54 +01:00
DannyS712
f14c2cb8ef Add AccidentalRecreationConstraint
Bug: T157658
Change-Id: Ia9346ceb06ca060cd6e953b1d5b358aabc853eb3
2020-11-16 22:36:54 +00:00
DannyS712
f10795c3cd EditPage: Add two more constraints
- AutoSummaryMissingSummaryConstraint
- SelfRedirectConstraint

Bug: T157658
Change-Id: I0bc29d81ec3df6228a04f41df66b53b113792e38
2020-11-11 23:15:42 +00:00
jenkins-bot
2d9b7a99e2 Merge "EditPage: Move $sectionHeadingToCheck handling to SpamRegexConstraint" 2020-11-11 02:20:08 +00:00
DannyS712
1f05a9799b EditPage: Move $sectionHeadingToCheck handling to SpamRegexConstraint
Cleaner and simpler if the constraint takes care of determining
how to handle the section title

Bug: T157658
Change-Id: I45de1aca77fe1ddcd3d94b6ca964328d9911b440
2020-11-11 00:51:58 +00:00
DannyS712
3b0c5e579b Move EditPage::runPostMergeFilters to a constraint
Bug: T157658
Change-Id: I071163d6d2538948693527c36e8e59281f528402
2020-11-10 23:34:20 +00:00
DannyS712
d7a737fca9 Rename MissingSummaryConstraint to NewSectionMissingSummaryConstraint
There is another place a missing summary is
checked, with different parameters and under
different conditions

Bug: T157658
Change-Id: I988a34a2a130244e6e250259b66727ef979a91ec
2020-11-09 22:59:20 +00:00
DannyS712
44418378e0 EditPage: Factor out more constraints
CreationPermissionConstraint
DefaultTextConstraint
MissingCommentConstraint
MissingSummaryConstraint

Bug: T157658
Change-Id: I55cf336ff6dfb990045e43e6dcd7437a241a46b2
2020-11-04 21:29:54 +00:00
DannyS712
b075dc775f Minor tweaks to edit constraints
- EditConstraintRunner debug logging uses `info` for the failed constraint
- Differentiate between the two PageSizeConstraints in debug logs
- Add or tweak some comments
- Normalize SpamRegexConstraint logs

Bug: T157658
Change-Id: I9d0e8d48a104320f29831357b45a4003942b04fd
2020-11-03 00:35:19 +00:00
DannyS712
cc8bab4111 Add PageSizeConstraint and ChangeTagsConstraint
Bug: T157658
Change-Id: I2c7b4f77cd07c72b42eaeb7e37095461c92b367a
2020-10-28 16:03:02 +00:00
DannyS712
05ae763ba2 EditPage: Migrate more checks to constraint
Add
- ContentModelChangeConstraint
- EditRightConstraint
- ImageRedirectConstraint
- ReadOnlyConstraint
- UserBlockConstraint
- UserRateLimitConstraint

Additionally:
- Split EditPageTest into a separate file for
all of the constraints being tested

- Add a helper EditConstraintTestTrait

- Add debug logging for EditConstraintRunner for
the result of each constraint

- Changed the order of some of the checks, which
may result in a different failure code if multiple
checks were going to fail, but shouldn't change the
overall result of whether an edit fails or not.

Bug: T157658
Change-Id: Ib8f8b62b9928544e5559c96d82bf850dd8cf9b05
2020-10-26 22:01:05 +00:00
DannyS712
e50dacf78c EditPage: Move spam checks to SpamRegexConstraint
Bug: T157658
Change-Id: I06ef5796f9da7b0e8555768ec6fd128b4f778294
2020-10-21 22:43:01 +00:00
DannyS712
dc32b15d8d Add EditConstraintFactory, migrate SimpleAntiSpamConstraint
Factory is a service in ServiceWiring, given the number
of dependencies that will eventually be needed, but is
internal and has no corresponding method in MediaWikiServices

Bug: T157658
Change-Id: I801a09f5133bed14da10c64a42ca0658024357d3
2020-10-21 14:36:01 +00:00
DannyS712
1aa3a1395c Introduce EditConstraint system, migrate unicode check to constraint
This is the start of "Phase 1" of the migration described in
T157658#6191234. For now, only a single constraint, the
requirement that EditPage::$unicodeCheck match the expected
value, is moved to the new system, in the UnicodeConstraint class.

Both the EditConstraintRunner and the new UnicodeConstraint
have 100% test coverage with pure unit tests.

Bug: T157658
Change-Id: I4fc806ec0fd631e265948a59244295eebec691fa
2020-10-20 14:09:26 +00:00
DannyS712
3a1c063899 Add missing license to IEditObject
Forgot to include it at the time

Change-Id: I60ac6662e4213bef4c0b35f473716784d517ae14
2020-10-09 02:29:15 +00:00
DannyS712
615b880051 [EditPage] Move AS_* status constants to a new interface
Interface is @internal and is implemented by EditPage; will be used in
the future when the backend is split and common status values are needed
for the different classes.

Doing separately to avoid cluttering the main work - just moves the
constant definitions. Since EditPage implements the new interface, any
existing EditPage::AS_* references will continue to work.

Bug: T20654
Change-Id: I71dafec2579b4a42dd08f3fc7e569e28c14d8753
2020-05-30 11:59:03 -07:00
jenkins-bot
219469d873 Merge "editpage: Fix misplaced return value in TextConflictHelper" 2020-05-25 11:07:56 +00:00
jenkins-bot
7e3922e176 Merge "TextConflictHelper: Add ARIA label to wpTextbox1" 2020-05-13 05:28:54 +00:00
DannyS712
96b8be5750 Add a new SpamChecker service
For checks against `$wgSpamRegex` and `$wgSummarySpamRegex`.
EditPage methods will be deprecated in a separate follow-up patch,
as well as making use of the service where needed.

Bug: T251015
Change-Id: I12120b51073c31680713204cfeb5c61c0ca8c52c
2020-05-11 14:52:28 +00:00
Volker E
14fb921e67 TextConflictHelper: Add ARIA label to wpTextbox1
Add `aria-label` attribute with explanatory description as value to the
`wpTextbox1` to allow screen reader read the purpose of the textbox for
visually impaired contributors.

Bug: T245863
Bug: T252355
Depends-On: I0628486e2201975464a77a55053a8d74ddfc57fb
Change-Id: Ib6fe49ade878757594fd28dac2bfd0ef8a7a5e8f
2020-05-11 06:36:55 +00:00
Thiemo Kreuz
8a40367a40 editpage: Fix misplaced return value in TextConflictHelper
Luckily this was not really broken. The old and the new code do the
exact same. The old code was just side-stepping the documented way
this method should be used.

Change-Id: I3f25ba159df5dbfc67eb7ade3fe29a017e601162
2020-05-06 18:01:35 +02:00
Peter Ovchyn
7d57b967b5 deprecation: Remove DeprecationHelper::newArgumentWithDeprecation and change callers accordingly
Bug: T245075
Change-Id: I0714b1c5d5a379cfe3ca473b72244d4d6bd1b7b8
2020-04-27 20:23:58 +03:00
ArtBaltai
0ef09103df TextConflictHelper: deprecate old constructor signature
A deprecation warning will be triggered if the constructor is called without providing a ContentHandlerFactory

Bug: T235165
Depends-On: I5996f0f01e28edf50d3caf2ca4557d64271d8545
Change-Id: Ie552b33a5644fa2aefd826df8fd18184434677b7
2020-02-12 14:02:38 +11:00
ArtBaltai
30e54b3962 Introduce ContentHandlerFactory
Added:
- ContentHandlerFactory
Tests:
- PHPUnit
Changed
- Calls of changed and deprecated
- DI for some service/api
Deprecated:
- ContentHandler::* then similar to ContentHandlerFactory
- ContentHandler::getForTitle
- ContentHandler::$handlers

Bug: T235165
Change-Id: I59246938c7ad7b3e70e46c9e698708ef9bc672c6
2020-02-07 00:53:51 +03:00
Adam Wight
630bd7c5e1 Simplify user bucket cases
Moving the repeated code out makes this slightly more readable.

Bug: T236886
Change-Id: I87ddba6901f901048fad18c3827316c260fe3ec3
2019-11-04 13:47:18 +01:00
WMDE-Fisch
5eef5a6654 Count edit conflicts combined with user edits
Bug: T236886
Change-Id: I275de8e806b9b29329c7757c4bb96ecd7ba0ea1f
2019-11-01 13:28:12 +01:00
Petr Pchelko
3cc3d00bcc Move getRestrictionLevels from NamespaceInfo to PermissionManager.
Bug: T11977
Change-Id: I051be9148c98086fdf53a66a74bf7c28699016db
2019-08-22 14:32:38 -07:00
Aryeh Gregor
2e1ac38485 Mass conversion to NamespaceInfo
Change-Id: I2fef157ceec772f304c0923a1cd8c0eef2e82a0f
2019-05-07 22:44:56 +02:00
Thiemo Kreuz
81fee5a5e9 editpage: Make TextConflictHelper::toEditContent private
The method is not used anywhere:
https://codesearch.wmflabs.org/search/?q=toEditContent&i=1
There is another method with the same name in the EditPage class. But
this is unrelated. As far as I can see the method I'm touching in this
patch was copied from the EditPage class.

Change-Id: I51d167723bd70220adbf4ac36f15f3290b7eb653
2019-04-24 10:34:01 +02:00
Kunal Mehta
4ef179e335 Fix/suppress misc phan errors (#5)
Add lots of missing return statements, or remove incorrect doc blocks.

Change-Id: I0881e98fbb9d0d4cf79ecc824064d24538055d3f
2019-04-05 15:53:37 -07:00
Thiemo Kreuz
734a969d55 Safe replacement of a lot of !count() with === []
This was originally a global search and replace. I manually checked all
replacements and reverted them if (due to the lack of type hints) either
null (that would be 0 when counted) or a Countable object can end in the
variable or property in question.

Now this patch only touches places where I'm sure nothing can break.

For the sanity of the honorable reviewers this patch is exclusively touching
negated counts. You should not find a single `!== []` in this patch, that
would be a mistake.

Change-Id: I5eafd4d8fccdb53a668be8e6f25a566f9c3a0a95
2019-01-15 17:28:49 +01:00
WMDE-Fisch
60e396da44 Set getEditConflictMainTextBox parameter type to array
This is only called at one place in core and used in the TwoColConf
extention. The passed argument is always an array.

Change-Id: I4ca94442b79dc8871ed72943be733d100e093e44
2018-08-16 11:03:48 +02:00
WMDE-Fisch
85c7ac60c8 Use Sanitizer::mergeAttributes when merging classes into attributes
Change-Id: Ia5199a75e6926fe64b3d99d5b5914320491176bb
2018-01-05 10:32:56 +01:00
WMDE-Fisch
fb9a36c049 Moved textbox1 building into TextConflictHelper on edit conflicts
Factored out some minor parts about building editor CSS classes.

getEditConflictMainTextBox() mainly mirrors showTextbox1 parts not
included were moved to the EditPage.

Change-Id: I671e095acc08382dd0a1c3d167fdaaa623ec5499
2018-01-04 18:21:13 +00:00
addshore
6f2924af67 Track which namespaces edit conflicts are resolved in
This is similar to the tracking of the occourance of
edit conflicts but tracks the resolution of the conflicts.

Bug: T182011
Change-Id: I9a0c05dc921946fb6e0580b56b663783ca0b1b6e
2017-12-07 16:39:18 +01:00
Kunal Mehta
3f88e0c7bf EditPage: Extract some edit conflict code into EditConflictHelper
Extensions with custom content models (e.g. ProofreadPage) will extend
EditPage to provide a customized editing experience. However when
another extension like TwoColConflict wants to change just how edit
conflicts look, this causes problems since only one class can take the
place of EditPage.

So instead, split most of the frontend code for edit conflicts into
TextConflictHelper, and call it from edit page. Extensions can override
with the instance created by calling
EditPage::setEditConflictHelperFactory().

And to make that split possible also move EditPage::addNewLineAtEnd()
and ::buildTextboxAttribs() into a separate TextboxBuilder class that
both EditPage and TextConflictHelper can use.

Bug: T176393
Change-Id: Ie415edd84329c02d5762477f8a171fced85b01a2
2017-10-26 10:32:29 +02:00