aboutsummaryrefslogtreecommitdiffstats
path: root/includes/api/ApiUndelete.php
Commit message (Collapse)AuthorAgeFilesLines
* api: Use type-declaration for string arg in ApiBase::__constructUmherirrender2024-10-171-9/+1
| | | | | | | Also for all sub-classes Remove simple doc-blocks without further information Change-Id: I981934efe32d44f52e5ab865a9b887be5bd0f41e
* Add namespace to IDBAccessObject and DBAccessObjectUtilsJames D. Forrester2024-09-271-1/+1
| | | | | Bug: T353458 Change-Id: I23cf7991f8792d4d000d1780463d8ce76dc0aee0
* Add namespace to includes/api classesJames D. Forrester2024-09-251-0/+6
| | | | | Bug: T353458 Change-Id: I3ea6b08c5018ba03ba45c5766e1f46e12f6b8597
* Remove more indirect calls to IDBAccessObject::READ_* constantsAmir Sarabadani2024-01-231-2/+1
| | | | | | | | | | Found via (?<!IDBAccessObject)::READ_ We are planning to deprecate and remove implementing IDBAccessObject interface just to use the constants. Bug: T354194 Change-Id: I89d442fa493b8e5332ce118e5bf13f13b8dd3477
* 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
* 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-5/+2
| | | | | | | | | | | | | | | 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: On action=undelete check for proper page identityUmherirrender2023-05-091-0/+3
| | | | | | | | | | | | WikiPageFactory::newFromTitle would throw when passing special pages to action=undelete, call Title::canExists to check if the title could be stored in the database (or read from it in this case) internal_api_error_MediaWiki\\Page\\PageAssertionException Exception caught: The given PageIdentity Special:SpecialPages does not represent a proper page Change-Id: I05bf76334cee3bcff8d853b4683efe744ab0b2d8
* 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-8/+9
| | | | Change-Id: I34ffcb70efbfa257da8dab6e0790aa0d697caf5b
* Use MainConfigNames instead of string literals, #2Aryeh Gregor2022-04-131-2/+4
| | | | | | | This covers all occurrences of /onfig->.*get( '/ in includes/. Undoubtedly there are still plenty more to go. Change-Id: I33196c4153437778496f40436bcde399638ac361
* ApiUndelete: Fix api bad method callDayllan Maza2022-04-011-1/+1
| | | | | | Follow-Up: I3d4775588f164c3007b1a89424674f Bug: T290210 Change-Id: I042978071422e3c8c592a77104ed79e6fc2ac667
* ApiUndelete: add option to undelete associated talk pageDaimona Eaytoy2022-03-301-8/+16
| | | | | | | | | | | * Associated talk page will only be restored if restoring the subject page was successful * If the subject page never existed or is currently available restoring the associated talk page should not be completed * Warnings and errors should be displayed accordingly Bug: T290210 Change-Id: I3d4775588f164c3007b1a89424674f7ce91c6f6d
* Use UndeletePage from ApiUndeleteDaimona Eaytoy2021-10-051-26/+37
| | | | | | | | | | | | | | | UndeletePage is responsible for checking permissions. As a user-facing change, if the user cannot undelete pages, the module will error with the "permissiondenied" code and the "badaccess-groups" message. This is consistent with other API modules (e.g. ApiDelete), and replaces the previous behaviour of failing with code "permdenied-undelete" and no message explaining the failure (which seems to be a bug). For everything else, backwards compatibility is preserved; in particular, we still die with "apierror-cantundelete" if nothing was deleted (which UndeletePage considers a successful operation). Bug: T290021 Change-Id: I89f5e9e4a1e120e6ca6dd52987059baefbcb84d5
* Use fluent setters instead of optional params in UndeletePageDaimona Eaytoy2021-10-011-2/+2
| | | | | | | Also make $comment a required parameter, for symmetry with DeletePage. Bug: T290021 Change-Id: I0bb2c6b782bf4d61396657d367e182295f913f0e
* Move code from PageArchive to a new UndeletePage commandDaimona Eaytoy2021-09-211-1/+1
| | | | | | | | This is just moving code verbatim, removing now-unneeded stuff, and duplicating tests as well. Bug: T290021 Change-Id: I540ddaaa11dfabcf0b87b608b151b5e34d199fd8
* api: Inject services into ApiWatchlistTraitUmherirrender2021-07-061-3/+19
| | | | | Bug: T259960 Change-Id: I73596f8c924ec4a02a7042608d19a35f82bb752a
* Authority: expose user block infodaniel2021-06-301-2/+4
| | | | | | | | | Expose info about user blocks from Authority. This allows calling code to provide more detailed information to the user about why they are denied some action on the wiki. Bug: T271494 Change-Id: Ia84e469888866d72752aad355292666c31e12bad
* Convert ChangeTags public interface to Authority.Petr Pchelko2021-02-241-2/+1
| | | | | Bug: T275507 Change-Id: I3b7f99391ab299df2b046a2878010cf6afe7fed7
* Use Authority and GroupPermissionLookup in Action APICindy Cicalese2021-02-231-1/+2
| | | | | | | | | | | | | | | | | | | Replaces calls directly to PermissionManager with calls to the Authority object available from Context or the GroupPermissionLookup service. This patch does not address use of PermissionManager for blocks. Deprecations: - ApiBase::checkUserRightsAny deprecated passing optional User parameter - ApiBase::checkTitleUserPermissions deprecated passing LinkTarget as first parameter, takes PageIdentity instead Bug: T271462 Bug: T271854 Change-Id: I5d7cac1c28a37e074750c46cda03283980a07fca
* 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/+12
| | | | | | | | | | | 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
* Hooks::run() call site migrationTim Starling2020-05-301-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Migrate all callers of Hooks::run() to use the new HookContainer/HookRunner system. General principles: * Use DI if it is already used. We're not changing the way state is managed in this patch. * HookContainer is always injected, not HookRunner. HookContainer is a service, it's a more generic interface, it is the only thing that provides isRegistered() which is needed in some cases, and a HookRunner can be efficiently constructed from it (confirmed by benchmark). Because HookContainer is needed for object construction, it is also needed by all factories. * "Ask your friendly local base class". Big hierarchies like SpecialPage and ApiBase have getHookContainer() and getHookRunner() methods in the base class, and classes that extend that base class are not expected to know or care where the base class gets its HookContainer from. * ProtectedHookAccessorTrait provides protected getHookContainer() and getHookRunner() methods, getting them from the global service container. The point of this is to ease migration to DI by ensuring that call sites ask their local friendly base class rather than getting a HookRunner from the service container directly. * Private $this->hookRunner. In some smaller classes where accessor methods did not seem warranted, there is a private HookRunner property which is accessed directly. Very rarely (two cases), there is a protected property, for consistency with code that conventionally assumes protected=private, but in cases where the class might actually be overridden, a protected accessor is preferred over a protected property. * The last resort: Hooks::runner(). Mostly for static, file-scope and global code. In a few cases it was used for objects with broken construction schemes, out of horror or laziness. Constructors with new required arguments: * AuthManager * BadFileLookup * BlockManager * ClassicInterwikiLookup * ContentHandlerFactory * ContentSecurityPolicy * DefaultOptionsManager * DerivedPageDataUpdater * FullSearchResultWidget * HtmlCacheUpdater * LanguageFactory * LanguageNameUtils * LinkRenderer * LinkRendererFactory * LocalisationCache * MagicWordFactory * MessageCache * NamespaceInfo * PageEditStash * PageHandlerFactory * PageUpdater * ParserFactory * PermissionManager * RevisionStore * RevisionStoreFactory * SearchEngineConfig * SearchEngineFactory * SearchFormWidget * SearchNearMatcher * SessionBackend * SpecialPageFactory * UserNameUtils * UserOptionsManager * WatchedItemQueryService * WatchedItemStore Constructors with new optional arguments: * DefaultPreferencesFactory * Language * LinkHolderArray * MovePage * Parser * ParserCache * PasswordReset * Router setHookContainer() now required after construction: * AuthenticationProvider * ResourceLoaderModule * SearchEngine Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
* Make use of PageArchive::undeleteAsUserDannyS7122020-03-181-2/+2
| | | | | Bug: T247188 Change-Id: I1dc38d039aa375fc607463360ed4d007b4cf16d5
* Coding style: Auto-fix MediaWiki.Usage.IsNull.IsNullJames D. Forrester2020-01-101-1/+1
| | | | Change-Id: I90cfe8366c0245c9c67e598d17800684897a4e27
* Unsuppress more phan issues (part 5)Daimona Eaytoy2019-09-011-4/+6
| | | | | | Bug: T231636 Depends-On: I6e5fba7bd273219b1206559420b5bdb78734aa84 Change-Id: I50377746f01749b058c39fd8229f9d566224cc43
* API: Migrate Title::userCan() calls to PermissionManagerMáté Szabó2019-05-301-1/+1
| | | | | | | | | T208768 introduced the PermissionManager service that can now be used for page specific permission checks. This change replaces calls to Title::userCan() with the new service in API classes. Bug: T220191 Change-Id: I768d07a520ca6473a4eefb88c9f587657bc74357
* Fix partially blocked admin undelete permissionsDayllan Maza2019-03-291-1/+2
| | | | | | | | If an admin is partially blocked they should be able to restore/undelete any given page. Bug: T219305 Change-Id: I404730273c33d72d7552cd69e93ccec78c5fad5a
* Use (int) rather than intval()Reedy2019-02-251-2/+2
| | | | | Bug: T216969 Change-Id: I4c06716c83b69d128f26fa7f68736808aa2d3d64
* Use PHP 7 '??' operator instead of '?:' with 'isset()' where convenientBartosz Dziewoński2018-05-301-1/+1
| | | | | | | | | | | | | | Find: /isset\(\s*([^()]+?)\s*\)\s*\?\s*\1\s*:\s*/ Replace with: '\1 ?? ' (Everywhere except includes/PHPVersionCheck.php) (Then, manually fix some line length and indentation issues) Then manually reviewed the replacements for cases where confusing operator precedence would result in incorrect results (fixing those in I478db046a1cc162c6767003ce45c9b56270f3372). Change-Id: I33b421c8cb11cdd4ce896488c9ff5313f03a38cf
* 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
* SECURITY: Do not allow users to undelete a page they can't edit or createBrian Wolff2017-04-061-1/+4
| | | | | | | | | | | | | | | | | | | If the page exists, it only checks edit rights, otherwise it checks both edit and create rights. This would only matter on wikis that have a non-default rights configuration where there are users with undelete rights but a restriction level enabled that prevents them from creating/editing pages (or they otherwise aren't allowed to edit/create) It should be noted that the error messages aren't used in the normal UI currently, but they could be in the future, and extensions could potentially be using them (The backend functions return them, but the UI functions in Special:Undelete ignore them) Bug: T108138 Change-Id: I164b80534cf89e0afca264e9de07431484af8508
* 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: i18n for warnings and errorsBrad Jorsch2016-12-061-6/+4
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* Add tags support to patrol, protect, unblock, and undeleteGeoffrey Mon2016-02-291-1/+14
| | | | | | | | | | | | - Add 'tags' parameters to appropriate API modules - Add tag-adding logic to appropriate functions that carry out relevant functions - ManualLogEntry::{set,get}Tags to handle adding tags to log entries in a cleaner fashion - Use ManualLogEntry::setTags in LocalFile::recordUpload2 Bug: T97720 Change-Id: I98c52da7985623bfdafda2dc2dae937b39b72419
* Convert all array() syntax to []Kunal Mehta2016-02-171-19/+19
| | | | | | | | | | 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
* Add dieBlocked to APIBase and make use of itAndrew H2015-12-221-9/+4
| | | | | | | Moves a frequently used snippet of code into APIBase to throw a usage exception with block info. Change-Id: I9bd0b2804e9e246f6d53031b04af48f111c0814c
* 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: Give block details along with errorsAlex Monk2015-06-171-1/+6
| | | | | Bug: T95072 Change-Id: I295d74d5f33e6dd1072a1e85710a02597a46e14d
* Replace wfRunHooks calls with direct Hooks::run callsAaron Schulz2014-12-101-1/+1
| | | | | | * This avoids the overhead of an extra function call Change-Id: I8ee996f237fd111873ab51965bded3d91e61e4dd
* 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/+6
| | | | | | | | | 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-13/+1
| | | | | | | | | | | | | | | | | | | | 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-20/+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
* SpecialUndelete/PageArchive: Use Config instead of globalsKunal Mehta2014-08-061-1/+1
| | | | Change-Id: Ic025412ed74d9cffad48a3ab04788d46ab43befb
* API: Allow undeleting filesBrad Jorsch2014-07-311-6/+20
| | | | | | | Strange that action=undelete didn't support this already. Bug: 40817 Change-Id: Ia864158370411e555f63f70588ebd305a756d6f5
* Add final period to API module descriptionsaddshore2014-03-101-1/+1
| | | | Change-Id: Icae68c1ab1fd0006e00a3a9a56ae8f831d3d0d45
* Fix CodeSniffer errors and warnings on some API classesSiebrand Mazeland2013-11-151-4/+6
| | | | Change-Id: Id5fd7180f3a1d62663f79b27ad5108062607596a
* API: Throw error when interwiki is given for various title paramumherirrender2013-03-011-1/+1
| | | | | | | | | | | | | See bug 44341 for action=parse, but the problem with interwiki processing can also be happen in other modules. This gives clearer error message on some modules For example action=move: Bad title "*title*" instead of: Unknown error: "immobile-target-namespace-iw" Change-Id: I86524533dfd778a169b39968999918a1f531efeb