Commit graph

6259 commits

Author SHA1 Message Date
jenkins-bot bd9a0758a1 Merge "Fix more inconsistencies in scripts for logging entries" 2020-02-07 20:32:45 +00:00
Daimona Eaytoy 3f83e57ad7 Factor out variables-related methods
This is another step needed to reduce the size of the gigantic
AbuseFilter and AbuseFilterHooks classes. It also makes many methods
non-static, for more testability.

Note, this layout is still not final. We should somehow merge the
functionality of VariableGenerator and AFComputedVariable, for which
I already have plans.

Change-Id: I366d598b69ad866496b7cb0059e0835c02e54041
2020-02-07 20:27:26 +00:00
Daimona Eaytoy 1686042a91 Move variable generators to new classes
RunVariableGenerator is for generating variables based on the current
action;
RowVariableGenerator is for RC entries;
VariableGenerator is the generic one.

This patch only moves the methods to the new classes, to keep the diff
easier to read, and facilitate conflict resolution. These classes will
then be revamped in I366d598b69ad866496b7cb0059e0835c02e54041.

Note that these classes are now namespaced.

One method, AbuseFilter::getEditVars, was renamed to
AbuseFilterVariableGenerator::generateEditVars, because it would
otherwise conflict with an incompatible method in RunVariableGenerator.

Change-Id: Iff412e5492873d4fae55402939a51609e64d55a8
2020-02-07 19:44:31 +00:00
Daimona Eaytoy 6b7be78534 Use RCDatabaseLogEntry as wrapper in get*VarsFromRCRow
This provides various shortcuts for user, target, comment, etc.,
avoiding direct access to the row, and thus a dependency on the
schema.

Change-Id: I250f94e0ac6cade33441a31ae8a27093a4d937a0
2020-02-07 19:19:10 +00:00
Daimona Eaytoy 472d1221bd tests: Increase and rebalance code coverage
Also fix a couple of broken tests in Consequences:
 - For createaccount, $user->addToDatabase must be called before
   testForAccountCreation, or it will throw a CannotCreateActorException.
 - In testThrottleLimit, also set wgAbuseFilterEmergencyDisableThreshold
   to avoid relying on the local config.

Bug: T201193
Change-Id: If1a50b0a729e4d554485f2e2225d5877510966b6
2020-02-07 18:32:17 +00:00
Translation updater bot df318a8d33 Localisation updates from https://translatewiki.net.
Change-Id: Ic72a381c829f49d6175d964a76522aab50d9b0a6
2020-02-06 08:18:34 +01:00
Translation updater bot cf9d4f54f9 Localisation updates from https://translatewiki.net.
Change-Id: I0ab18a55991d9e5eeba5a7c703ed571ed14dd60c
2020-02-05 08:18:27 +01:00
Translation updater bot 5dbd92df73 Localisation updates from https://translatewiki.net.
Change-Id: Ifcd188567652155e61ab8a4d52460ab26009228c
2020-02-04 08:32:45 +01:00
Daimona Eaytoy 54512dd124 Fix more inconsistencies in scripts for logging entries
This includes a bunch of improvements.

In addMissingLoggingEntries:
 - Don't access mDescription directly
 - Build a ManualLogEntry instead of stuffing data in the DB

In fixOldLogEntries:
 - Fix entries having log_page = NULL instead of 0 due to
 addMissingLoggingEntries skipping that field
 - Fix entries having log_deleted = afh_deleted caused by
 addMissingLoggingEntries -- those are completely unrelated
 - Add batching, controlled by log_id, with default size of 500
 - Use Database::strreplace to have a single UPDATE per batch, instead
 of one per row.
 - In dry run, when checking rows to update, exclude the rows that
 would've been deleted in the first phase.

Bug: T228655
Change-Id: I885dba3f0772633d843b8a55e483047b169dc9ba
2020-02-03 15:30:07 +00:00
Translation updater bot 39b07ff63a Localisation updates from https://translatewiki.net.
Change-Id: Ia204eb5179a8eb90d53a7b924be9086a3461d216
2020-02-03 08:25:16 +01:00
Translation updater bot 8109bafff1 Localisation updates from https://translatewiki.net.
Change-Id: Ia2dc67115aab1b3e5204a607d6028d49b882c845
2020-01-31 09:51:38 +01:00
libraryupgrader a14ec744f7 build: Updating composer dependencies
* mediawiki/minus-x: 0.3.2 → 1.0.0
* mediawiki/mediawiki-phan-config: 0.9.0 → 0.9.1

