aboutsummaryrefslogtreecommitdiffstats
path: root/maintenance/cleanupSpam.php
Commit message (Collapse)AuthorAgeFilesLines
* add `use MediaWiki\Maintenance\Maintenance` to some maintenance classesNovem Linguae2024-11-121-0/+1
| | | | | | | A–F. Still need to do F–Z. Bug: T353458 Change-Id: Ieb4bad0658b9cddc9403c6a55ef3bd1245aa08ae
* maintenance: add transaction round wrapper methods to MaintenanceAaron Schulz2024-11-051-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | These help with the basic pattern of running loop of transaction rounds, each of which should handle deferred updates and possible replication wait barriers. Add Maintenance::newBatchIterator() helper method for easily wrapping an iterator with an batching iterator. This is useful for grouping the writes in transaction rounds and avoiding the slowness of excessive waitForReplication() calls. Update some maintenance scripts to use these methods, including: * makeTestEdits.php * importSiteScripts.php * cleanupSpam.php * protect.php * undelete.php * rollbackEdits.php * namespaceDupes.php * uppercaseTitleForUnicodeTransition.php Deprecate the single-connection transaction wrappers. Bug: T373057 Change-Id: I42256f9e775bad102e6e5d47c512e0b5cc60d070
* Exclude boilerplate maintenance code from code coverage reportsDreamy Jazz2024-08-271-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | Why: * Maintenance scripts in core have bolierplate code that is added before and after the class to allow directly running the maintenance script. * Running the maintenance script directly has been deprecated since 1.40, so this boilerplate code is only to support a now deprecated method of running maintenance scripts. * This code cannot also be marked as covered, due to PHPUnit not recognising code coverage for files. * Therefore, it is best to ignore this boilerplate code in code coverage reports as it cannot be marked as covered and also is for deprecated code. What: * Wrap the boilerplate code (requiring Maintenance.php and then later defining the maintenance script class and running if the maintenance script was called directly) with @codeCoverageIgnore comments. * Some files use a different boilerplate code, however, these should also be marked as ignored for coverage for the same reason that coverage is not properly reported for files. Bug: T371167 Change-Id: I32f5c6362dfb354149a48ce9c28da9a7fc494f7c
* cleanupSpam: Add import for DatabaseReedy2024-05-171-0/+1
| | | | Change-Id: Ia13c319cef766dd345b828c5f0bc8e40ede06863
* maintenance: Introduce getReplicaDB() and getPrimaryDB()Amir Sarabadani2024-01-181-2/+2
| | | | | | | | | | | | And start using them instead of wfGetDB(), LB/LBF connection methods or worse, $this->getDB(). $this->getDB() reuses the database object regardless of whether you're calling a replica or primary, leading to returning a replica on a primary and other way around. Bug: T330641 Change-Id: I9e2cf85ca277022284fc26b9f37db57bd12aaa81
* Namespace User under \MediaWiki\UserJames D. Forrester2023-09-191-0/+1
| | | | | Bug: T166010 Change-Id: I7257302b485588af31384d4f7fc8e30551f161f1
* Merge "maintenance: Replace usages of deprecated WikiPage::doDeleteArticleReal"jenkins-bot2023-09-111-4/+2
|\
| * maintenance: Replace usages of deprecated WikiPage::doDeleteArticleRealDaimona Eaytoy2021-11-081-4/+2
| | | | | | | | | | | | Use DeletePage instead. Change-Id: Icf064d6f8ce609d1119b45377af037ed03e464a4
* | maintenance: Begin using `Maintenance::getServiceContainer()`Derick Alangi2023-09-041-3/+2
| | | | | | | | | | | | | | | | | | | | | | Maintenance class provides a method for getting a fresh reference of the MW services container instance. Let's make use of these in maintenance scripts now that we have it. NOTE: There are still some static methods like in refreshLinks.php that makes use of services that we can't use this method for now. Change-Id: Idba744057577896fc97c9ecf4724db27542bf01c
* | Replace more usages of deprecated MWExceptionDaimona Eaytoy2023-06-081-1/+0
| | | | | | | | | | Bug: T328220 Change-Id: Ib619ead0f397188d828e6e5dfc80ed1fa7175c7d
* | build: Cleanup of .phpcs.xmlUmherirrender2023-04-131-0/+1
| | | | | | | | | | | | Use inline suppression for known exception from eval/passthru/query call Change-Id: Ie85ea5698a615adf07e4e391bf06d102149effd5
* | Just another 80 or so PHPStorm inspection fixes (#4)Tim Starling2023-03-251-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | * Unnecessary regex modifier. I agree with this inspection which flags /s modifiers on regexes that don't use a dot. * Property declared dynamically. * Unused local variable. But it's acceptable for an unused local variable to take the return value of a method under test, when it is being tested for its side-effects. And it's acceptable for an unused local variable to document unused list expansion elements, or the nature of array keys in a foreach. Change-Id: I067b5b45dd1138c00e7269b66d3d1385f202fe7f
* | Merge "Reorg: Move LinkFilter to ExternalLinks"jenkins-bot2023-03-031-0/+1
|\ \
| * | Reorg: Move LinkFilter to ExternalLinksAmir Sarabadani2023-03-011-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It's one-class namespace and I know it's not great but: - I hope to add more classes with the redesign of externallinks table - It's not named very well either, it's a collection of URL-related functionalities - Making it clear LinkFilter is about external links, not internal or interwiki or templatelinks etc. Bug: T321882 Change-Id: I0dd530237f45e4fec786178ec03ee941c6bcd982
* | | Reorg: Namespace the Title classJames D. Forrester2023-03-021-0/+1
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is moderately messy. Process was principally: * xargs rg --files-with-matches '^use Title;' | grep 'php$' | \ xargs -P 1 -n 1 sed -i -z 's/use Title;/use MediaWiki\\Title\\Title;/1' * rg --files-without-match 'MediaWiki\\Title\\Title;' . | grep 'php$' | \ xargs rg --files-with-matches 'Title\b' | \ xargs -P 1 -n 1 sed -i -z 's/\nuse /\nuse MediaWiki\\Title\\Title;\nuse /1' * composer fix Then manual fix-ups for a few files that don't have any use statements. Bug: T166010 Follows-Up: Ia5d8cb759dc3bc9e9bbe217d0fb109e2f8c4101a Change-Id: If8fc9d0d95fc1a114021e282a706fc3e7da3524b
* | Reorg: Move StubObject classes in includes to its own directoryAmir Sarabadani2022-10-251-0/+1
| | | | | | | | | | Bug: T166010 Change-Id: Idcf0e9dc6e0841e4f132207bce0f96774dad898c
* | maintenance: Use SelectQueryBuilder to construct queriesDerick Alangi2022-07-191-12/+13
| | | | | | | | | | | | | | Part 1 of migrating files in `maintenance/` from IDatabase::select() to SelectQueryBuilder. Change-Id: Idfe83b900de3fbc6a251a5a78d8af1a4cd88970f
* | phan: Disable null_casts_as_any_type settingUmherirrender2022-03-211-0/+2
| | | | | | | | | | | | | | | | | | | | | | Make phan stricter about null types by setting null_casts_as_any_type to false (the default in mediawiki-phan-config) Remaining false positive issues are suppressed. The suppression and the setting change can only be done together Bug: T242536 Bug: T301991 Change-Id: I0f295382b96fb3be8037a01c10487d9d591e7e01
* | rdbms: Remove usage of deprecated function Database::numRows()Amir Sarabadani2022-01-191-1/+1
|/ | | | | Bug: T286694 Change-Id: I6e34e7cccdeb30022863122d39824c742f6fb236
* Emit deprecation warnings reading from $wgUserDannyS7122021-09-151-2/+2
| | | | | | | | | | | | | | | | | | With this patch deprecation warnings will be emitted if $wgUser is accessed or written into. The only pattern of usage still allowed is $oldUser = $wgUser; $wgUser = $newUser; // Do something $wgUser = $oldUser; Once there is no deprecation warnings, we know that nothing legitimately depends on $wgUser being set, so we can safely remove the code that's still allowed as well. Bug: T267861 Change-Id: Ia1c42b3a32acd0e2bb9b0e93f1dc3c82640dcb22
* Hard deprecate User group methodsvladshapik2021-07-231-1/+1
| | | | | | | | | | | | | | | | 1) The following methods were hard deprecated: - User::addAutopromoteOnceGroups - User::getEffectiveGroups - User::getAutomaticGroups - User::getFormerGroups 2) User ::getGroups, ::getGroupMemberships, ::addGroup, ::removeGroup were replaced in the production code, but they were not hard deprecated because of conflict with UserRightsProxy class. Bug: T275148 Change-Id: Ia69598316f5dc5dd9511f6112b5b13e1aa07575a
* Use WikiPage::doUserEditContent() instead of ::doEditContent()DannyS7122021-06-281-7/+6
| | | | | | | | Results in passing a user where previously the fallback to $wgUser was being used, mostly in tests. Bug: T255507 Change-Id: Iabe24315b23c0ad1272353186425e71974528d23
* Remove some unneeded uses of full User objectsDannyS7122021-05-221-5/+6
| | | | Change-Id: Ib86399445a77d3005f23ae87d87f3cf742b13b1f
* Replace uses of DB_MASTER with DB_PRIMARYJames D. Forrester2021-04-291-1/+1
| | | | | | Just an auto-replace from codesniffer for now. Change-Id: I5240dc9ac5929d291b0ef1c743ea2bfd3f428266
* cleanupSpam: pass a user when editing a pageDannyS7122020-12-141-5/+8
| | | | | | | | Avoid fallback to $wgUser (see T255507 for work on deprecating that fallback) Bug: T243708 Change-Id: I188fec7b31c327815d2f92861ead8c79d06a3b5b
* Replace deprecated WikiPage::factory/newFromID in maintenance scriptsUmherirrender2020-11-121-4/+4
| | | | Change-Id: I5b2d4313f986484368da9b63c9a19892c2328dae
* cleanupSpam - reduce direct references to $wgUserDannyS7122020-09-151-1/+1
| | | | | Bug: T243708 Change-Id: I6a607dd1acb3b29c053ce933faf91e75cf27e068
* maintenance scripts: Reduce direct references to $wgUserDannyS7122020-06-051-3/+4
| | | | | | | | Only use `wgUser` when setting or retrieving the global, not for the user object that it is set to Bug: T243708 Change-Id: Ie962192f1dbc066ba71b9abb48dc9d522d472c78
* Replace uses and hard deprecate Revision::newFromTitleDannyS7122020-04-181-5/+12
| | | | | | | Also fixed a use of ::newFromId in benchmarkParse and Parser Bug: T249183 Change-Id: I3219a72f1085836205dc497e2236b52db24d7c16
* Maintenance: Change ::doDeleteArticle to WikiPage::doDeleteArticleRealDannyS7122020-03-251-4/+11
| | | | | Bug: T248000 Change-Id: I48bcf68e90209c5cfc2b7fedbf70fdffc374ec64
* Introduce ContentHandlerFactoryArtBaltai2020-02-071-1/+4
| | | | | | | | | | | | | | | | | 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
* phan: Disable enable_class_alias_supportUmherirrender2019-09-151-1/+1
| | | | | | It is enabled for b/c in extensions, but not needed in core Change-Id: I51dca12be9c77049f77563d9bf0edd07928c2300
* Merge "Replace wfWiki() usage with WikiMap in some additional places"jenkins-bot2019-07-231-4/+4
|\
| * Replace wfWiki() usage with WikiMap in some additional placesAaron Schulz2019-07-041-4/+4
| | | | | | | | Change-Id: Ide4518292bd9392d09f701b2c301673687d19f3b
* | maintenance: Avoid usage of deprecated Revision::* constantsDerick Alangi2019-07-211-3/+5
|/ | | | | | | Update deprecated Revision::* constants to use RevisionRecord::* equivalents. Change-Id: Icae1ebb088e4efadbc7c2806127a2073d337fa05
* Fix order of @var parameter in PHPFomafix2019-04-081-2/+2
| | | | | | | | | | | | Replace @var $foo type by @var type $foo Change-Id: Iec8b90ffea4028a1005daef422b7c4ec38c2715f
* maintenance: Deprecate Maintenance::hasArg/getArg with no paramThiemo Kreuz2019-03-291-1/+1
| | | | | | | | | | | | | | | | | | | Benefit of keeping the parameter optional: - In maintenance scripts that really only have one parameter, it's a little more convenient to be able to ask for *the* parameter via an empty getArg(). Disadvantages: - It's unclear what getArg() means when there is no indication *which* argument the code asks for. This might as well return the last argument, or an array of all arguments. - In scripts with two or more arguments, it's confusing to see getArg( 1 ) next to an empty getArg(). - The methods are more complex and a bit more complicated to use with the extra feature of this parameter being optional. Users need to look up what the default is to be able to use it safely. Change-Id: I22a43bfdfc0f0c9ffdb468c13aba73b888d1f15e
* Use new externallinks.el_index_60 fieldBrad Jorsch2018-11-121-8/+8
| | | | | | | | | | | | | | | | | | | | | This adds a method to LinkFilter to build the query conditions necessary to properly use it, and adjusts code to use it. This also takes the opportunity to clean up the calculation of el_index: IPs are handled more sensibly and IDNs are canonicalized. Also weird edge cases for invalid hosts like "http://.example.com" and corresponding searches like "http://*..example.com" are now handled more regularly instead of being treated as if the extra dot were omitted, while explicit specification of the DNS root like "http://example.com./" is canonicalized to the usual implicit specification. Note that this patch will break link searches for links where the host is an IP or IDN until refreshExternallinksIndex.php is run. Bug: T59176 Bug: T130482 Change-Id: I84d224ef23de22dfe179009ec3a11fd0e4b5f56d
* Make cleanupSpam.php query for http and httpsReedy2018-06-031-18/+46
| | | | | Bug: T186795 Change-Id: I9e350306f85d3d3ca4daba626e49a0792605acc7
* Use ::class to resolve class names in maintenance scriptsUmherirrender2018-01-231-1/+1
| | | | | | | This helps to find renamed or misspelled classes earlier. Phan will check the class names Change-Id: I1d4567f47f93eb1436cb98558388e48d35258666
* Maintenance: add fatalError() methodBryan Davis2017-11-211-2/+2
| | | | | | | | Deprecate the second argument to Maintenance::error() in favor of a new Maintenance::fatalError() method. This is intended to make it easier to review flow control in maintenance scripts. Change-Id: I75699008638f7e99b11210c7bb9e2e131fca7c9e
* Update cleanupSpam.php to hide its activity from RecentChangesMarcoAurelio2017-09-291-6/+6
| | | | | | | | | | | | | | | | | Spam cleanup activities, mostly when it comes from automated processes (the so called 'spambots') can involve a fair ammount of edits and log actions to accomplish. As such, to avoid flooding Special:RecentChanges, this script will now set a bot flag on the script run so its edits and actions won't show up in that special page. To prepare this patch I had the help of Bartosz Dziewoński which I'd also like to thank and I'll credit as co-author as well. Bug: T176206 Co-Authored-By: Bartosz Dziewoński <matma.rex@gmail.com> Change-Id: Ifde08056a7481b877b4b82699cc0a5ea3f962dd9
* Rename DB_SLAVE constant to DB_REPLICAAaron Schulz2016-09-051-2/+2
| | | | | | | | | This is more consistent with LoadBalancer, modern, and inclusive of master/master mysql, NDB cluster, and MariaDB galera cluster. The old constant is an alias now. Change-Id: I0b37299ecb439cc446ffbe8c341365d1eef45849
* Convert all array() syntax to []Kunal Mehta2016-02-171-5/+5
| | | | | | | | | | Per wikitech-l consensus: https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html Notes: * Disabled CallTimePassByReference due to false positives (T127163) Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
* Use addDescription() instead of accessing mDescription directlyMax Semenik2016-01-301-1/+1
| | | | Change-Id: I0e2aa83024b8abf5298cfea4b21bf45722ad3103
* Update wfGetDB calls in Maintenance scripts to use getDB()Reedy2016-01-021-3/+3
| | | | Change-Id: I9ad6745d84506b736dae94747256caac89715899
* Clean up transactions in maintenance scriptsAaron Schulz2015-12-301-2/+2
| | | | | | | | | | | | | | | Add transaction methods to complement getDB(). This makes it easy to grep for direct begin()/commit() calls to IDatabase by having script use their own wrapper. Maintenance scripts are one of the few places that can (and need to) use begin/commit instead of the start/end atomic methods. Eventually, there should be almost no direct callers and those methods can be made stricter about throwing errors on nested calls. Change-Id: Ibbfc7a77c0d2a55f7fc2261087f6c3a19061e0aa
* User: Mostly remove password handlingBrad Jorsch2015-10-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | AuthManager is coming, which will make it easier to add alternative methods of authentication. But in order to do that, we need to finally get around to ripping the password-related bits out of the User class. The password expiration handling isn't used anywhere in core or extensions in Gerrit beyond testing for expired passwords on login and resetting the expiry date on password change. Those bits have been inlined and the functions removed; AuthManager will allow each "authentication provider" to handle its own password expiration. The methods for fetching passwords, including the fact that mPassword and other fields are public, has also been removed. This is already broken in combination with basically any extension that messes with authentication, and the major use outside of that was in creating system users like MassMessage's "MediaWiki message delivery" user. Password setting methods are silently deprecated, since most of the replacements won't be available until AuthManager. But uses in unit testing can be replaced with TestUser::setPasswordForUser() immediately. User::randomPassword() and User::getPasswordFactory() don't really belong in User either. For the former a new PasswordFactory method has been created, while the latter should just be replaced by the two lines to create a PasswordFactory via its constructor. Bug: T47716 Change-Id: I2c736ad72d946fa9b859e6cd335fa58aececc0d5
* Update formatting in maintenance/ (2/4)Siebrand Mazeland2014-04-231-1/+3
| | | | Change-Id: I2b791d3bff0de464b6bdaaeae0622c065389c31c
* Pass phpcs-strict on maintenance/ (7/8)Siebrand Mazeland2014-04-231-5/+17
| | | | Change-Id: Ibb03a775055c687a4c5bc6864172e043d3a7e3d8