Commit graph

25 commits

Author SHA1 Message Date
Daimona Eaytoy 45d80bc7e5 Clean up view classes
- Depend on a generic IContextSource rather than SpecialAbuseFilter
  (lower coupling);
- Inject a LinkRenderer (IContextSource doesn't have a ::getLinkRenderer
  method)
- Add a helper method in SpecialAbuseFilter to get the page title, that
  can also be used elsewhere (and the name constant can be made private
  now)
- Pull down the mFilter property (and rename it to just 'filter') to
  classes that actually need it. Some classes didn't need this at all
  and the types were different among subclasses

Now the only cause of coupling between the View classes and
SpecialAbuseFilter is the static call in getTitle.

Change-Id: I3df0c3a7621f0cc9a64a16b0a402a15aae2d5d73
2020-10-13 10:38:43 +02:00
Daimona Eaytoy 97afa97403 Exclude old, single-use scripts from coverage reports
These scripts were already included in the updater (and hence executed)
several MW versions ago. There's no need to write tests for them right
now, so exclude these from coverage.

Change-Id: I43e46f06b98bb3b9b9d61a45baaf232e2a99c308
2020-09-30 12:42:34 +02: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
Daimona Eaytoy 302c967ce7 Fix addMissingLogEntriesScript
This script was plagued by several problems:
 - it used SUBSTRING_INDEX, thus breaking support for Postgres and
 SQLite
 - it didn't recognize non-legacy rows, thus creating duplicates
 - it didn't extend LoggedUpdateMaintenance, but we only want it to be
 executed once
 - it didn't have a dry-run option

And most importantly: it inserted new rows using '\n' as separator,
instead of "\n" (note single quotes), thus creating broken entries.

Bug: T228655
Bug: T208931
Change-Id: I3a7b0fe32f1516ba21fa0ef380a9f54062e9c680
2019-12-03 17:45:00 +00: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
Daimona Eaytoy b4346678c6 Replace deprecated wfWaitForSlaves
Deprecated since 1.27.

Change-Id: I16787520dd4939e6d1579261ac35a4a1f6288b70
2019-03-29 11:01:37 +01: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
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 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
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
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
Alex Monk e3db4db83e Fix addMissingLoggingEntries maintenance script handling of newlines
Bug: T54919
Change-Id: I0a979d9022ce3371813e214a7e4e1432e34c823b
2015-08-22 23:28:18 +01: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