Change-Id: I119f4d56cce674302f34e938e598e6cc6bf28dc0
2020-01-28 17:51:38 +00:00
Translation updater bot b497bcf337 Localisation updates from https://translatewiki.net.
Change-Id: Ia2c6fcc94217e79aa4c10f5fa79b2b7cea434c38
2020-01-28 08:23:53 +01:00
libraryupgrader b91530a128 build: Updating jakub-onderka/php-console-highlighter to 0.4.0
Change-Id: I9d1eaece84340db9576b63a1340a7a3cffbc5b77
2020-01-28 02:27:42 +00:00
Ammar Abdulhamid 641aeebbcf Replace deprecated IP class with IPUtils
Bug: T242556
Change-Id: If8e9034885726b673d1500fa8b538b5302e66165
2020-01-24 18:27:26 +01:00
Translation updater bot a6098bb465 Localisation updates from https://translatewiki.net.
Change-Id: I24d6a752789355597e19b0feeba04e85a6072bf1
2020-01-24 08:14:16 +01:00
Daimona Eaytoy 102789f62a Avoid keeping superfluous row properties
Most of them are overwritten either in ViewEdit::loadRequest or
AbuseFilter::saveFilter. af_hit_count and af_throttled are actually
relevant for the old version, so list them explicitly. And also add
default af_group and af_global, which are later read, for import action.

Depends-On: Iabd0ae5b18571f8cad44ef2d86bcf2519e7f95ba
Change-Id: Ie9aae938cca06e38a7a834a3f74f3e8735ab01ee
2020-01-23 12:50:03 +00:00
James D. Forrester bdef1200f8 Follow-up 87459ec: When no registration date is recorded, use 2008-01-15
Before the phan upgrade, this was silently choking on null as so falling
back to age since 1970-01-01 (~50 years); since the upgrade, the code is
breaking filters by responding with 0. The approximation of using 2008's
Wikipedia Day is less wrong and more fun (credit to Roan for making this
suggestion).

Bug: T243469
Change-Id: Ibc25ab09ecd0bf0b2292425c2768b1dc911b9974
2020-01-22 15:38:09 -08:00
jenkins-bot 5db1032618 Merge "Simplify throttling code" 2020-01-22 17:19:52 +00:00
jenkins-bot 81fd6af030 Merge "Actually record all filters in total_filters" 2020-01-22 17:19:50 +00:00
jenkins-bot 70d31da673 Merge "Stop using deprecated stuff with easy replacements" 2020-01-22 16:44:57 +00:00
Daimona Eaytoy 53b9f38888 Refactor data load in ViewEdit
Instead of having a single loadRequest method (which could end up
loading from the DB...), split it in a DB-only method and a request-only
one. Simplify the logic used to show the filter editor. Show the page
without changes or warnings if the user lost editing rights in the
meanwhile. Avoid two static properties, and pass them in when relevant
instead. Bonus: optimize a query to sort by afh_id instead of afh_timestamp to avoid filesort.

This will allow a subsequent patch to clean the $row object in
loadRequest.

Change-Id: Iabd0ae5b18571f8cad44ef2d86bcf2519e7f95ba
2020-01-21 14:15:41 +01:00
Daimona Eaytoy e9fe252def Fix remaining PHPCS issues
Mainly, add visibility modifiers on constants.

Change-Id: I41e8e2d691b2bad6ea6f244d54517d37d7783181
2020-01-21 12:36:37 +00:00
libraryupgrader 1d911b8187 build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 28.0.0 → 29.0.0
  The following sniffs are failing and were disabled:
  * MediaWiki.Commenting.FunctionComment.MissingParamTag
  * MediaWiki.Commenting.FunctionComment.ParamNameNoMatch

npm:
* eslint-config-wikimedia: 0.13.1 → 0.15.0
* grunt-stylelint: 0.11.1 → 0.13.0
* stylelint-config-wikimedia: 0.6.0 → 0.8.0

Additional changes:
* Remove direct "stylelint" dependency in favor of "grunt-stylelint".
* Also sorted "composer fix" command to run phpcbf last.
* Removing manual reportUnusedDisableDirectives for eslint.

Change-Id: I8f73202db1333fbc36ccf556b3bb05b1e8c279cb
2020-01-21 07:38:54 +00:00
Translation updater bot c48977da9d Localisation updates from https://translatewiki.net.
Change-Id: I7d421c3ac8e1a6b00b5832eca9edcdbfdbb4aa8c
2020-01-21 08:15:13 +01:00
Daimona Eaytoy d8cb1a33a0 Factor out get(Local|Global)Filters methods
This is a preparatory step for T234427 (although not strictly related),
and in the future it will enable us not to use the DB in several tests.

