aboutsummaryrefslogtreecommitdiffstats
path: root/maintenance/edit.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: Use namespaced classesUmherirrender2024-10-211-0/+1
| | | | | | | This does not include use of MediaWiki\Maintenance\Maintenance, assuming the maintenance scripts going into the same namespace Change-Id: I488f95b537ce86eb5e463be7bce3653610dd13d9
* 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
* 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
* Namespace User under \MediaWiki\UserJames D. Forrester2023-09-191-0/+1
| | | | | Bug: T166010 Change-Id: I7257302b485588af31384d4f7fc8e30551f161f1
* 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
* 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
* Split a base class out of CommentStoreAlexander Vorwerk2023-01-011-0/+1
| | | | | | | | | | so that extensions (i.e. CheckUser) can implement their own comment store without having a lot of code duplication basically the comment store version of I3a6486532f2ef36 Bug: T233004 Change-Id: Ib40f99e00a514d41776ce521baf113e46d37e9cd
* Reorg: Move RawMessage to under language/Amir Sarabadani2022-12-161-0/+1
| | | | | | | | | | To follow Message. This is approved as part of RFC T166010. Also namespace it but doing it properly with PSR-4 would require namespacing every class under language/ and that will take some time. Bug: T321882 Change-Id: I195cf4c67bd51410556c2dd1e33cc9c1033d5d18
* Reorg: Move StubObject classes in includes to its own directoryAmir Sarabadani2022-10-251-0/+1
| | | | | Bug: T166010 Change-Id: Idcf0e9dc6e0841e4f132207bce0f96774dad898c
* maintenance: Add --parse-title option to edit.php to parse the title inputEd Sanders2021-12-031-1/+12
| | | | | | | Allows scripts to edit pages that can vary by language, e.g. "{{int:mainpage}}" or target pages using parser variables, e.g. "News_{{CURRENTYEAR}}". Change-Id: I94bd613d34743739c6529f22c1dcccc27acc4e8b
* Emit deprecation warnings reading from $wgUserDannyS7122021-09-151-3/+1
| | | | | | | | | | | | | | | | | | 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
* maintenance: Cleanup use of exit in Maintenance::execute implementationUmherirrender2021-08-301-3/+1
| | | | | | | | Returning void from execute() is success. Returning true is success, false is failure with exit(1) Using fatalError also using exit(1) Change-Id: I1d40430ad6226e4aab8f0810b03ee1213282d123
* Remove trailing dot/space from some exception messages and output stringsTimo Tijhof2021-08-041-1/+1
| | | | | | | | | | One exception message contained a trailing dot/space, which I removed as well, following I935835316c0. A very small number of exceptions and output() calls contained trailing space, which I removed for consistency. Change-Id: I16f48c1a051c452bbef699eb9b7476d83f8821d8
* Use a constant for 'Maintenance script' usernameGergő Tisza2021-05-031-1/+1
| | | | | | | | | | | The user 'Maintenance script' is often used to perform various automated tasks. Providing it everywhere as a string literal is error-prone, and errors can be somewhat disruptive (e.g. with User::newSystemUser with steal=true it can erase the credentials of a legitimate account). Provide a constant instead. Also replace existing uses for consistency. Change-Id: I685a5bfe56bbf1a47f35072f7f7c8be320ee27db
* Replace deprecated WikiPage::factory/newFromID in maintenance scriptsUmherirrender2020-11-121-1/+2
| | | | Change-Id: I5b2d4313f986484368da9b63c9a19892c2328dae
* maintenance scripts: Reduce direct references to $wgUserDannyS7122020-06-051-6/+7
| | | | | | | | Only use `wgUser` when setting or retrieving the global, not for the user object that it is set to Bug: T243708 Change-Id: Ie962192f1dbc066ba71b9abb48dc9d522d472c78
* 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: 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
* Re-namespace RevisionStore and RevisionRecord classesBrad Jorsch2018-10-091-1/+1
| | | | | | | | | | | | | | | | | | | During development a lot of classes were placed in MediaWiki\Storage\. The precedent set would mean that every class relating to something stored in a database table, plus all related value classes and such, would go into that namespace. Let's put them into MediaWiki\Revision\ instead. Then future classes related to the 'page' table can go into MediaWiki\Page\, future classes related to the 'user' table can go into MediaWiki\User\, and so on. Note I didn't move DerivedPageDataUpdater, PageUpdateException, PageUpdater, or RevisionSlotsUpdate in this patch. If these are kept long-term, they probably belong in MediaWiki\Page\ or MediaWiki\Edit\ instead. Bug: T204158 Change-Id: I16bea8927566a3c73c07e4f4afb3537e05aa04a5
* Add constant for the name of the 'main' slot for MCRGergő Tisza2018-09-241-2/+4
| | | | | Bug: T202142 Change-Id: I97a74e5a029b014f3c2195188936d5c8233c1b7f
* Allow edit.php to modify different slots.daniel2018-09-141-6/+29
| | | | | | | | | | | | This adds --slot and --remove options to the edit.php maintenance script, to allow content of different slots to be edited, alots to be added, and slots to be removed. This is needed to help with testing MCR functionality, since EditPage does not yet support MCR. Bug: T189220 Change-Id: I985fb5afcd5d469fc31b32d2a927f425c40fc290
* 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-4/+4
| | | | | | | | 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
* Use english messages for background use of Status::getWikiTextumherirrender2016-04-121-1/+1
| | | | | | | | Status::getWikiText is used for internal logging, api error messages and maintenance scripts. All this places are usually in english, so pass an english language to getWikiText. Change-Id: I3010fca8eb5740a3a851c55a8b12e171714c78f7
* 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
* Use addDescription() instead of accessing mDescription directlyMax Semenik2016-01-301-1/+1
| | | | Change-Id: I0e2aa83024b8abf5298cfea4b21bf45722ad3103
* User: Mostly remove password handlingBrad Jorsch2015-10-131-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Remove RequestContext from edit.php and fixDoubleRedirects.phpwithoutaname2014-07-231-3/+0
| | | | Change-Id: I9388e6b3fec3c8ea92099aeaf010dd067f62a20f
* Add "nocreate" and "createonly" options to edit.phpKunal Mehta2013-12-101-0/+8
| | | | Change-Id: I2101360a934b8b9a92094c44429e3e2314c7fba3
* Remove ugly $wgTitle usage from edit.php maintenance scriptChad Horohoe2013-11-161-6/+6
| | | | Change-Id: Iae44d0945a10832a7f6585d3620c8e994783457b
* edit.php maintenance script not setting up context, just globalsAlex Monk2013-06-061-0/+3
| | | | | | | Was breaking one of Echo's hooks Bug: 49271 Change-Id: Ie1b5f5bc4a672bcfff3c99b9a76b37c502c09985
* 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
* style: normalize end of filesAntoine Musso2013-02-031-1/+0
| | | | | | | | | | | | By PSR2 PHP Standard, the files should ends with exactly one newline. Some of our files have 2 or more and some other were missing a newline. Fix almost all occurences of CodeSniffer sniff: PSR2.Files.EndFileNewline.TooMany I have not fixed the selenium files, I believe we will drop them. Change-Id: I89fca8c1786fee94855b7b77bb0f364001ee84b6
* merged masterdaniel2012-08-291-1/+1
| | | | Change-Id: Ib2b879c4daa17401eeeb50767c0e5a54254855c3
* Revert "merged master"Daniel Kinzler2012-08-291-1/+1
| | | This reverts commit 67bfdc7a68940d901e585eadd984a2074bf0216a
* merged masterdaniel2012-08-291-1/+1
| | | | Change-Id: Ib2b879c4daa17401eeeb50767c0e5a54254855c3
* Replace usage of doEdit() with doEditContent()daniel2012-08-281-1/+2
| | | | Change-Id: I2c423744bd91044c37bbec53b35729bd1c09901b
* Improve documentation of maintenance scripts.Alexandre Emsenhuber2012-07-241-0/+1
| | | | Change-Id: If0af9922ede902c2c6f18b627d5810f3e888c944
* Improve documentation of maintenance scripts.Alexandre Emsenhuber2012-07-101-1/+6
| | | | Change-Id: I0e2869970c46f4fd14b792f2978cc1ba9d8550be
* Use WikiPage instead of Article to call doEdit()Alexandre Emsenhuber2011-12-291-2/+2
| | | | Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/107586
* * Added possibility to set short options aliases to long long options, added ↵Alexandre Emsenhuber2011-04-061-11/+11
| | | | | | | | | -h alias to --help and -q to --quiet for all scripts * Converted edit.php, people using short option version (with only one dash) won't have to change anything, but the ones using long options that were only one character (--u, --s, --m, --b and --a) will either need to change to short options or use full name Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/85557
* Revert r66977 (removing $wgTitle from edit.php). This doesn't break core, ↵Chad Horohoe2011-02-061-4/+4
| | | | | | | but could quite possibly break extensions that expect $wgTitle to be set during editing. I hate $wgTitle :( Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/81611
* Fix concern raised by Brion in r74108 (but has really existed since the ↵Chad Horohoe2011-01-131-1/+1
| | | | | | | | | | | maintenance rewrite). Right now, including a maintenance script causes it to execute. This is bad when you want to reuse the particular class but not have it start executing all by itself. Until now, we relied on setting MW_NO_SETUP which was a) hacky, b) irreversable, and c) likely to be forgotten if you didn't use one of the wrappers like runChild(). Instead, move the freaky magic to doMaintenance and have *it* check if it's in a specific call stack that indicates this is being run from the file scope and should be executed. Rename DO_MAINTENANCE to RUN_MAINTENANCE_IF_MAIN so it's nice and clear what magic happens behind the require_once(). Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/80205
* Changed $wgArticle to local variable, not neededAlexandre Emsenhuber2010-12-141-3/+3
| | | | Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/78372
* Whitespace fixup under tha maint directory.Mark A. Hershberger2010-12-041-5/+5
| | | | Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/77711
* edit.php: got rid of $wgTitleMax Semenik2010-05-271-4/+4
| | | | Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/66977
* Stylize maintenance folder..Sam Reed2010-05-221-3/+3
| | | | Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/66751
* Redo addArgs() as addArg() so we can actually do useful things with ↵Chad Horohoe2009-08-181-1/+1
| | | | | | | arguments like descriptions and proper requirement checks, similar to addOption() Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/55287