Commit graph

40 commits

Author SHA1 Message Date
Daimona Eaytoy f0e428d4c3 Fix query in normalizeThrottleParameters
afh_actions was removed from the fields list in
I48f83f64d406c553a55ac4bbee700d59002e6a18, but we actually need it to
build the new actions.

Bug: T209565
Change-Id: I21acced670c568307f87e90179ac3a9d944b0bb1
2019-07-05 18:46:36 +02:00
Thiemo Kreuz aba489a1f4 Add missing type hint to SpecialPage::execute()
[Also make use of the list() feature in one case I forgot before in
If2b6c95.]
 -> Changed to use direct array access by Daimona per inline comment.

Change-Id: I708dff30b6e00ccab3257b2e6fa5995eb9e30e0f
2019-05-16 14:31:54 +00:00
Thiemo Kreuz c6f20a64dd Add missing limits to explode() calls
This is fixing potential bugs where invalid strings with more than one
comma have silently been accepted.

Change-Id: Ib1e7d0c99973f243ef6faad6389bab688187c1cf
2019-05-15 16:14:12 +02:00
jenkins-bot 903f3db8fe Merge "Beautify old, broken abuse_filter_history rows" 2019-04-10 05:11:38 +00:00
Daimona Eaytoy 25ed009518 Beautify old, broken abuse_filter_history rows
And right when the throttle script seemed complete... Here is another
function! So, this change splits the logic in new functions called
sequentially, and the only actual change is adding the beautifyHistory
function. Its purpose is to search ANY row in abuse_filter_history with
empty/missing parameters and normalize it. More specifically, missing
period and count are inserted as 0, and for missing groups we add
"none", used by a newly introduced message. This way, messages shown on
Special:AbuseFilter/history will be clearer and won't have gaps.

Bug:T209565
Bug:T215787
Change-Id: I38395f4df9d83badfd26cdf584ffba743b6417a9
2019-04-10 04:51:58 +00:00
Daimona Eaytoy b4346678c6 Replace deprecated wfWaitForSlaves
Deprecated since 1.27.

Change-Id: I16787520dd4939e6d1579261ac35a4a1f6288b70
2019-03-29 11:01:37 +01:00
Max Semenik 9afac9d6ff Use setDescription() instead of accessing guts directly
Change-Id: I369b88419afc6550922caf625059ad9570428cac
2019-03-25 19:51:20 -07:00
Daimona Eaytoy f2c1beec44 Replace double-equals with triple-equals
Since double-equals are evil. I left some of them in place where I
wasn't sure, but I may be changed some which were intended to be
doubles. It could be a good idea to delay merging this patch until we'll
have more code coverage.

Change-Id: I1721a3ba532d481e3ecf35f51099c1438b6b73b2
2019-03-22 16:12:13 +01:00
jenkins-bot b4780723e4 Merge "Fix faulty query in normalizeThrottleParameters" 2019-03-17 09:50:39 +00:00
Umherirrender da682f78ac Use ::class for class name resolution
Available since php5.5

Change-Id: Ie60465484858867d507081dfe5a305c6ab0599de
2019-03-03 01:41:40 +01:00
Daimona Eaytoy 1244960435 Fix faulty query in normalizeThrottleParameters
The DESC must be specified in the ORDER BY clause, or it will return the
first row instead of the last. Plus select only needed fields and remove
deprecated Database::nextSequenceValue.

Bug: T209565
Change-Id: I48f83f64d406c553a55ac4bbee700d59002e6a18
2019-03-02 12:57:41 +00:00
Daimona Eaytoy 15019ed34d Update the throttle script
Another batch of changes for the throttle script, fixing bugs discovered
on its last run and improving performance.
For a list of fixes, see T209565#4903044.
After merging, we need backports (REL1_32 and wmf branches) and another
dry-run.

Bug: T209565
Change-Id: I530a22d57971f8b22892e43faae5d1c6fa1e14ed
2019-01-24 00:13:09 +01:00
Daimona Eaytoy af9c7ee852 Re-fix the throttle script
This include a technical improvement (use local variables instead of
class members), and prevents displaying duplicates in the list of broken
filters.
It also covers other two quite common cases: the one where groups aren't
lowercase (for instance 'Page' instead of 'page') and extra spaces (e.g.
'user, ip' instead of 'user,ip'). The former is now fixed automatically,
while the second is a correct syntax which we don't need to fix, but now
it's effectively recognized as correct.

