aboutsummaryrefslogtreecommitdiffstats
path: root/includes/api/ApiRollback.php
Commit message (Collapse)AuthorAgeFilesLines
* Namespace all remaining files in includes/changetagsJames D. Forrester2025-03-251-1/+1
| | | | | Bug: T353458 Change-Id: I3cf44dfe5425f2efb8409c83571c427447b053af
* Remove 2-line PHPDocs that just repeat the types from the codethiemowmde2025-01-171-5/+0
| | | | | | | | | | | | | | | | Same as Ia294bf4 did for 1-line comments. This patch removes slightly more complex 2-line PHPDoc comments that don't add any new information to the code, but literally repeat what the code already says. They say "don't document the code, code the documentation", and we are doing this more and more. We just tend to forget to remove the obsolete comments. Note I'm also removing a line of text in a few cases when it's very short and literally says the same as the method name. Again, such comments add zero new information. Change-Id: I01535404bab458c6c47e48e5456403b7a64198ed
* api: Use type-declaration for string arg in ApiBase::__constructUmherirrender2024-10-171-1/+1
| | | | | | | Also for all sub-classes Remove simple doc-blocks without further information Change-Id: I981934efe32d44f52e5ab865a9b887be5bd0f41e
* Add namespace to includes/api classesJames D. Forrester2024-09-251-0/+7
| | | | | Bug: T353458 Change-Id: I3ea6b08c5018ba03ba45c5766e1f46e12f6b8597
* Merge "Add 'temp' to allowed user types in various APIs"jenkins-bot2023-11-301-1/+1
|\
| * Add 'temp' to allowed user types in various APIsThalia2023-11-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Why: * Before this task, when an API parameter specifies allowed user types, temporary users and permanent users are in the same category: 'name'. * However, it is useful to separate them out, and sometimes allow a permanent user but not a temporary user (e.g. ApiResetPassword, since temporary users don't have passwords). * We therefore re-defined the 'name' type only to refer to permanent (named) users, and add a new 'temp' type. * This fixes params that currently intend to allow temp users, and that use 'name' to do so, by adding 'temp'. What: * Based on a search for `UserDef::PARAM_ALLOWED_USER_TYPES`, add the 'temp' type where necessary. * The following were not updated, because they shouldn't apply to temporary users: - owners for includes/api/ApiQueryWatchlist.php, includes/api/ApiQueryWatchlistRaw.php - users for includes/api/ApiResetPassword.php, includes/api/ApiUserrights.php, includes/api/ApiValidatePassword.php Bug: T350701 Change-Id: If5ccf1d469327791acff74d013343307e411cca9
* | Move user options related classes into its own namespaceMartin Urbanec2023-11-291-1/+1
|/ | | | | | | | | | | | | There are a couple of user options related classes already, and the T321527 work on dynamic defaults is going to add even more. Let's move them into a separate namespace to make core a bit more organized. Old name is kept as an alias for compatibility purposes. Bug: T321527 Bug: T352284 Change-Id: I9822eb1553870b876d0b8a927e4e86c27d83bd52
* Namespace remaining files under includes/deferredJames D. Forrester2023-11-221-0/+1
| | | | | Bug: T166010 Change-Id: Ibd40734b96fd2900e3ce12239d09becfb4150059
* Get correct main page in API call examplesAmmar Abdulhamid2023-09-201-2/+5
| | | | | | | | | | | | | | Remove hardcoded "Main Page" and use whatever the main page of the wiki is. Many wikis have their main page in a different title than the default or even in a different namespace entirely. With the hardcoded title this produces broken/redlink for the doc examples and makes it overall less useful. Most typical examples; Mediawiki.org itself, Wikidata.org, etc. Bug: T235207 Change-Id: Ia9eee76544cad153166dd5a2eb8e8c1bf3a38b74
* Use real type hints for services etc. in api/ except ApiQuery*.phpBartosz Dziewoński2023-08-291-2/+1
| | | | | | | | | | | | | | | Mostly used find-and-replace: Find: /\*[\*\s]+@var (I?[A-Z](\w+)(?:Interface)?)[\s\*]+/\s*(private|protected|public) (\$[a-z]\w+;\n)((?=\s*/\*[\*\s]+@var (I?[A-Z](\w+)(?:Interface)?))\n|) Replace with: \3 \1 \4 Followed by some manual review to make sure I'm not changing too much, omitting some changes that looked too complicated and anything that caused test failures, and some whitespace fixes. Change-Id: I6ec7587607df4f1a4f448a096c3e44c4e5270b70
* Api: Fix some very old copyright statements for RoanJames D. Forrester2023-03-161-1/+1
| | | | Change-Id: I820a2d388922653a6a5b9048b0feaafbb4297d91
* 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
* api: Replace numerous deprecated constantsReedy2022-06-061-5/+6
| | | | Change-Id: I34ffcb70efbfa257da8dab6e0790aa0d697caf5b
* Use MainConfigNames instead of string literals, #2Aryeh Gregor2022-04-131-3/+5
| | | | | | | This covers all occurrences of /onfig->.*get( '/ in includes/. Undoubtedly there are still plenty more to go. Change-Id: I33196c4153437778496f40436bcde399638ac361
* build: Updating dependencieslibraryupgrader2021-07-221-1/+1
| | | | | | | | | | | | | | composer: * mediawiki/mediawiki-codesniffer: 36.0.0 → 37.0.0 The following sniffs now pass and were enabled: * Generic.ControlStructures.InlineControlStructure * MediaWiki.PHPUnit.AssertCount.NotUsed npm: * svgo: 2.3.0 → 2.3.1 * https://npmjs.com/advisories/1754 (CVE-2021-33587) Change-Id: I2a9bbee2fecbf7259876d335f565ece4b3622426
* api: Inject services into ApiWatchlistTraitUmherirrender2021-07-061-2/+9
| | | | | Bug: T259960 Change-Id: I73596f8c924ec4a02a7042608d19a35f82bb752a
* Factor out rollback logic from WikiPagePetr Pchelko2021-04-141-18/+22
| | | | Change-Id: I95da91875fcf2f53143c315560e35ccd5ffbf4b3
* Merge "Convert ChangeTags public interface to Authority."jenkins-bot2021-03-011-1/+1
|\
| * Convert ChangeTags public interface to Authority.Petr Pchelko2021-02-241-1/+1
| | | | | | | | | | Bug: T275507 Change-Id: I3b7f99391ab299df2b046a2878010cf6afe7fed7
* | Convert WikiPage to authority.Petr Pchelko2021-02-271-1/+1
|/ | | | Change-Id: Iba5e36e5a13c304be51b82a952b2a3044e122c8c
* 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
* Remove requirement for ApiWatchlistTrait to be in ApiBase.Ammar Abdulhamid2020-09-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | This trait is not needed in ApiBase and its presence here is proving to be problematic. See I795db12. In this patch, the trait usage (more precisely the 'use statement') has been removed from ApiBase and accordingly the signatures of ApiWatchlistTrait::getWatchlistValue() and ::setWatch() have been altered to now require User object. With these changes, the abstract getUser() method in the trait is no longer needed, so it has been removed also. All core usages of the affected functions are fixed in this patch. The trait is used in only one extension according to codesearch tool, the extension will be fixed in Ic22e163. Bug: T262175 Bug: T248512 Follow-up: Ia18627b9824dca81f44f0571e8420d89b7626cf6 Change-Id: Idabcea71edfca9e7ed42000a258c99ff407873d4
* Add watchlist expiry support to applicable APIsMusikAnimal2020-07-131-11/+19
| | | | | | | | | | | This introduces an ApiWatchlistTrait that refactors out common code across APIs that allow you to watch pages. Some methods have been migrated from ApiBase and changed completely, but codesearch suggests they aren't being used outside the API modules in this patch. Bug: T248512 Bug: T248514 Change-Id: Ia18627b9824dca81f44f0571e8420d89b7626cf6
* WikiPage::commitRollback - also return a RevisionRecordDannyS7122020-06-201-2/+2
| | | | | | | | Still need to return a Revision until 1.36, but the Revision returned shouldn't be used in core Bug: T251965 Change-Id: Ie227c9449da2da2fdf99d595c08e80a15a78f5d5
* ApiRollback: Reduce use of Revision objectsDannyS7122020-06-101-3/+6
| | | | | | | | | | | WikiPage::doRollback modifies $details to include Revision objects, and while the method has been marked as internal and will have breaking changes made in 1.36 to remove the use of Revision objects entirely, for now they should not be used, but rather their RevisionRecord objects retrieved instead. Bug: T251853 Change-Id: Ie907af06774a3980d506c9f089b0122f36cda7bf
* ApiRollback: Properly deal with UserIdentityDaimona Eaytoy2020-02-131-4/+5
| | | | | | | | | | | | Follow-up I1462edc170127, which enabled the UserDef::PARAM_RETURN_OBJECT flag for the 'user' parameter, so that it returns UserIdentityValue objects instead of string values, but the internal use of that value was still expecting a string Bug: T245159 Change-Id: I2f8d8c406ab81b6d5dc19a1fff389646af61001e
* API: Use ParamValidator libraryBrad Jorsch2020-02-041-7/+5
| | | | | | | | | | | | | | | | | This brings significant modularization to the Action API's parameter validation, and allows the Action API and MW REST API to share validation code. Note there are several changes in this patch that may affect other code; see the entries in RELEASE-NOTES-1.35 for details. Bug: T142080 Bug: T232672 Bug: T21195 Bug: T34675 Bug: T154774 Change-Id: I1462edc1701278760fa695308007006868b249fc Depends-On: I10011be060fe6d27c7527312ad41218786b3f40d
* Use (int) rather than intval()Reedy2019-02-251-4/+4
| | | | | Bug: T216969 Change-Id: I4c06716c83b69d128f26fa7f68736808aa2d3d64
* Add TransactionProfiler::redefineExpectations and migrate appropriate callersAaron Schulz2018-12-101-2/+2
| | | | | | | Some of the callers of setExpectations() actually need to reset the old expectations to avoid erroneous warnings. Change-Id: I63c01c0f6cd748bdc849f1a5264e17bd377b9d11
* build: Updating mediawiki/mediawiki-codesniffer to 23.0.0Umherirrender2018-12-011-3/+4
| | | | | | Avoid use of __METHOD__ magic constant in closure Change-Id: I28d519530ca2fcde026a6cbb419848098d4617ca
* Avoid post-send DBPerformance log warnings for page rollbackAaron Schulz2018-11-221-0/+3
| | | | Change-Id: I3d4eafc7d9d04647955822d5100d8cf253d80c8a
* Merge "Silence transaction profiler master queries notices for rollback"jenkins-bot2018-10-251-0/+5
|\
| * Silence transaction profiler master queries notices for rollbackAaron Schulz2018-10-241-0/+5
| | | | | | | | Change-Id: I53f0149cbf69ee2e57fe556668dd6cbfadd79823
* | Use PHP 7 '??' operator instead of if-then-elseFomafix2018-10-211-4/+1
|/ | | | Change-Id: If9d4be5d88c8927f63cbb84dfc8181baf62ea3eb
* Remove "Created on" from file header commentsUmherirrender2018-01-261-4/+0
| | | | | | | | | It is the job of git and svn to provide this information/metadata. The form was different, some with short, some with long month name some with leading zero at the day, some without. The year is also present in the Copyright clause Change-Id: If006907b82b9e45f13cfa2e45d41107a95570e1a
* API: Account for PHP 7.2 changeBrad Jorsch2017-12-041-1/+1
| | | | | | | | | | PHP 7.2 broke existing functionality in making count( null ) raise a warning. So add tests for null all over the place, or change tests where we know the value is null or an array (but not false, empty-string, or 0) to just cast to boolean. Bug: T182004 Change-Id: Idfe23a07daa9f60eee72f2daf04304be87057a29
* Make API documentation links language awareBaha2017-04-051-1/+1
| | | | | | | | | | | | | | Links generated by the API are now aware of the user's preferred language and will show documents in that language if available. To test, log in to mediawiki.org and set your language preference to 'es', then on an MediaWiki installation with this patch view the generated expanded API help at `api.php?action=help&recursivesubmodules=1&modules=main`. Each link to documentation on mediawiki.org should take you to its translated /es subpage, if one exists. Bug: T104518 Change-Id: I339a1f3ae1bce9d759cf251899d57c32b1def91e
* API: More i18n cleanupBrad Jorsch2016-12-081-11/+0
| | | | | | | | | | | * Use errorformat for action=login Failed responses in non-BC mode. * We removed 'messageHtml' from action=rollback's response on error, but left it for success. Remove it there too, it's even less useful. * We changed action=watch's reporting of errors, but left the mostly-pointless reporting of "success" UI messages. These should be handled on the client side. Change-Id: Ia6c402a4254fbacf4c2c3f125ce8bf0bcc71e509
* API: i18n for warnings and errorsBrad Jorsch2016-12-061-21/+5
| | | | | | | | | | | | | | | | | | | | | | | | | API warnings and error messages are currently hard-coded English strings. This patch changes that. With a few exceptions, this patch should be compatible with non-updated extensions: * The change to ApiBase::$messageMap will blow up anything trying to mess with it. * The changes to the 'ApiCheckCanExecute' hook will cause a wrong (probably unparsed) error message to be emitted for extensions not already using an ApiMessage. Unless they're currently broken like Wikibase. Bug: T37074 Bug: T47843 Depends-On: Ia2b66b57cd4eaddc30b3ffdd7b97d6ca3e02d898 Depends-On: I2e1bb975bb0045476c03ebe6cdec00259bae22ec Depends-On: I53987bf87c48f6c00deec17a8e957d24fcc3eaa6 Depends-On: Ibf93a459eb62d30f7c70d20e91ec9faeb80d10ed Depends-On: I3cf889811f44a15935e454dd42f081164d4a098c Depends-On: Ieae527de86735ddcba34724730e8730fb277b99b Depends-On: I535344c29d51521147c2a26c341dae38cec3e931 Change-Id: Iae0e2ce3bd42dd4776a9779664086119ac188412
* RollbackAction: Implement AJAX interface and require POSTTimo Tijhof2016-05-231-19/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Similar to WatchAction (converted in commit 77cdf1919). * Make FormAction::getFormFields not abstract. In most cases this will just be an empty array. * Convert RollbackAction from FormlessAction to FormAction and implement the required error handling scenarios (mostly moved out of from the old method, or duplicated from the WikiPage method where necessary). * In most cases the in-between form is never used since a JavaScript handler takes over the link and uses the API over AJAX instead. In the no-js fallback (as well as for any existing tokenless rollback links) copy the GET parameters into the form for re-submission as POST (plus token, added by HTMLForm). * Remove the distinction between WebUI and API tokens. This stronger token salt made it unnecessarily complex and was only there because it used GET until now. This streamlining of tokens matches what we already do for 'watch', 'edit', 'patrol' and other actions. * Fix form submission bugs when 'from' query parameter is missing. - Ensure the required 'from' query parameter is present before showing a form. No need for the user to submit a form we know will fail. - Plain GET request to action=rollback (with no parameters) is now a 400 Bad Request instead of a form that would fail when submitted. - Submitting the form without 'form' field now correctly says why it failed. Previously it emitted a session error, which was a lie. Bug: T88044 Change-Id: Ia457802fec2e90573c8e7d552bc1f3cee258f10b
* Convert all array() syntax to []Kunal Mehta2016-02-171-25/+25
| | | | | | | | | | 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
* Make change tagging of edits in RecentChange::notifyNew/Editcenarium2016-02-101-5/+2
| | | | | | | | | | | | | | | Change tags to apply to an edit can now be passed directly to the WikiPage::doEditContent function. They are then passed to the RecentChange::notifyNew/Edit functions where tagging is made after the recent change is saved. This ensures that other callers of doEditContent will not run into the same issue as T100248. ApiRollback is fixed in this way. In addition, we'll have to pass tags in this way for core tagging of edits (I2e48bd458fc8d7c289f04dc276f9287516e0b987), and this makes it possible to merge the arrays of tags and call ChangeTags::addTags only once. Change-Id: I829960c7a33b70464065839d7504d7529dfd0b72
* Add logic for "tags" in ApiBasevictorbarbu2016-02-041-1/+1
| | | | | Bug: T97720 Change-Id: I275c516b4744e243333ec0818d2be1e5508e54a3
* API: Flag "user" parameters in various modules as type 'user'Brad Jorsch2016-01-091-1/+1
| | | | | | | | | | The API 'user' type accepts both user names and IP addresses, and applies normalization but not canonicalization. We should be using this on basically every user parameter to ensure that e.g. IPv6 usernames get uppercased. Bug: T122803 Change-Id: Ic67fb54061ac311e54f325b2a1a4658f43b8fef4
* Add tag parameter to API action=rollbackmhutti12015-12-161-0/+18
| | | | | | | Added code to allow tag change in ApiRollback.php Bug: T111948 Change-Id: Ic8dcefe569f169041c9e0078a49af4ee87d2bbd6
* Added wfTransactionalTimeLimit() method and applied itAaron Schulz2015-08-121-0/+2
| | | | | | | | | | | | * Potentially long running POST requests often use multiple transactions, talk to multiple services, or defer updates. Try to make sure they have a chance to complete all of the work. WMF already sets ignore_user_abort() across the board in config, but this applies it to key spots for all installs, in addition to bumping the time limit. * Eventually this can lower the need for high overall time limits. Bug: T102890 Change-Id: I893ddd773064dcd63b5b24c84c6391974f4b5aee
* API: Fix access on getExamplesMessagesBrad Jorsch2014-10-291-1/+1
| | | | | | | ApiBase declares it protected, but for some reason I had made it public in all subclasses. Change-Id: I8a50d4f47e66c7f09137968d3941dc5cdc1d28e4
* API: Internationalize all remaining core API modulesBrad Jorsch2014-10-201-28/+8
| | | | | | | | | This also adds some new ApiBase::PARAM_* constants to generate more helpful help, and a method to override the default description message for the use of ApiDisabled and ApiQueryDisabled. Bug: 71638 Change-Id: Ic0c3d232e0498d58a043037e2e0c6f0b1c3edad3
* API: Overhaul token handlingBrad Jorsch2014-08-261-15/+20
| | | | | | | | | | | | | | | | | | | | The current token handling is a mess. This simplifies things greatly: * *All* tokens are obtained from action=query&meta=tokens, rather than being spread over action=tokens, action=query&prop=info, action=query&prop=revisions, action=query&prop=recentchanges, and action=query&prop=users. All these old methods are deprecated. * Similarly, there is only one hook to register new token types. All old hooks are deprecated. * All tokens are cacheable. * Most token types are dropped in favor of a 'csrf' token. They already were returning the same token anyway. * All token-using modules will document the required token type in a standard manner in action=help and are documented in machine-readable fashion in action=paraminfo. Note this will require updates to all extensions using tokens. Change-Id: I2793a3f2dd64a4bebb0b4d065e09af1e9f63fb89
* API: Remove action=paraminfo 'props' and 'errors' result propertiesBrad Jorsch2014-08-071-26/+0
| | | | | | | | | | | | | | | | | The format for 'props' was never specified and the list for 'errors' is impossible to keep updated when considering that many errors come from MediaWiki backend code and extension hook functions. And since there doesn't seem to be any real use case for either of these, let's just kill both of them instead of wasting effort on trying to fix them. Note that neither getResultProperties nor getPossibleErrors are called from any extensions in gerrit, and none of the other deprecated methods are called outside of the implementations of those two methods. Removing the obsolete methods is left to the maintainers of the extensions, as keeping them hurts nothing and is needed to maintain compatibility with earlier versions of MediaWiki. Change-Id: Ie11a401d60c834059fbf1b5625ca8ea093b3337c