aboutsummaryrefslogtreecommitdiffstats
path: root/maintenance/cleanupPreferences.php
Commit message (Collapse)AuthorAgeFilesLines
* maintenance: Use type declaration on undocumented private functionsUmherirrender2025-03-311-1/+2
| | | | Change-Id: I2c1bc3b4e0ee782076ddaeae133672b730d345d9
* BatchRowIterator: Use SelectQueryBuilder directlyBartosz Dziewoński2025-01-071-8/+7
| | | | | | | | | | | Allow passing a SelectQueryBuilder to BatchRowIterator, instead of passing only table names and then setting all other query info using custom methods. Hopefully offering this more familiar interface will make BatchRowIterator easier to use. Change-Id: I87f81ba693e0a74d414342fa5ffc2eac0bcfdf11
* 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
* 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
* Use namespaced classes (1)Umherirrender2024-06-161-1/+1
| | | | | | | Changes to the use statements done automatically via script Addition of missing use statement done manually Change-Id: Ic4d4dd61de5ab896fb6173eb579c81f164a1e4a3
* user: Introduce UserOptionsStoreTim Starling2024-06-121-1/+5
| | | | | | | | | | | | | | | | | | | | | | | Refactoring: * Break out the database access part of UserOptionsManager to a separate class hierarchy implementing interface UserOptionsStore. It's basically a key/key/string-value store, very simple. The complex parts of user options storage remain in UserOptionsManager. * Bundle the UserOptionsManager caches into a per-user cache object. I was adding a couple more and it was getting tedious. Start integrating GlobalPreferences with UserOptionsManager: * Have an array of stores. There's always a local store, and extensions can add stores via an attribute. * Add $global parameter to UserOptionsManager::setOption(), allowing this method to update or override global options. * Rename loadOptionsFromDb to loadOptionsFromStore. * Move the local override feature from GlobalPreferences to core. Bug: T323076 Change-Id: Ib3623b723557c819bc0ffdf21a4ffcb070eb298b
* maintenance: Use expression builder in cleanupPreferences.phpUmherirrender2024-04-211-3/+5
| | | | | | | | Also type-hint for IReadableDatabase Depends-On: I15fc617eae8bc18c911525ea382e99e82b40011a Depends-On: Ib77f8f409b48115684396bf920428adb075c2820 Change-Id: I09d07ba11e8cd6d288c1ed5ddea89b654e24cbb2
* maintenance: Introduce getReplicaDB() and getPrimaryDB()Amir Sarabadani2024-01-181-1/+1
| | | | | | | | | | | | 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
* Add support for conditional user defaultsMartin Urbanec2024-01-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | Why: Sometimes, it is necessary to have different behavior for newly registered and existing users. For example, this happens in the Echo or GrowthExperiments extensions. As of now, this behavior is implemented by inserting user_properties rows in onLocalUserCreated. Over time, this results in a singificant amount of rows inserted, which contributes to the user_properties table bloat, which is already overly large (cf. T54777). This patch makes it possible to remove such rows by supporting conditional defaults for user properties. What: Add support for conditional defaults of user properties. This can be configured via `ConditionalUserOptions` config option. Bug: T321527 Change-Id: I1549c3137e66801c85e03e46427e27da333d68e2
* maintenance: Migrate to DeleteQueryBuilderAmir Sarabadani2024-01-021-5/+4
| | | | | Bug: T353219 Change-Id: Iecb55ab3f905ee9ed4e32e9cbb58c36f8cacf669
* maintenance: Begin using `Maintenance::getServiceContainer()`Derick Alangi2023-09-041-2/+1
| | | | | | | | | | | 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
* maintenance: Use $this->waitForReplication()Amir Sarabadani2022-10-241-2/+1
| | | | | | | This adds reconfiguring db pools in case a replica gets depooled Bug: T298485 Change-Id: Id052ce8ed45c51e51b071778858d27b48605bf93
* Use MainConfigNames instead of string literals, #5Aryeh Gregor2022-04-271-1/+2
| | | | | | | This should be the last of the usages in core, although I'm sure a few are hiding somehow. Change-Id: I7bf0b24bf23d3efb4c56a891830bbfe67945e899
* Improve CleanupPreferences::deleteByWhereUmherirrender2022-02-211-32/+40
| | | | | | | | | | | | - Use BatchRowIterator for the selects. The old code loops with --dry-run, because the old code depends on the delete to select the next batch. With the iterator a pagenation is done. - Use a read and a write connection - One delete per batch - Get the default options from the service to include options from extensions set by the UserGetDefaultOptions hook Change-Id: I463c18c927c76ac2c234f3731a9ddbc9bec9d4f9
* Remove unimplemented "bogus" parts of CleanupPreferencesUmherirrender2021-09-291-17/+4
| | | | Change-Id: I50b5a1bfde6f132b449eda9576ba163f1301ca13
* 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
* Hooks::run() call site migrationTim Starling2020-05-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Migrate all callers of Hooks::run() to use the new HookContainer/HookRunner system. General principles: * Use DI if it is already used. We're not changing the way state is managed in this patch. * HookContainer is always injected, not HookRunner. HookContainer is a service, it's a more generic interface, it is the only thing that provides isRegistered() which is needed in some cases, and a HookRunner can be efficiently constructed from it (confirmed by benchmark). Because HookContainer is needed for object construction, it is also needed by all factories. * "Ask your friendly local base class". Big hierarchies like SpecialPage and ApiBase have getHookContainer() and getHookRunner() methods in the base class, and classes that extend that base class are not expected to know or care where the base class gets its HookContainer from. * ProtectedHookAccessorTrait provides protected getHookContainer() and getHookRunner() methods, getting them from the global service container. The point of this is to ease migration to DI by ensuring that call sites ask their local friendly base class rather than getting a HookRunner from the service container directly. * Private $this->hookRunner. In some smaller classes where accessor methods did not seem warranted, there is a private HookRunner property which is accessed directly. Very rarely (two cases), there is a protected property, for consistency with code that conventionally assumes protected=private, but in cases where the class might actually be overridden, a protected accessor is preferred over a protected property. * The last resort: Hooks::runner(). Mostly for static, file-scope and global code. In a few cases it was used for objects with broken construction schemes, out of horror or laziness. Constructors with new required arguments: * AuthManager * BadFileLookup * BlockManager * ClassicInterwikiLookup * ContentHandlerFactory * ContentSecurityPolicy * DefaultOptionsManager * DerivedPageDataUpdater * FullSearchResultWidget * HtmlCacheUpdater * LanguageFactory * LanguageNameUtils * LinkRenderer * LinkRendererFactory * LocalisationCache * MagicWordFactory * MessageCache * NamespaceInfo * PageEditStash * PageHandlerFactory * PageUpdater * ParserFactory * PermissionManager * RevisionStore * RevisionStoreFactory * SearchEngineConfig * SearchEngineFactory * SearchFormWidget * SearchNearMatcher * SessionBackend * SpecialPageFactory * UserNameUtils * UserOptionsManager * WatchedItemQueryService * WatchedItemStore Constructors with new optional arguments: * DefaultPreferencesFactory * Language * LinkHolderArray * MovePage * Parser * ParserCache * PasswordReset * Router setHookContainer() now required after construction: * AuthenticationProvider * ResourceLoaderModule * SearchEngine Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
* Use Maintenance::getConfig in some maintenance scriptsUmherirrender2019-09-011-5/+5
| | | | | | This avoid global state Change-Id: Id67d07597159a0bd2721a381775230c3cd1d5509
* maintenance: Use addDescription() instead of accessing mDescription directlyDerick Alangi2019-06-111-1/+3
| | | | Change-Id: I705a3fab4a6b151b81b45a3e2d7559f554986378
* Remove empty and unnecessary /* @{{ … */ commentsThiemo Kreuz2019-03-151-3/+0
| | | | | | | This was the only comment I could find that uses two curly brackets for some reason. There are a few more with one curly bracket. Change-Id: Iaed631916064e6be4895edd4c7a3d7de491e16c2
* maintenance: Remove unused code from several maintenance scriptsThiemo Kreuz2019-03-031-1/+0
| | | | | | | | | | | | The most notable removal is done in the orphans script. This code was really never used. Brion introduced it in 2005, already disabled. I have all the respect for what Brion did. I just think it does not make much sense to keep code around for so long if it does not work anyway, and must be rewritten from scratch anyway now that we have multi-content revisions and such. Change-Id: I4e8050929f90e44a6e6051bf938993a8b0cdf649
* Remove a few obscure "done" and "empty" commentsThiemo Kreuz2019-01-301-1/+0
| | | | | | | These don't add any knowledge to what is already obvious from the code, I find. Change-Id: Ia613b6a059f78dbeefdfd020899bd1a6e239a731
* Remove gadget special-case from preferences cleanupSam Wilson2018-04-061-4/+2
| | | | | | | | | Avoiding deletion of 'gadget-' preferences is now done in the Gadgets extension via the hook. Bug: T188966 Change-Id: I81a070986b6e76a2fcec52617b59e9528e52eba2 Depends-On: I5627f014827fdbf266eb7fdb00a446f81a0c3458
* Add DeleteUnknownPreferences hookSam Wilson2018-04-031-9/+8
| | | | | | | | This makes it possible for extensions to add to the WHERE clause with which unknown preferences are deleted. Bug: T188966 Change-Id: Ifb22ca42207956f2b07333da026ff0b215a83930
* Merge "Rewrite pref cleanup script"jenkins-bot2018-01-311-11/+119
|\
| * Rewrite pref cleanup scriptChad Horohoe2018-01-301-11/+119
| | | | | | | | | | | | | | | | | | | | | | | | | | - Keep the current hidden pref cleanup stuff, that's not harmful and marginally useful - Drop preferences we dunno wtf they're about. Cuz they're probably deprecated or otherwise unused - Normalize preferences into accepted value ranges. This part is kinda hard and I haven't figured it out, so slap a TODO More to come, stay tuned! Change-Id: I70047adba0034136d107ce7534294cc6fa3c1860
* | 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
* Convert all array() syntax to []Kunal Mehta2016-02-171-1/+1
| | | | | | | | | | 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
* Clean up transactions in maintenance scriptsAaron Schulz2015-12-301-3/+3
| | | | | | | | | | | | | | | 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
* Some bugzilla.wikimedia.org -> phabricator.wikimedia.org changesumherirrender2015-09-241-1/+1
| | | | | | | | Changed some old bugzilla links to new phabricator links in comments, test data and error message. This reduces the need for redirects from old bugzilla to new phabricator from our source code. Change-Id: Id98278e26ce31656295a23f3cadb536859c4caa5
* phpcs: More require/include is not a functionTimo Tijhof2013-05-211-1/+1
| | | | | | | | | | | | | Follows-up I1343872de7, Ia533aedf63 and I2df2f80b81. Also updated usage in text in documentation and the installer LocalSettingsGenerator. Most of them were handled by this regex: - find: (require|include|require_once|include_once)\s*\(\s*(.+?)\s*\)\s*;$ - replace: $1 $2; Change-Id: I6b38aad9a5149c9c43ce18bd8edbab14b8ce43fa
* phpcs: Fix WhiteSpace.LanguageConstructSpacing warningsTimo Tijhof2013-05-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Squiz.WhiteSpace.LanguageConstructSpacing: Language constructs must be followed by a single space; expected "require_once expression" but found "require_once(expression)" It is a keyword (e.g. like `new`, `return` and `print`). As such the parentheses don't make sense. Per our code conventions, we use a space after keywords like these. We appeared to have an unwritten exception for `require` that doesn't make sense. About 60% of require/include usage was missing the space and/or had superfluous parentheses. It is as silly as print("foo") or return("foo"), it works because keywords have no significance for whitespace between it and the expression that follows, and since experessions can be wrapped in parentheses for clarity (e.g. when doing string concatenation or mathematical operations) the parenthesis before and after basiclaly just ignored. Change-Id: I2df2f80b8123714bea7e0771bf94b51ad5bb4b87
* Fixed some spacing in maintenance folderumherirrender2013-04-181-1/+1
| | | | | | | Added spaces before if, foreach Added some braces for one line statements Change-Id: I9657f72996358f8c1c154cea1ea97970d973723c
* Add some __METHOD__ to begin/commit/rollback callsumherirrender2012-12-011-2/+2
| | | | Change-Id: I20dad8d6bb7a523e8a6f50bc0af5cdba57d7160f
* Bug 42039 - Fix some file-related issues in the distributionMarkAHershberger2012-11-121-52/+52
| | | | | | | | | | Minor issues. Tested the removal of maintenance/postgres/archives/patch-ipb_address_unique.sql in a new installation but haven't tested it on an upgrade. Change-Id: I58aa11c5acab5de427cbc000e6786a208fc6b26f
* Use __DIR__ instead of dirname( __FILE__ )jeroendedauw2012-08-271-1/+1
| | | | | | We can now do this since we finally switched to PHP 5.3 for MW 1.20 and get rid of the silly dirname(__FILE__) stuff :) Change-Id: Id9b2c9cd2e678197aa81c78adced5d1d31ff57b1
* Improve documentation of maintenance scripts.Alexandre Emsenhuber2012-07-081-1/+24
| | | | Change-Id: I2433d23544e808e16f28805f93183b1af2409c94
* Remove BOM from cleanupPreferencesReedy2012-07-071-1/+1
| | | | Change-Id: I3c049c0229bb9ed1365f2781baa44b4c8e1e1e18
* *(bug 30976) Add maintenance script to remove preferences from $wgHiddenPrefsTyA2012-07-041-0/+29
Change-Id: Ie74fab1edeac2c6b275c51e6af3a7924b3aac46b