Bug: T209565
Change-Id: Idbfa114048bfb1127b1240c787cffa8973a47220
2019-01-09 15:58:49 +01:00
Daimona Eaytoy ea89dd4ca3 Report all filters with wrong throttle parameters
Instead of only the first one. This is quite hacky, but I don't have
much time right now, and this script is written in the spirit of JFDI.

Bug: T209565
Change-Id: Ic12ff21dd41b619bea9c71001555fd4d6299e58b
2018-12-17 20:19:20 +01:00
Daimona Eaytoy aa280998c0 Fix big problems with normalizeThrottleParameters
My final testing unveiled 4 problems, see T209565#4780868. Testing again
after this patch yields the expected outcome.

Update: A fifth problem is that we cannot disable throttling if throttle
groups are empty or fully invalid: that case is similar to the one with
invalid rate, the throttle limit is never reached and thus throttle just
doesn't work. Instead, ask users to fix it by hand.

Bug: T203336
Bug: T209565
Change-Id: Id03c9880f60764efc596ac40b8662087fdb30550
2018-12-15 18:36:16 +01:00
Daimona Eaytoy d3a8491c3f Change throttle selector to restore old functionality, overall improvement
Long (sigh) explanation in T203587#4569698. Also, simplified the way
TagMultiselect are generated, this one and the one for change tags.
This new selector is back-compat both with the old textarea and the OOUI
checkboxMultiselect; actually, this one is //fully// compatible with the
old textarea.
Add validation for throttle parameters and unit tests for validation
(split from I976c95658cddb2585910b6f8a5f047aadc4e4d47).
Added a trim when retrieving throttle identifier to allow syntax like
'ip, user'.
Improved the message shown on history.
Re-added the maintenance script to clean DB.

As I wrote in the task, a review by two other people would be great, at
least for the maintenance script (it could potentially break the DB).

Bug: T203587
Bug: T203336
Bug: T203584
Bug: T203585
Depends-On: I3b2e763bd8835207dc5df1db43d3e1881e6961c3
Change-Id: I7831dbb0bab55807392ac1f7915d6cb0cb713593
2018-11-14 12:51:36 +01:00
Matěj Suchánek 45d1d71def Reduce use of globals in favor of Config
I'd like to have this reviewed by more than one user before merging, to avoid regressions of annoying typos.

Change-Id: I91a9c5cca55e540a6c95b750579c1c369a760b15
2018-05-02 02:27:26 +00:00
Daimona Eaytoy 3c3a521fec Fix coding conventions exclusion rules
This should fix every error with excluded rules, leaving only the one
for $wgTitle. A double check would be nice in order to avoid regressions
due to stupid mistakes.

Bug: T178007
Change-Id: I22c179f3a01d652640304b59e43fcb5b5a9abac3
2018-04-20 08:40:18 +00:00
Brad Jorsch 3014871cb5 Update for the actor table change
Core change I8d825eb0 begins the process of changing core database
tables from using xx_user and xx_user_text fields to using xx_actor.
This updates the extension to continue to function during and after the
transition.

Bug: T167246
Change-Id: I4065716022aa60c0fa1a258659db22be2b7f43de
2018-03-09 16:34:24 -05:00
Brad Jorsch 7399cd4348 Update CommentStore usage
CommentStore's calling conventions changed in I3abb62a5c.

Change-Id: I80012f82b39e5054ee40a44b5a8e92dec46c2962
2018-03-09 16:22:32 -05:00
Huji Lee 8ca391c8e0 Correctly reference the "Abuse Filter" extension in maintenance scripts
Bug: T186928
Change-Id: I415f39aa618a6148ad29a3fb4b059aadbfd63da5
2018-02-10 16:13:41 +00:00
Max Semenik 58d29d04a1 Use getBatchSize() instead of direct field access
Change-Id: If2dd3a6b80a228605138ae7b6c8da718c0f07d62
2017-11-07 19:39:34 -08:00
jenkins-bot 689b7abaff Merge "Remove back-compat code paths" 2017-10-31 16:12:40 +00:00
Brad Jorsch 6071e7a43f Remove back-compat code paths
Per T178092, AbuseFilter now maintains compatibility with older versions
of MediaWiki using release branches. Thus, various back-compat code
paths may be removed from the master branch.

