aboutsummaryrefslogtreecommitdiffstats
path: root/maintenance/storage/checkStorage.php
Commit message (Collapse)AuthorAgeFilesLines
* maintenance: Use type declaration on undocumented private functionsUmherirrender2025-03-311-3/+3
| | | | Change-Id: I2c1bc3b4e0ee782076ddaeae133672b730d345d9
* Replace a number of uses of class aliases with the real thingsJames D. Forrester2025-03-261-0/+1
| | | | | | | Found via disabling phan's alias support for a run (and ignoring wgLang's hard-coded state of being a \Language, alas). Change-Id: I4753bcd84d72d6de111fc7ffc5841fa417bf7333
* externalstore: cleanup ExternalStoreDB::getTable() and fix callersAaron Schulz2024-09-181-2/+2
| | | | | | | | | | | Remove unused $db parameter and make the $cluster required. Update the checkStorage.php callers to provide the cluster. Use the getTable() method in trackBlobs.php to avoid duplication. Mark this method as @internal to the class and /storage scripts. Change-Id: I888040a536a60e22e780900a59e4c34b6c468cdf
* maintenance: Add missing documentation to class propertiesUmherirrender2024-09-131-0/+1
| | | | | | | | | | Add doc-typehints to class properties found by the PropertyDocumentation sniff to improve the documentation. Once the sniff is enabled it avoids that new code is missing type declarations. This is focused on documentation and does not change code. Change-Id: I7dec01892a987a87b1b79374a1c28f97d055e8fa
* 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-0/+1
| | | | | | | Changes to the use statements done automatically via script Addition of missing use statement done manually Change-Id: Ic4d4dd61de5ab896fb6173eb579c81f164a1e4a3
* Merge "Use expression builder to avoid raw sql via BETWEEN operator"jenkins-bot2024-04-231-1/+4
|\
| * Use expression builder to avoid raw sql via BETWEEN operatorUmherirrender2024-04-211-1/+4
| | | | | | | | | | | | Replace BETWEEN with >= and <= operator Change-Id: Ic21b6f4cc11c773c967d9d4c5f20e762c2ff9629
* | maintenance: storage: Fix multiple property declaration phpcs errorsTaavi Väänänen2024-04-211-1/+2
|/ | | | Change-Id: I74302c9b2818e02d7d5e67a728558ced5e8f0181
* maintenance: Migrate to IDatabase::newUpdateQueryBuilderUmherirrender2024-04-141-7/+12
| | | | | Bug: T353219 Change-Id: Ic278c8534dad40a3f34674db2d5fbfbca5984da8
* maintenance: Introduce getReplicaDB() and getPrimaryDB()Amir Sarabadani2024-01-181-6/+6
| | | | | | | | | | | | 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
* WikiImporter: Pass Authority for permissions instead of global contextBartosz Dziewoński2023-12-111-1/+3
| | | | | | | | | | | | | | | Pass Authority to WikiImporter constructor, instead of looking at the user from RequestContext::getMain(), and skipping this check if $wgCommandLineMode is true. Maintenance scripts now use UltimateAuthority, to match the original intent of skipping permission checks, see 2ed55f42 / r96311. The Authority parameter to WikiImporterFactory::getWikiImporter() is optional for now for backwards-compatibility. It should become required later after deprecation. Change-Id: Iea1d03dcdcbda2f9a9adbff1b0d319efd22c4d86
* maintenance: Migrate another batch to SelectQueryBuilderAmir Sarabadani2023-09-211-10/+10
| | | | | | | Around fifty-ish. Found becuase of fixed MigrateSelect. Bug: T344971 Change-Id: If85428d5a033822bfd8ee1f6ab730863bfad55bd
* maintenance: Begin using `Maintenance::getServiceContainer()`Derick Alangi2023-09-041-6/+5
| | | | | | | | | | | 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: Switch simple calls of Database::select to SQBAmir Sarabadani2023-07-191-41/+36
| | | | | | | Done semi-automatically via a php parser written on top of ANTLR4. Bug: T311866 Change-Id: I33f5b6703c0aa9c80c907a21c2a770e30642edd3
* Make some storage scripts use Maintenance classdaniel2023-06-141-10/+21
| | | | | | | CommandLineInc is deprecated. This allows the scripts to be executed from MaintenanceRunner. Change-Id: I180605ea5cb47783670b28a6f01d98f0398c705d
* build: Cleanup of .phpcs.xmlUmherirrender2023-04-131-0/+1
| | | | | | Use inline suppression for known exception from eval/passthru/query call Change-Id: Ie85ea5698a615adf07e4e391bf06d102149effd5
* Fix some PHPStorm inspections (#1)Tim Starling2023-03-251-2/+2
| | | | | | | | | | | | * Triple backslash in regex should really be quadruple backslash * Using the returned value of a void method * Immediately overwritten array keys * Duplicate array keys * Foreach variable reuse * sprintf() with too many params * Incorrect reference usage Change-Id: I3c649b543c9561a1614058c50f3847f663ff04df
* Use short array destructuring instead of list()Tim Starling2022-10-211-1/+1
| | | | | | | | Introduced in PHP 7.1. Because it's shorter and looks nice. I used regex replacement. Change-Id: I0555e199d126cd44501f859cb4589f8bd49694da
* checkStorage: pass no parameters to WikiRevision::getContent()Universal Omega2021-10-241-2/+1
| | | | | | | This defaults to SlotRecord::MAIN, which is what it should be rather than RevisionRecord::RAW Bug: T294043 Change-Id: Ib035fe4eea778747f47a476c8aa2cfaab44aa7d8
* CheckStorage: Annotate importRevision $revision parameter as being WikiRevisionReedy2021-10-211-0/+3
| | | | Change-Id: Ic07cd955a3a25a70db2a1589a57d19a592813986
* Fix checkStorage.phpUniversal Omega2021-10-211-1/+1
| | | | | | | | | | Fixes checkStorage.php --fix * importRevision() is required to be public for WikiImporter::setRevisionCallback() * $revision must not be passed by reference * $importer is unused, so removed Change-Id: I53ef3825308af3b6e632cb88b9a3eb2f40ab5239
* HistoryBlobStub: add getLocation() to get $mOldIdUniversal Omega2021-10-191-1/+1
| | | | | | | For use in the checkStorage and resolveStubs maintenance scripts, in order to fix them. Follows-Up: Id1f530c2c8ec1171615f726dc7446431ee7ca8fe Change-Id: Iade3d1660f2b7db62f829f5e5ca94372614ae7e5
* build: Update mediawiki/mediawiki-phan-config to 0.11.0Umherirrender2021-09-071-2/+0
| | | | | | | Addition and remove of suppression needs to be done with the version update. Change-Id: I3288b3cefa744b507eadebb67b8ab08c86517c1c
* Use array_fill_keys() instead of array_flip() if that reflects the ↵Tim Starling2021-06-151-1/+1
| | | | | | | | | | | | | | | | | | developer's intention array_fill_keys() was introduced in PHP 5.2.0 and works like array_flip() except that it does only one thing (copying keys) instead of two things (copying keys and values). That makes it faster and more obvious. When array_flip() calls were paired, I left them as is, because that pattern is too cute. I couldn't kill something so cute. Sometimes it was hard to figure out whether the values in array_flip() result were used. That's the point of this change. If you use array_fill_keys(), the intention is obvious. Change-Id: If8d340a8bc816a15afec37e64f00106ae45e10ed
* WikiImporter: inject servicesZabeMath2021-05-241-4/+3
| | | | | | | | This patch injects services into WikiImporter. It also adds a WikiImporterFactory service for creating WikiImporter instances. Change-Id: I2966297e5728fca1ae8280361f1008cef6c6041b
* Replace uses of DB_MASTER with DB_PRIMARYJames D. Forrester2021-04-291-3/+3
| | | | | | Just an auto-replace from codesniffer for now. Change-Id: I5240dc9ac5929d291b0ef1c743ea2bfd3f428266
* Use static closures where safe to useUmherirrender2021-02-111-1/+1
| | | | | | | | | This is micro-optimization of closure code to avoid binding the closure to $this where it is not needed. Created by I25a17fb22b6b669e817317a0f45051ae9c608208 Change-Id: I0ffc6200f6c6693d78a3151cb8cea7dce7c21653
* build: Enable phan-taint-check-plugin and suppress issuesUmherirrender2020-12-301-7/+0
| | | | | | | | | | | | | | | | | | Taint check checks for possible security issues by tracking html escaping and more by using phan. This slows done the phan-job a bit and requires more ram Keep the DoubleEscaped issues out to make reviewer easier Adds suppression for false positives Adds taint-annotation to help taint-check Removes suppression for code phan now understand better by the tracking of keys in taint-check Fix some small issues by adding int cast or htmlspecialchars calls Bug: T216348 Bug: T268920 Change-Id: I849ac4f120fd15b483e8939d4db45c98dc351259
* build: Upgrade mediawiki-phan-config from 0.10.5 to 0.10.6James D. Forrester2020-12-171-2/+0
| | | | Change-Id: I73eaadb7a78a4ce84a5bbff2d48665da807fde9f
* Suppress taint-check issues in maintenance scripts/cli contextUmherirrender2020-12-071-0/+7
| | | | | | | | all places detected as SecurityCheck-XSS by mediawiki/phan-taint-check-plugin 3.1.0 Bug: T216348 Change-Id: Ib4c8295ad95c2c605fd2f0791e73322f747a00af
* maintenance: Move commandLine from .inc to .phpJames D. Forrester2020-09-281-1/+1
| | | | | | | … and fix the name to match the class. Bug: T184782 Change-Id: Id3d0d0a6b3f2da6316d18eb57804c5a2b697108b
* includes: Use expression assignment operator += or |= where possibleUmherirrender2020-07-311-3/+3
| | | | | | It is easier to read. Change-Id: Ia3965b80153d64f95b415c6c30f526efa252f554
* phan: Enable redundant_condition_detectionUmherirrender2020-07-011-0/+2
| | | | | | | | Remove duplicate casts Suppress false positives Bug: T248438 Change-Id: I2f89664a4bcd3b39b15e7cf850adda2f0c90ae6f
* Replace core uses and hard deprecate Revision::(de)compressRevisionTextDannyS7122020-06-041-1/+1
| | | | | Bug: T246284 Change-Id: I4649a0f30cf8638856f2e66d454b83a397e3e3d4
* Fix various MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineCommentReedy2020-05-211-1/+1
| | | | Change-Id: I50c7c93f1534e966224f98a835ca01f93eb9416d
* Fix PSR12.Properties.ConstantVisibility.NotFound in maintenance/Reedy2020-05-091-1/+1
| | | | Change-Id: Ib0f081f7b278fdd3f4083fc5020bcac97f6015b4
* Remove compat code for pre-MCR schema.daniel2020-03-241-49/+30
| | | | | | | | NOTE: This was manually tested to ensure it does not break updates, see T242764. Bug: T198557 Change-Id: I1d9f5465018bae10124514bc38169e23e0e613e6
* Coding style: Auto-fix MediaWiki.Usage.IsNull.IsNullJames D. Forrester2020-01-101-2/+2
| | | | Change-Id: I90cfe8366c0245c9c67e598d17800684897a4e27
* build: Upgrade phan to 0.9.0Daimona Eaytoy2019-12-071-1/+3
| | | | | | | | | | | | | | | Scalar casts are still allowed (for now), because there's a huge amount of false positives. Ditto for invalid array offsets. Thoughts about the rest: luckily, many false positives with array offsets have gone. Moreover, since *Internal issues are suppressed in the base config, we can remove inline suppressions. Unfortunately, there are a couple of new issues about array additions with only false positives, because apparently they don't take branches into account. Change-Id: I5a3913c6e762f77bfdae55051a395fae95d1f841
* Set method visibility on maintenance scriptsUmherirrender2019-11-161-5/+5
| | | | Change-Id: I44c82fbe65e1d002803ce065df6563f06dd39cd4
* Remove Revision::getRevisionText and gated pre-MCR schema accessPetr Pchelko2019-09-271-2/+19
| | | | | | | | | | | | | | | | | | | | | | | | - fixT22757.php appears to have been written for T22757 which has been resolved, I assume it can be removed. - compressOld.php - rev_text_id access is gated on MCRSchemaMigrationStage READ_OLD. IT's safe to use the old_text and old_flags directly as we select for them. Also the query ensures external blobs are not selected, so we can use decompressData instead of Revision::getRevisionText. Tested locally. - recompressTracked.php uses a temporary table for tracking the blobs. Table is populated by trackBlobs which explicitly queries for old_id, so using it directly in recompressTracked is ok. Tested locally. - checkStorage.php the affected code attempts to fix broken revisions from a dump, however, it looks like it doesn't work - the code expects revision IDs as input, however it receives an array of text table old_id values. Untested. Bug: T198343 Change-Id: I753019565c15d270c831c995c07c7f1aad887cb6
* externalstore: deprecate getLBInfo() dependency in ExternalStoreDBAaron Schulz2019-09-101-2/+2
| | | | | | | | | | Use the cluster and master server info array instead, when possible. Also add initializeTable() method based on the one in addWiki.php. This lets some internals be hidden from that script a bit more. Bug: T231162 Change-Id: I694f12cc800684bcc13351021d9abc9a01bddfe9
* Unsuppress another phan issue (part 7)Daimona Eaytoy2019-09-031-0/+2
| | | | | | | Bug: T231636 Depends-On: I2cd24e73726394e3200a570c45d5e86b6849bfa9 Depends-On: I4fa3e6aad872434ca397325ed7a83f94973661d0 Change-Id: Ie6233561de78457cae5e4e44e220feec2d1272d8
* maintenance: Avoid usage of deprecated Revision::* constantsDerick Alangi2019-07-211-1/+2
| | | | | | | Update deprecated Revision::* constants to use RevisionRecord::* equivalents. Change-Id: Icae1ebb088e4efadbc7c2806127a2073d337fa05
* Make ExternalStore wrap ExternalStoreFactory and create access classAaron Schulz2019-06-281-2/+5
| | | | | | | | | | | | | | | * Inject settings and global instances as dependencies to the ExternalStoreMedium instances. This includes the local wiki domain, so that wfWikiId() calls are not scattered around. * Create ExternalStoreAccess service for read/write logic. * Deprecate the ExternalStore wrapper methods. * Add some exception cases for bogus store URLs are used instead of just giving PHP warnings and failing later. * Make moveToExternal.php require the type/protocol to decide which ExternalStoreMedium to use instead of assuming "DB". * Convert logging calls to use LoggerInterface. Change-Id: I40c3b5534fc8a31116c4c5eb64ee6e4903a6197a
* Remove references to field rev_text_idBill Pirkle2019-04-221-10/+39
| | | | | | | | Field rev_text_id is being retired as part of MCR Schema Migration. Remove references to this field from maintenance scripts. Bug: T198341 Change-Id: I43ab93c44cbd0a2a2479baf848f50348e1e4762b
* Fix order of @var parameter in PHPFomafix2019-04-081-1/+1
| | | | | | | | | | | | Replace @var $foo type by @var type $foo Change-Id: Iec8b90ffea4028a1005daef422b7c4ec38c2715f
* Replace deprecated function wfEscapeShellArg with Shell::escape()Derick Alangi2019-04-071-1/+2
| | | | Change-Id: I4046d593d1450cfffc489ca2abadba1084a540e4
* Avoid using calls to freeResults() and allow object go out of scopeDerick Alangi2019-03-231-7/+0
| | | | | Bug: T26712 Change-Id: Ie97b6f3e3cfc4dc010900ebde5ff8e5afec10727