Change-Id: Id069f6e74f9c4df43b3a602d4224473d5ca68ed1
2020-01-20 17:13:06 +01:00
Max Semenik 8e7230076e Fix PHPUnit 8 warning
Bug: T192167
Change-Id: Ifbebbc3467eb0bf3f12cffc9e5601a1c94327bd9
2020-01-20 15:47:45 +00:00
jenkins-bot fdb85d5ef3 Merge "build: Upgrade phan" 2020-01-20 11:57:47 +00:00
Translation updater bot ede43ddc31 Localisation updates from https://translatewiki.net.
Change-Id: Ib18ce3168164322b4b845e58405755c3069fd2ac
2020-01-20 08:47:01 +01:00
Daimona Eaytoy 87459ec679 build: Upgrade phan
Depends-On: I6d538ce3ca7fd2d495c2bafbab7cc279da69db1c
Change-Id: Ic8c3a01a5c37fdf461f4fd5598e597eb9c9073d3
2020-01-19 18:48:51 +00:00
Translation updater bot 1206f464e7 Localisation updates from https://translatewiki.net.
Change-Id: Ic2a1c002efb7ff0e01a7e881a4d9d2c256c639bc
2020-01-17 08:36:01 +01:00
Translation updater bot f1457a10fa Localisation updates from https://translatewiki.net.
Change-Id: I9032b9a5ff34bef0b4f93d1fcb9d071147cfcc75
2020-01-16 09:28:57 +01:00
jenkins-bot 6ee44ae21a Merge "Fix generation of HTML vars, simplify tests" 2020-01-14 19:26:21 +00:00
Translation updater bot 71567b52a7 Localisation updates from https://translatewiki.net.
Change-Id: Ic68d4f485d151f47bdf3128b320a39e925c629b0
2020-01-14 10:58:21 +01:00
Translation updater bot 7e044dc49e Localisation updates from https://translatewiki.net.
Change-Id: I27b7efedac1801d6b98c861eca46e8c990ed8a50
2020-01-13 09:08:27 +01:00
Daimona Eaytoy 44ea3aa7f4 Fix generation of HTML vars, simplify tests
-new_html: also strip the "Transclusion limit" comment if present, and
anyway take it into account (as well as a "</div>"), which right now
prevent the PP limit report from being stripped as well.
-new_text: trim extra whitespace on the right, which is created when
stripping the aforementioned comments.

Also simplify the test for getEditVars, make it not blindly copy what
AFComputedVariable does.

Extra: kill a temporary variable.

These changes are partly taken from
I96785c6c5fdf381c21d5f8930ee12e706abb7f3f.

Change-Id: I2b4c84a3d9d0d17ce229088197b75781d5181b4f
2020-01-12 17:44:02 +00:00
Daimona Eaytoy 10c2fe7151 Stop using deprecated stuff with easy replacements
This patch is mostly replacing Revision::* constants,
Wikimedia\(restore|suppress)Warnings, and wfWikiId.

Change-Id: I13544cc3e12955a9376ccce3c120e2cee1f2ee2e
2020-01-08 14:59:30 +01:00
Translation updater bot 04f91a58cd Localisation updates from https://translatewiki.net.
Change-Id: I0b7e9927553db36e3884deb6360c5d0a10b3edf0
2020-01-08 08:41:29 +01:00
jenkins-bot f0e4c22b53 Merge "Simplify a query in AFComputedVariable" 2020-01-07 19:30:20 +00:00
Daimona Eaytoy c54e2fc180 Simplify throttling code
Change-Id: I54ebdf0bc61d5628d1755b75232a934358b112ff
2020-01-07 17:52:16 +01:00
Translation updater bot 539df33889 Localisation updates from https://translatewiki.net.
Change-Id: Ifd4f12d4badea3795398b4983aaddab7e2f75034
2020-01-07 08:47:07 +01:00
Translation updater bot 4d1bcc6d9d Localisation updates from https://translatewiki.net.
Change-Id: I336f56e58e4535ad477bfb359f21894215cbcb36
2020-01-06 08:47:04 +01:00
Translation updater bot f425d06548 Localisation updates from https://translatewiki.net.
Change-Id: If8fa7277655f0368eec64ca9a4af41316590034a
2020-01-03 08:44:28 +01:00
Translation updater bot e1edbbb5f9 Localisation updates from https://translatewiki.net.
Change-Id: Ibf38ed14f4e37ac881f5fc9ba429ae4809803afa
2020-01-02 08:56:38 +01:00
Translation updater bot 9552c187cc Localisation updates from https://translatewiki.net.
Change-Id: I8c1f45948f926fc2b343e6e7e10abaf9fc2c3701
2019-12-29 20:39:03 +01:00
jenkins-bot eef2760d7b Merge "Use explicit variarg for VariableHolder functions" 2019-12-27 10:24:31 +00:00
jenkins-bot 8fea62529b Merge "Fix AbuseFilterCachingParser violating return type constraint" 2019-12-27 10:04:57 +00:00
jenkins-bot a46c0e7359 Merge "Restore the ability to filter content model changes" 2019-12-27 10:02:50 +00:00
jenkins-bot 5c9fe8bd9b Merge "Always evaluate the offset when retrieving array elements" 2019-12-27 09:58:50 +00:00
Translation updater bot 3d9cbb5a94 Localisation updates from https://translatewiki.net.
Change-Id: I10b2ba68f1cfafea0e6f517b76b7f7259d432bd2
2019-12-26 16:17:47 +01:00