Change-Id: Ia1b5eade30d7486e3b1b386b15a7db4e5c8cfead
2017-10-31 09:37:54 -04:00
Simeon Dahl 4c0636bc0a Cleanup, added spaces
Added spaces in some classes so it follow the same style as the others.
Edit is pure cleanup.

Change-Id: If5d5e6e4e99eed83aa69dfb4a224fbcc7c077d43
2017-10-19 09:40:22 +02:00
Brad Jorsch cfa98448c3 Use CommentStore to access core comment fields when available
See core change Ic3a434c0.

Bug: T166732
Change-Id: I130510381ef97d8a2d29686843e2710cb5f72195
2017-08-30 13:27:46 -04:00
Max Semenik 0686f99653 DB_SLAVE -> DB_REPLICA
Change-Id: I371e092b3cd7f0af3770bf4e64b01a630e23ff92
2017-08-29 19:51:39 -07:00
Umherirrender a063e33ee8 Use short array syntax
Done by phpcbf over composer fix

Change-Id: I53fd1fc8d056b9b60194d2d630852cfca37aadea
2017-06-15 17:02:57 +02:00
pppery 66f52694a2 Make maintenance scripts use $this->requireExtension()
Bug: T152139
Change-Id: I9c3a6a186275b6554a761de8548bc16f8938d488
2016-12-12 22:42:00 +00:00
Paladox b3081e1798 Update mediawiki/mediawiki-codesniffer to 0.5.1
Change-Id: I4b2055a76db4362a8136e3fd595228cf07d083a9
2016-08-23 16:18:27 +02:00
Siebrand Mazeland ce1396aea7 Add support for PHP CodeSniffer checks
Also fix any remaining errors and warnings.

Change-Id: Ie49c6172e6bbf8040e5524d33d2f719e96784745
2016-01-06 09:59:47 -08:00
jenkins-bot 5f1447d698 Merge "No longer call removed SpecialPage::getLocalPageForName" 2015-08-22 23:29:39 +00:00
Alex Monk d010f3c0c9 No longer call removed SpecialPage::getLocalPageForName
Removed in I5122f0f2, which was after this script was written but long before
it was merged.

Bug: T54919
Change-Id: If67a5f137590414ba8c6c958d819e87099a3b010
2015-08-23 00:01:18 +01:00
jenkins-bot 01a024ffdc Merge "Fix addMissingLoggingEntries maintenance script handling of newlines" 2015-08-22 22:45:22 +00:00
Alex Monk e3db4db83e Fix addMissingLoggingEntries maintenance script handling of newlines
Bug: T54919
Change-Id: I0a979d9022ce3371813e214a7e4e1432e34c823b
2015-08-22 23:28:18 +01:00
jenkins-bot 75cb547f27 Merge "Add maintenance script to restore missing log entries for each filter history entry" 2015-08-11 19:46:45 +00:00
Krenair 1b9c71fabe Add maintenance script to restore missing log entries for each filter history entry
Quite a few of these occured on wikis between r48501 (2009-03-17) and r52734 (2009-07-03)

Bug: 52919
Change-Id: Ib33d0a1814fe131a5291ed7408057515482aa61f
2015-08-08 01:32:37 +01:00
Aaron Schulz 4219fa141c Fixed broken batching in –PurgeOldLogIPData
Bug: T95382
Change-Id: I133642e5dd8e75e98e6189ad10f54dbbea648c8d
2015-04-07 19:28:26 -07:00
Reedy b7fa8d5d20 $res is a bool, not a resultwrapper..
Display running count. Silent scripts are annoying

Change-Id: I4dcebbf1cd49dce6332ed1bdc0e2ba7aced4b8f1
2014-01-03 18:06:49 +00:00
Reedy cac808a35c Write maintenance script for AbuseFilter to purge old IP data from logs
Bug: 51573
Change-Id: I93392d77fb6172d55353d2ba7fb1be3a19f13b11
2013-11-19 21:44:14 +00:00