aboutsummaryrefslogtreecommitdiffstats
path: root/includes/api/ApiWatch.php
Commit message (Collapse)AuthorAgeFilesLines
* api: Use type declaration on undocumented private functionsUmherirrender2025-04-041-2/+2
| | | | Change-Id: I2998ad3ccc5a54eccfe36ad09fe509e83dfb719c
* 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/+5
| | | | | Bug: T353458 Change-Id: I3ea6b08c5018ba03ba45c5766e1f46e12f6b8597
* api: Add missing documentation to class propertiesUmherirrender2024-09-071-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: I8b33b5f4d91c1935228e7010327dbc6ce138fc00
* Get correct main page in API call examplesAmmar Abdulhamid2023-09-201-3/+6
| | | | | | | | | | | | | | 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
* Namespace User under \MediaWiki\UserJames D. Forrester2023-09-191-0/+1
| | | | | Bug: T166010 Change-Id: I7257302b485588af31384d4f7fc8e30551f161f1
* Namespace TitleFormatter under \MediaWiki\TitleJames D. Forrester2023-09-191-0/+1
| | | | | | | One of the big ones, so doing this alone. Bug: T166010 Change-Id: Ic2d59eb6764b1a273ed7162ecabf641f638b8f66
* ApiWatch: Fix property type documentationBartosz DziewoƄski2023-08-281-5/+2
| | | | Change-Id: Ida3b57a13c4e8cf0183297e038810f2da5378c17
* Allow watchlist UI for temp users with sufficient rightsTim Starling2023-08-231-1/+3
| | | | | | | | | | | | | | | | | | Following on from I1ccda3878a, if temp users are explicitly granted viewmywatchlist and editmywatchlist rights in LocalSettings.php, make the watchlist API and UI be functional for them. The reasons for denying temp users access to the watchlist are mostly Wikimedia-specific, and may change in future, so this provides a bit more flexibility for third parties and for future use. T330518 (Minerva watch star suppression) does not appear to regress. This change does not cause a watch star to appear for Minerva, since it is doing its own thing. A watch star does appear for Vector, conditional on user rights. Bug: T341976 Change-Id: Idfebd0f9ab939faa962dfad6d6f502c312c819fa
* watchlist: Prepare for IP MaskingMartin Urbanec2023-08-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Instead of replacing isRegistered with isNamed in the watchlist component, (re)assign the watchlist rights (`editmywatchlist` and `viewmywatchlist`) to the `user` group, instead of `*`. This should hide watchlist-related interface from temp accounts, as those are not a member of the `user` group. isRegistered() is kept in watchlist, as technically, any user with an ID could have a watchlist (it is now a matter of rights / product decision, rather than technological reasons). This patch partially reverts Ib935fc04387100f25cafd75c632ac5ae7114d5d5. This is an alternative to Ifeedbbfb520ec26680134279bd44fec98754d897. What is left is to change the "User registration" filters to match expectations for temp. accounts (to be done in a follow-up patch; see T343322). Bug: T341976 Change-Id: I1ccda3878a658d4251429ae65ebee04c09d81243
* api: Replace deprecated ApiPageSet::getMissingTitles in action=watchUmherirrender2023-06-161-10/+20
| | | | | Bug: T339384 Change-Id: I6ca0620f943557e9cc977c4b22f27975295b0811
* 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
* Make use of ??= in more placesDannyS7122022-12-171-3/+1
| | | | | | New feature from PHP 7.4 Change-Id: Ifa7a9bc7b2ec415ad7ecb23f4c1776f51f58fd6b
* Use MainConfigNames instead of string literals, #2Aryeh Gregor2022-04-131-2/+3
| | | | | | | This covers all occurrences of /onfig->.*get( '/ in includes/. Undoubtedly there are still plenty more to go. Change-Id: I33196c4153437778496f40436bcde399638ac361
* Replace Title::isWatchable() with WatchlistManager::isWatchable()Cindy Cicalese2021-04-291-2/+2
| | | | | Bug: T281497 Change-Id: I947422fa9aa7f26dcd304da2089b8252b60ab4c1
* Use WatchlistManager in API classesCindy Cicalese2021-04-211-4/+9
| | | | Change-Id: I7b2016162e86b455c0102742751981c44d7e829c
* 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
* Swap out uses of User->isLoggedIn() with ->isRegistered()James D. Forrester2020-12-221-1/+1
| | | | | Bug: T270450 Change-Id: I90ff94a553ebae9a4ef97c25c333f067f19c327d
* WatchedItemStore: Enforce a maximum watchlist expiry durationMusikAnimal2020-05-221-0/+7
| | | | | | | | | | | | | | | | | | | | | Introduces $wgWatchlistExpiryMaxDuration which is used instead of given expiry if the given exceeds it. This is done in the storage layer. The reasoning is to control the size of the watchlist_expiry table. Hence, the max duration does not apply to indefinite expiries (since that would mean now row in watchlist_expiry). The frontend is responsible for disallowing expiries greater than the max, if it choses to do so. APIs should now pass in $wgWatchlistExpiryMaxDuration as the PARAM_MAX setting for the 'expiry' type. They should also set PARAM_USE_MAX so that the maximum value is used if it is exceeded. Other APIs that watch pages will be updated in separate patches (see T248512 and T248514). Bug: T249672 Change-Id: I811c444c36c1da1470f2d6e185404b6121a263eb
* Add expiry type to ParamValidatorMusikAnimal2020-04-081-26/+2
| | | | | | | | | | | | | | | This commit also changes ApiWatch to make use of the new parameter type. Other APIs will be updated to use it in a separate patch (T248196). In doing this, we are for the first using logic within a TypeDef outside the API. This seems acceptable given TypeDefs chiefly appear to serve as a validation method, with otherwise no particular logic tied to the concept of APIs. wfIsInfinity() now uses ExpiryDef::INFINITY_VALS Bug: T248508 Change-Id: If8f0df059eafb73ec9f39cc076b3a9ce2412d60a
* ApiWatch: Add support for expiriesMusikAnimal2020-03-241-5/+65
| | | | | | | | | With this commit, the action=watch API accepts an 'expiry' parameter, analagous to the expiry accepted by action=userrights, action=block, etc. Bug: T245078 Change-Id: If37a772253082529cb290027da87098c1e6bf98c
* Emit namespace for titles in ApiWatchDannyS7122019-10-241-3/+4
| | | | | Bug: T235477 Change-Id: Ib7a1e6c727f8c7d04b5b0b41ed385d451f25f611
* 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
* 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
* ApiWatch: Set 'missing' to true, not 1Brad Jorsch2016-12-201-1/+1
| | | | | Bug: T153775 Change-Id: I2b45cc7f64623f10d86e37dd2cbf2516f78ae7e6
* API: More i18n cleanupBrad Jorsch2016-12-081-10/+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-9/+14
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* Use different message when (un)watching a page in talk namespaceGlaisher2016-08-071-2/+4
| | | | | | | | | addedwatchtext and removedwatchtext uses the phrase "$1 and its discussion page". As this is inaccurate on talk namespace pages, two new messages, addedwatchtext-talk and removedwatchtext-talk, have been introduced for use in talk namespace pages. Bug: T87856 Change-Id: Iafd86402d3a2a65ce2be007c87c981ac08f44e67
* Use single quotes in API where possibleSiebrand Mazeland2016-03-081-1/+1
| | | | Change-Id: I972e296f4820f78f5dfcecc27bc4912ca84a3178
* Convert all array() syntax to []Kunal Mehta2016-02-171-14/+14
| | | | | | | | | | 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
* API: Log all deprecated parameter uses to api-feature-usage.logBrad Jorsch2015-11-031-1/+0
| | | | | | | | | Some were being logged, and some weren't. Let's log them all automatically when PARAM_DEPRECATED is processed, instead of requiring each module to manually log them. Bug: T117569 Change-Id: Ia38aeeccd0b9857b12b28914f509284483fbcca8
* Change API result data structure to be cleaner in new formatsBrad Jorsch2015-04-201-2/+2
| | | | | | | | | | | Nothing in this patch should result in changed output for format=json or format=php except as noted in RELEASE-NOTES-1.25, and changed output for format=xml should be similar or cosmetic. However, other code accessing the result data directly may need to be updated. Bug: T87053 Bug: T12887 Change-Id: I3500708965cb8869b5aed1543381aad208dadd13
* API: Overhaul ApiResult, make format=xml not throw, and add json formatversionBrad Jorsch2015-04-101-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ApiResult was a mess: some methods could only be used with an array reference instead of manipulating the stored data, methods that had both array-ref and internal-data versions had names that didn't at all correspond, some methods that worked on an array reference were annoyingly non-static, and then the whole mess with setIndexedTagName. ApiFormatXml is also entirely annoying to deal with, as it liked to throw exceptions if certain metadata wasn't provided that no other formatter required. Its legacy also means we have this silly convention of using empty-string rather than boolean true, annoying restrictions on keys (leading to things that should be hashes being arrays of key-value object instead), '*' used as a key all over the place, and so on. So, changes here: * ApiResult is no longer an ApiBase or a ContextSource. * Wherever sensible, ApiResult provides a static method working on an arrayref and a non-static method working on internal data. * Metadata is now always added to ApiResult's internal data structure. Formatters are responsible for stripping it if necessary. "raw mode" is deprecated. * New metadata to replace the '*' key, solve the array() => '[]' vs '{}' question, and so on. * New class for formatting warnings and errors using i18n messages, and support for multiple errors and a more machine-readable format for warnings. For the moment, though, the actual output will not be changing yet (see T47843 for future plans). * New formatversion parameter for format=json and format=php, to select between BC mode and the modern output. * In BC mode, booleans will be converted to empty-string presence style; modules currently returning booleans will need to use ApiResult::META_BC_BOOLS to preserve their current output. Actual changes to the API modules' output (e.g. actually returning booleans for the new formatversion) beyond the use of ApiResult::setContentValue() are left for a future change. Bug: T76728 Bug: T57371 Bug: T33629 Change-Id: I7b37295e8862b188d1f3b0cd07f66ac34629678f
* 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-18/+10
| | | | | | | | | 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: HTMLize and internationalize the help, add Special:ApiHelpBrad Jorsch2014-10-101-17/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The existing API help, formatted as basically a plain-text document embedded in XML and with a little bolding and a few links syntax-highlighted in after the fact, works ok for experienced programmers but isn't at all newbie-friendly. Further, all the help is hard-coded in English, which isn't very friendly to non-English speakers. So let's rewrite it. The help text is now obtained from i18n messages and output in HTML, with the default display consisting of help for a single module with links to help for other modules. This, of course, necessitates deprecating many of the existing help-related methods and hooks and replacing them with new ones, but backwards compatibility is maintained for almost everything. At the same time, action=paraminfo also needs to support the 'description' and other help-related fields being output in wikitext or HTML, and I11cb063d (to access all modules via the 'modules' parameter instead of having 'modules', 'formatmodules', 'querymodules', and so on) is folded in. And we also add Special:ApiHelp. When directly accessed, it simply redirects to api.php with appropriate parameters. But it's also transcludable to allow up-to-date API help text to be included within the on-wiki documentation. Note this patch doesn't actually add i18n messages for any API modules besides ApiMain and ApiHelp. That will come in a followup patch, but for the moment the backwards-compatibility code handles them nicely. While we're messing with the documentation, we may as well add the "internal" flag requested in bug 62905 (although the 'includeinternal' parameter it also requests doesn't make much sense anymore) and a "deprecated" flag that's needed by several modules now. Bug: 30936 Bug: 38126 Bug: 42343 Bug: 45641 Bug: 62905 Bug: 63211 Change-Id: Ib14c00df06d85c2f6364d83b2b10ce34c7f513cc
* API: Overhaul token handlingBrad Jorsch2014-08-261-9/+0
| | | | | | | | | | | | | | | | | | | | 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: Log usage of various deprecated featuresBrad Jorsch2014-08-141-0/+1
| | | | | | This will let us know how aggressively we can finally remove these. Change-Id: I03fab36e921807e74fbabfa878756af254d89a1b
* API: Remove action=paraminfo 'props' and 'errors' result propertiesBrad Jorsch2014-08-071-19/+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
* API: Refactor continuation code and add to purge, watch, etc.Brad Jorsch2014-07-041-0/+6
| | | | | | | | | | | While generator support was added to various actions, the continuation parameters from the generators weren't being returned to the client. This patch refactors the code for handling continuation out of ApiQuery and into ApiResult, and then uses it in the other actions that need it. Bug: 60734 Change-Id: I1a6e51cdc964ddcdd69aaa2f735223371233e8af
* Revert "Add API action=watch 'entirewatchlist' param to bulk-clear watchlist."MaxSem2014-05-121-43/+17
| | | | | | | | Unbounded modification = replication lag. And this function is specifically intended for clearing very large watchlists which would easily escalate to pageable lags of several minutes. This reverts commit 66b07ea38133992f98bb158c95103b720fe958ec. Change-Id: Ie34be712884407e671d715e56bda3bff4a7e78f4
* Make phpcs-strict pass on includes/ (4/~10)Siebrand Mazeland2014-05-111-1/+2
| | | | Change-Id: I2767205a7059adfb8fa090a82abd332e518f2590
* Add API action=watch 'entirewatchlist' param to bulk-clear watchlist.Brion Vibber2014-05-091-17/+42
| | | | | | | | | | | Requested by bot runners, who often accumulate huge watchlists and have trouble resetting them. Requires POST and a token to prevent accidents or abuse. Same token as individual or list watching. Bug: 65058 Change-Id: Id8476a1ba8b2661cf6451cacf3121d5c2d0675cf
* Add final period to API module descriptionsaddshore2014-03-101-1/+1
| | | | Change-Id: Icae68c1ab1fd0006e00a3a9a56ae8f831d3d0d45
* Update formattingSiebrand Mazeland2014-02-061-2/+5
| | | | Change-Id: I18aff576262479c9bb1c56eb8e1d1aaae200e4b1
* Fix CodeSniffer errors and warningsSiebrand Mazeland2014-02-051-4/+17
| | | | Change-Id: Idc74e34634d88625773fb8f73315f61edfa67e28
* Support ApiPageSet in ApiWatcheranroz2014-02-041-19/+80
| | | | | | | | | | | | | Add support for ApiPageSet capabilities in ApiWatch to support batch operation on titles, pageids etc. The old 'title' parameter (for a single page) is still supported to keep backwards compatibility. Moved a function from ApiPurge to ApiPageSet: getInvalidTitlesAndRevisions() gathers warnings about invalid/missing titles/ids in the requested page set. Split from If993f6e8. Change-Id: I820dcb64d469616b10741df013911197cc5bde29
* Use Title::isWatchable in ApiWatchumherirrender2013-12-271-1/+1
| | | | | | Same checks, but same method as in SpecialEditWatchlist Change-Id: Ic03fc159df9e6322fd0f2d73de4e69b34065d5bb
* Fix CodeSniffer errors and warnings on some API classesSiebrand Mazeland2013-11-151-4/+9
| | | | Change-Id: Id5fd7180f3a1d62663f79b27ad5108062607596a
* Add user rights 'viewmywatchlist', 'editmywatchlist'Brad Jorsch2013-06-261-0/+3
| | | | | | | | | These are needed for OAuth grants. Note that, even if 'editmywatchlist' is not granted, various actions will still allow for adding but not removing of pages. Change-Id: Ie33446a228dd6ed0114730935c1bf65667f5ce01