aboutsummaryrefslogtreecommitdiffstats
path: root/maintenance/importDump.php
Commit message (Collapse)AuthorAgeFilesLines
* maintenance: Use type declaration on undocumented private functionsUmherirrender2025-03-311-6/+6
| | | | Change-Id: I2c1bc3b4e0ee782076ddaeae133672b730d345d9
* maintenance: Replace call_user_func with dynamic function callUmherirrender2025-01-311-3/+3
| | | | | | | | Use modern php syntax to call a callable. Reduce the stack trace to improve performance and better IDE and static analyzer support Change-Id: I1af7da4a8b3433f31dfef78adda2511a88adb73f
* Remove trivial 1-line PHPDocs that just repeat the codethiemowmde2025-01-161-6/+0
| | | | | | | | | | | | | I assume these are all either auto-generated by an IDE or the language-level type declarations have been added later. In any case the comments don't add any new information to what the code already says. This is just extra clutter that makes the code harder to read, I would argue. There are many, many more comments like this. In this patch I intentionally focus on the most trivial 1-line comments. Change-Id: Ia294bf4ce0d8a77036842fe25884bc175c2b0e7d
* add `use MediaWiki\Maintenance\Maintenance` to some maintenance classesNovem Linguae2024-12-041-0/+1
| | | | | | | | | | | | | F–P. Still need to do P–Z. there's a couple spots where I added `use MediaWiki\Maintenance\LoggedUpdateMaintenance;` or similar instead. some of the existing "use" blocks were in weird spots (e.g. above the copyright docblock, or too far down). i didn't move those because they are out of scope for this patch. Change-Id: I5b6a8f3eae5be85d67bccfcce31c0c2027850f45
* 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
* Maintenance: Print errors from StatusValue objects in a consistent wayBartosz Dziewoński2024-06-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Allow Maintenance::error() and Maintenance::fatalError() to take StatusValue objects. They now print each error message from the status on a separate line, in English, ignoring on-wiki message overrides, as wikitext but after parser function expansion. Thoughts on the previously commonly used methods: - $status->getMessage( false, false, 'en' )->text() Almost the same as the new output, but it allows on-wiki message overrides, and if there is more than one error, it prefixes each line with a '*' (like a wikitext list). - $status->getMessage( false, false, 'en' )->plain() - $status->getWikiText( false, false, 'en' ) As above, but these forms do not expand parser functions such as {{GENDER:}}. - print_r( $status->getErrorsArray(), true ) - print_r( $status->getErrors(), true ) These forms output the message keys instead of the message text, which is not very human-readable. The error messages are now always printed using error() rather than output(), which means they go to STDERR rather than STDOUT and they're printed even with the --quiet flag. Change-Id: I5b8e7c7ed2a896a1029f58857a478d3f1b4b0589
* Update name & email for bvibberBrooke Vibber2024-02-081-1/+1
| | | | | | | | | | | | | Updating name & email addresses for Brooke Vibber. Re-ran updateCredits.php as well so there are some new entries in there as well. There are a couple of files in resources/libs that will have to be changed upstream to keep tests happy, I will do patches later. :D Change-Id: I2f2e75d3fa42e8cf6de19a8fbb615bac28efcd54
* maintenance: Replace unnecessary uses of LBFactory and LoadBalancerBartosz Dziewoński2024-01-231-1/+1
| | | | | | | | | | * Change `$services->getDBLoadBalancerFactory()->waitForReplication()` to `$this->waitForReplication()` * Change various complicated expressions to `$this->getReplicaDB()` and `$this->getPrimaryDB()` * Remove unused variables Change-Id: Ia857be54938a32bb6288dcdf695a35cd38761c3c
* WikiImporter: Pass Authority for permissions instead of global contextBartosz Dziewoński2023-12-111-1/+4
| | | | | | | | | | | | | | | 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
* importDump: Unconditionally call $importer->setUsernamePrefix()Reedy2023-09-201-7/+7
| | | | | | | | | | In the current form, it results in `assignKnownUsers` being set to false. Which is contradictory to the docs for `--no-local-users`. Also document the default `username-prefix` and mention trailing `>` being added. Bug: T346898 Change-Id: I00d3ecbfb468a38b03eb6c98f224d1868006a2ee
* 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
* Replace more usages of deprecated MWExceptionDaimona Eaytoy2023-06-081-1/+0
| | | | | Bug: T328220 Change-Id: Ib619ead0f397188d828e6e5dfc80ed1fa7175c7d
* rdbms: remove IMaintainableDatabase::deadlockLoop()Aaron Schulz2022-12-201-2/+3
| | | | | | | | | This method does not actually work since deadlocks cause transaction rollback on the service side, which does not match the way it uses begin() and commit(). Deadlocks would just become transaction state errors. Change-Id: I64ce8a406ac05b997d947cd5f30b26f68bbb8e18
* Replace deprecated wfReadOnly/wfReadOnlyReasonUmherirrender2022-06-201-1/+1
| | | | | Bug: T283978 Change-Id: I49f8c7bf1162dc834a1708e2e581f6fb264bbd0a
* snapshot: Add @var documentation for class propertiesUmherirrender2022-03-091-2/+9
| | | | Change-Id: I80ba53bdeb730a115ab3eec4849a38a13a896cdb
* importDump.php: handle fopen errorGergő Tisza2021-10-171-0/+3
| | | | | Bug: T293569 Change-Id: I13c05d754513f01f6a3f293d299cb9d55cc19265
* Remove unreachable code after exception/die/exitUmherirrender2021-09-031-1/+0
| | | | Change-Id: Ia81903fb2a8157625fbe63115097eccc1161b5db
* WikiImporter: inject servicesZabeMath2021-05-241-1/+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-1/+1
| | | | | | 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
* Fix various MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineCommentReedy2020-05-211-2/+4
| | | | Change-Id: I50c7c93f1534e966224f98a835ca01f93eb9416d
* Fix parameter documentation for dump methods for handling revisionsDannyS7122020-05-051-21/+13
| | | | | | | | The only caller passes a WikiRevision, which does not extend the Revision class; the parameter is a WikiRevision, not a Revision Bug: T246284 Change-Id: Iaf25b692e6093eab6e12439864bae97c96a3b9db
* Replace wfWaitForSlaves() with LBFactory::waitForReplication()Reedy2020-05-021-1/+1
| | | | Change-Id: I337147d61e2ec686a8672d0340dff4b6783f78cd
* Coding style: Auto-fix MediaWiki.Usage.IsNull.IsNullJames D. Forrester2020-01-101-1/+1
| | | | Change-Id: I90cfe8366c0245c9c67e598d17800684897a4e27
* Mark some more BackupReader functions publicReedy2019-12-241-3/+3
| | | | | | | Partial revert I44c82fbe65e1d002803ce065df6563f06dd39cd4 Bug: T241426 Change-Id: Ic35f6765f308d2a6676c788c7066a7124cec3108
* Mark BackupReader::reportPage() publicReedy2019-11-251-1/+1
| | | | | | | Partial revert I44c82fbe65e1d002803ce065df6563f06dd39cd4 Bug: T238984 Change-Id: If7f7899c626c96b7024f84e73886bd80636a3a2d
* Set method visibility on maintenance scriptsUmherirrender2019-11-161-11/+11
| | | | Change-Id: I44c82fbe65e1d002803ce065df6563f06dd39cd4
* Set public for override of Maintenance functionsUmherirrender2019-10-091-1/+1
| | | | | | | | | | | | The following function are set to public in the parent class and cannot have another visibility in subclasses Maintenance::__construct Maintenance::execute Maintenance::getDbType Maintenance::validateParamsAndArgs Maintenance::setDB Change-Id: I0cd6514642d479aca20f1221bf673b0713c21631
* Do not output wikitext in maintenance scriptUmherirrender2019-09-201-1/+1
| | | | | | | | Also remove print_r with a string Always use english for maintenance scripts Bug: T229843 Change-Id: I539a1ac1f6a201dd8ee9ce89599cc34bebfba79f
* maintenance: Explicitly declare all used propertiesDaimona Eaytoy2019-09-091-0/+10
| | | | | | | All uses were checked with codesearch, and the visibility was chosen as strict as possible. Change-Id: I56666299cc04ccc418e05949422876583982eb3c
* Unsuppress another phan issue (part 7)Daimona Eaytoy2019-09-031-0/+1
| | | | | | | Bug: T231636 Depends-On: I2cd24e73726394e3200a570c45d5e86b6849bfa9 Depends-On: I4fa3e6aad872434ca397325ed7a83f94973661d0 Change-Id: Ie6233561de78457cae5e4e44e220feec2d1272d8
* Unsuppress other phan issues (part 4)Daimona Eaytoy2019-08-311-0/+1
| | | | | | Bug: T231636 Depends-On: I58e67c2b38389df874438deada4239510d21654f Change-Id: I6e5fba7bd273219b1206559420b5bdb78734aa84
* maintenance: Deprecate Maintenance::hasArg/getArg with no paramThiemo Kreuz2019-03-291-2/+2
| | | | | | | | | | | | | | | | | | | 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
* Merge "Fix option name in maintenance/importDump.php"jenkins-bot2018-10-041-1/+1
|\
| * Fix option name in maintenance/importDump.phpBrad Jorsch2018-10-031-1/+1
| | | | | | | | | | Bug: T200138 Change-Id: Icc5d9878bc3ebdf03efec9161b220ad0bf55dc9a
* | Mass conversion of $wgContLang to serviceAryeh Gregor2018-08-111-3/+5
|/ | | | | | | Brought to you by vim macros. Bug: T200246 Change-Id: I79e919f4553e3bd3eb714073fed7a43051b4fb2a
* 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
* [WikiImporter::notice] use wfDebug instead of echo in notice()Yifei He2017-12-221-0/+3
| | | | | | | | Make the default notice implementation of notice() function to send the notice to wfDebug() instead of simply echo to prevent XSS Bug: T177997 Change-Id: I9ffb597e0642afc1603cdd15e2d09c6f2584b448
* Merge "Add missing @throws in Importers"jenkins-bot2017-12-061-0/+1
|\
| * Add missing @throws in ImportersWMDE-Fisch2017-12-061-0/+1
| | | | | | | | Change-Id: I02760e59d73f4278cca87483ab4578b6e76b2324
* | Avoid DB rows with usable names but ID = 0 by introducing "interwiki" usernamesBrad Jorsch2017-11-301-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Importing revisions in MediaWiki has long been weird: if the username on the imported revision exists locally it's automatically attributed to the local user, while if the name does not exist locally we wind up with revision table rows with rev_user = 0 and rev_user_text being a valid name that someone might later create. "Global" blocks too create rows with ipb_by = 0 an ipb_by_text being a valid name. The upcoming actor table change, as things currently stand, would regularize that a bit by automatically attributing those imported revisions to the newly-created user. But that's not necessarily what we actually want to happen. And it would certainly confuse CentralAuth's attempt to detect its own global blocks. Thus, this patch introduces "interwiki" usernames that aren't valid for local use, of the format "iw>Example".[1] Linker will interpret these names and generate an appropriate interwiki link in history pages and the like, as if from wikitext like `[[iw:User:Example]]`. Imports for non-existant local users (and optionally for existing local users too) will credit the edit to such an interwiki name. There is also a new hook, 'ImportHandleUnknownUser', to allow extension such as CentralAuth to create local users as their edits are imported. Block will no longer accept usable-but-nonexistent names for 'byText' or ->setBlocker(). CentralAuth's global blocks will be submitted with an interwiki username (see Ieae5d24f9). Wikis that have imported edits or CentralAuth global blocks should run the new maintenance/cleanupUsersWithNoId.php maintenance script. This isn't done by update.php because (1) it needs an interwiki prefix to use and (2) the updater can't know whether to pass the `--assign` flag. [1]: '>' was used instead of the more usual ':' because WMF wikis have many existing usernames containing colons. Bug: T9240 Bug: T20209 Bug: T111605 Change-Id: I5401941c06102e8faa813910519d55482dff36cb Depends-On: Ieae5d24f9098c1977447c50a8d4e2cab58a24d9f
* | Maintenance: add fatalError() methodBryan Davis2017-11-211-3/+3
|/ | | | | | | | 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
* importDump.php: Declare uploadCount propertyMark A. Hershberger2017-08-261-0/+1
| | | | | Bug: T174255 Change-Id: Ic5014821a8f10ab29b729104cd7d4e434085e2f2
* Add skipping to nth page option/ability for dump importing processMehmet Mert Yıldıran2017-06-091-0/+6
| | | | | | | | | | | Usage: php importDump.php --skip-to 271500 /path_to/dumpfile.xml.gz When importing a database dump and the import process crashes (for random reasons) after a certain number of pages, the "--skip-to" parameter allows restarting the import process at a certain page instead of starting the import from scratch. Change-Id: Ib36063b69d6846fc197800bba44287493b0632c0
* Disable statistics update on import with maintenance/importDump.phpSubin Siby2017-01-031-1/+5
| | | | | | | Disable updating statistics in importDump.php to quickly finish imports from command line. Bug: T144600 Change-Id: Ib827c068fb20cc03aab47e3106d489f18be1dac6
* Convert all array() syntax to []Kunal Mehta2016-02-171-6/+6
| | | | | | | | | | 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
* Fix a bunch of call-time pass-by-reference errorsMax Semenik2016-02-101-4/+4
| | | | Change-Id: I3bd8e7c4d2dca465957a353cb7dc2a906699ff6a
* Use addDescription() instead of accessing mDescription directlyMax Semenik2016-01-301-2/+4
| | | | Change-Id: I0e2aa83024b8abf5298cfea4b21bf45722ad3103
* Update wfGetDB calls in Maintenance scripts to use getDB()Reedy2016-01-021-1/+1
| | | | Change-Id: I9ad6745d84506b736dae94747256caac89715899