aboutsummaryrefslogtreecommitdiffstats
path: root/includes/api/ApiQuery.php
Commit message (Collapse)AuthorAgeFilesLines
* Merge "api: Add query module for retrieving Codex icons"jenkins-bot2025-03-151-0/+3
|\
| * api: Add query module for retrieving Codex iconsSiddharth VP2025-01-081-0/+3
| | | | | | | | | | | | | | | | This supports use of Codex icons in user scripts, which do not have access to them via ResourceLoader. Bug: T311099 Change-Id: I4c47b0d17102bd446e6c846255349a6dbdeaf399
* | ApiQueryRandom: Allow filtering based on content modelAbijeet2025-03-101-0/+3
| | | | | | | | | | Bug: T364905 Change-Id: Ia8fd682f6f173933e8678b78f7d8c837aaf62d7a
* | ApiQuerySiteinfo: Support $wgGroupInheritsPermissionsKevin Israel2025-02-191-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | I noticed that the "confirmed" group was missing from the API result on en.wikipedia.org. It is defined using $wgGroupInheritsPermissions, not $wgGroupPermissions. Rather than only using the latter, obtain lists of user groups and granted permissions from UserGroupManager and GroupPermissionsLookup respectively (and not just for filtering undefined groups out of the lists of changeable groups). Bug: T357846 Change-Id: I473868449dcf360afcba3c731ac7f282b623b1cd
* | Stats: Add support for chaining TimingMetric->start()Timo Tijhof2025-01-301-4/+4
| | | | | | | | | | | | Bug: T240685 Bug: T364240 Change-Id: Id1fe4ac6127894c9861b0d904c7a55f21deb7455
* | ApiQueryBlocks: add 'parsedreason' propMusikAnimal2025-01-091-0/+1
|/ | | | | | | | | | This gives feature parity with ApiQueryLogEvents's 'parsedcomment' leprop. Needed by I2c24da2e44630b2bbbf1c041cb3c85cb1a1f7d66 Bug: T383180 Change-Id: Ia0c0c799e0b10b788ab414c9d7bd2fa3f018c3c7
* Add ApiQueryCheckCanExecute hookGergő Tisza2024-12-031-0/+6
| | | | | | Adds the equivalent of ApiCheckCanExecute for query modules. Change-Id: I88effab746544c4788b607059a2184ead5b1bbac
* Inject services into API classesFomafix2024-10-281-0/+9
| | | | | | | | | | | | | | | | | Inject all services into the following API classes * ApiQueryAllDeletedRevisions * ApiQueryAllRevisions * ApiQueryDeletedRevisions * ApiQueryDeletedrevs * ApiQueryLogEvents * ApiQueryRecentChanges * ApiQueryRevisions * ApiQuerySiteinfo * ApiQueryUserContribs The classes are not extended by extensions. Change-Id: Iaf3de739f43108976982f5255806e8a1a521dacd
* 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 includes/api classesJames D. Forrester2024-09-251-0/+8
| | | | | Bug: T353458 Change-Id: I3ea6b08c5018ba03ba45c5766e1f46e12f6b8597
* Update user widgets to support named and temp account exclusionJamie Kuppens2024-09-161-0/+1
| | | | | | | | | | | | | | | * This change introduces two new optional parameters to the 'allusers' API call named 'excludenamed' and 'excludetemp' that allows filtering accounts based on whether they're named accounts or temporary accounts. This is tested by using the temporary matchPattern configured with $wgAutoCreateTempUser. * User widgets that call 'allusers' have been updated so that 'excludenamed' and 'excludetemp' can be optionally set so that named or temporary accounts may not returned with user suggestions. Bug: T332030 Change-Id: I6563ae610017fd1cd35c36ba65906041f7f68c4b
* api: Add missing documentation to class propertiesUmherirrender2024-09-071-0/+2
| | | | | | | | | | 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
* Replace deprecated LogFormatter::newFromRow/newFromEntryUmherirrender2024-07-291-1/+4
| | | | Change-Id: I453ce3148a46fcb9cc5c685cee92274e0cb4f98a
* Filter temporary accounts as anonymous in ApiQueryRecentChangesSTran2024-07-291-0/+1
| | | | | | | | | | | | Edits from temporary accounts are considered anonymous edits. ApiQueryRecentChanges doesn't correctly reflect this and needs to be updated to correctly return temporary account edits as anonymous (and similarly, not to return them when requesting !anon) - Update the anon|!anon query to accomodate temporary accounts Bug: T370803 Change-Id: Ica5225422ea53d2aa3a84b86d9c2f14832a34ed4
* api: Replace deprecated ApiPageSet::getGoodTitlesUmherirrender2024-07-061-0/+1
| | | | | Bug: T339384 Change-Id: Ib2872498338c01ad63bbcee859f89f94311ee325
* ApiQuerySiteinfo: Use TempUserConfig classKosta Harlan2024-06-131-0/+1
| | | | | | | | | | | | | | | | | | | | | | | Why: - Using TempUserConfig is more flexible as it doesn't require us to know about the internal details of the AutoCreateTempUser config object What: - Use TempUserConfig service instead of loading the AutoCreateTempUser object - Remove properties from ApiQuerySiteInfo that don't already have getters. If someone has a need for more this information to be exposed in ApiQuerySiteInfo, they can be added in a separate patch - This seems compatible with the goals of T335532 which was about making it possible to discover via the API if an action would result in a temp account - Implement __toString for Pattern, so that it can be used in ApiQuerySiteInfo Bug: T335532 Change-Id: Ica84b3e9b9865b8b83a9e9e513c99cd2e47661c9
* Define ApiQuery::isWriteModeDreamy Jazz2024-04-051-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | Why: * ApiQueryBase subclasses may define a ::isWriteMode override, as the API call may need to write to the DB. ** This is the case for the CheckUser extension, where the 'checkuser' API creates a log entry that allows users to audit usage of the API. * ApiQuery currently does not define a implementation of ::isWriteMode, which means that the definitions by any class that extends ApiQueryBase currently do nothing. * ApiQuery::isWriteMode should be defined and work in a similar way to ApiQuery::isReadMode, so that subclasses of ApiQueryBase can have their definitions of ::isWriteMode respected. What: * Define ApiQuery::isWriteMode in a similar way to how ApiQuery ::isReadMode is written, but also inspecting the modules that are used through the 'list' and 'prop' params. * Add tests for ApiQuery::isWriteMode. Bug: T361951 Change-Id: Idf1c8f95df58a861404e0c89507c885ec4554793
* Group temporary users with IP users in ApiQueryWatchlist filtersThalia2024-03-031-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Why * ApiQueryWatchList allows filtering anon users or not-anon users. It is not obvious wether temporary users should be considered anon for these purposes. * The equivalent filters in recent changes group temporary users with anonymous users (T343322). * Since ApiQueryWatchlist queries the recentchanges table, and shares many filters with recent changes, it makes sense to filter the same way in both, and therefore to group temporary users with anonymous users. What * Update queries in WatchedItemQueryService to group temporary users with anonymous users for FILTER_ANON and FILTER_NOT_ANON. * Don't change the 'anon' flag, because the other APIs flag temporary users with anon=false. * Instead add a 'temp' flag for temporary users. Bug: T358693 Change-Id: I4cd3a4d0c5f4f488933cf3f06dee62a9beb85440
* Update summary message for ApiQueryContributors for temp accountsDreamy Jazz2024-02-281-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | Why: * The ApiQueryContributors API description says that it returns 'the list of logged-in contributors' for given pages in the API summary text. * When temporary accounts are enabled, this list will include both named and temporary accounts. As such, the message needs to be updated to make this clear for users of the API on a wiki which has temporary accounts enabled. What: * Add 'apihelp-query+contributors-summary-tempusers-enabled' which is shown instead of the existing summary message for the API if TempUserConfig::isEnabled returns true. * Update existing mention of 'anonymous' with 'logged-out' to per https://w.wiki/9Ji$ in the existing summary message. * Update the existing message documentation for the summary message to link to this new message to make it easier for translators. * Test the newly added PHP code. Bug: T341228 Change-Id: Id1bd597e068cb3aa946c94686ca6fa39ef1df89f
* ApiMain, ApiQuery: update stats to generate StatsFactory metricsCole White2024-01-171-15/+14
| | | | | Bug: T350592 Change-Id: I12681e3d069bdcaf184952d692d36bf71697e4d8
* Add `temp` flags to api callsSTran2023-12-121-0/+2
| | | | | | | | | | | | Temporary accounts are now distinct from users or anonymous. Add a flag to reflect that to: - ApiQueryImageInfo - ApiQueryLogEvents - ApiQueryRecentChanges - ApiQueryRevisionsBase Bug: T351636 Change-Id: I7986dea5ccd0dc942bf133040c4ac715487f29b9
* Special:BlockList: Improve display of hidden usersTim Starling2023-12-051-0/+1
| | | | | | | | | | | | | | | | With multiblocks the user might be hidden even if bl_deleted=0 in the block row being formatted. So: * Add a subquery with a second block_target/block table which determines whether the user is deleted. * When formatting each row, redact the name if it is deleted and the authority does not have permission to see it. * Add a parameter to show which block is the one responsible for deleting the user. * Similarly add a subquery in ApiQueryBlocks. Change-Id: Id9900397618e1f626802ada6fe4ee4ad10f32495
* Support new block schemaTim Starling2023-11-291-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Support migration stages when reading and writing blocks. I tried to set it up for an easy next stage, in which support for the old schema is removed. I tried to avoid factoring out of shared code between the two schemas, so that the old schema cases can simply be deleted without the need to revert unnecessary abstractions. However, I added HideUserUtils to factor out ipb_deleted queries. Code review showed that this was already quite complex, with multiple approaches to the problem, so it benefits from refactoring even without the schema abstraction. HideUserUtils is a service rather than a standalone class to support unit tests, since unit tests do not allow global config access. When the migration stage config is removed, it will be a service with no constructor parameters -- an unnecessary abstraction which should ideally be resolved at that time. When interpreting result rows, it is possible to share code by using field aliases. But when constructing WHERE conditions, the actual field names need to be used, so the migration is more intrusive in ApiQueryBlocks and SpecialBlockList, where complex conditions are used. Bug: T346293 Bug: T51504 Bug: T349883 Change-Id: I408acf7a57b0100fe18c455fc13141277a598925
* ApiQueryInfo: Fix permission checks while logged-out and temp users enabledBartosz Dziewoński2023-10-311-0/+1
| | | | | | | | | | When temp users are enabled, logged-out authority may not have the permission to perform some action, but the user (as in, the person) may still be able to perform it through the magic of having a temp user created for them. Bug: T350039 Change-Id: I5e776d670f0d487346191fa99596dc5d6809a414
* Get correct main page in API call examplesAmmar Abdulhamid2023-09-201-1/+4
| | | | | | | | | | | | | | 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 TitleFormatter under \MediaWiki\TitleJames D. Forrester2023-09-191-0/+1
| | | | | | | One of the big ones, so doing this alone. Bug: T166010 Change-Id: Ic2d59eb6764b1a273ed7162ecabf641f638b8f66
* api: Use ParserFactory on module creationUmherirrender2023-08-291-1/+1
| | | | | | | | Change "Parser" to "ParserFactory" in object specs and get a instance when needed Bug: T343070 Change-Id: I9b65c272726bb0035f4cdca4fbf417a0a11375cb
* Use real type hints for services etc. in api/ApiQuery*.phpBartosz Dziewoński2023-08-291-8/+3
| | | | | | | | | | | | | | | 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: Ie78be1c614985d7c2964156e454cc9266515dc18
* Merge "API: Add metrics for query modules"jenkins-bot2023-06-291-0/+19
|\
| * API: Add metrics for query modulesdaniel2023-06-291-0/+19
| | | | | | | | | | | | | | | | | | | | This adds metrics for individual query modules, to break down the timing currently lumped together in api.query.executeTiming. This will allow us to track repsonse latency for individual query modules on https://grafana.wikimedia.org/d/000000002/api-backend-summary Change-Id: I590fd2aff231789d0b7d31403a5222531f2b458d
* | Merge "api: Replace deprecated ApiPageSet::getGoodPages in action=query"jenkins-bot2023-06-261-8/+27
|\ \
| * | api: Replace deprecated ApiPageSet::getGoodPages in action=queryUmherirrender2023-06-161-8/+27
| |/ | | | | | | | | | | | | | | | | Inject TitleFormatter and TitleFactory to improve the best case (getGoodPages) to avoid calling the factory there instead of using Title::getPrefixedText after calling factory Bug: T339384 Change-Id: I21cf9b738cfdb1a418c10e48ec834efefccb6ab7
* / API: Replace deprecated calls to wfExpandUrl with UrlUtils::expandJames D. Forrester2023-06-221-0/+12
|/ | | | | Bug: T319340 Change-Id: Ic987f9381ac17e9e46504abdb2d07a5a94ba3b4a
* Start using ChangeTagsStoreAmir Sarabadani2023-06-091-0/+3
| | | | | | | Also some clean ups here and there Bug: T245964 Change-Id: Ibf20eec3257a2dc54e3ccbe766b679ebdfbab8d9
* api: Drop ApiQuery::getNamedDB() and ApiQueryBase::selectNamedDB()Amir Sarabadani2023-06-011-32/+0
| | | | | | | | Both deprecated in 1.39 and hard-deprecated. Unused in production and allow us to clean up dependency of ApiQuery to LB. Depends-On: Ia94618b7f58fcca72e903fd2e2e9f0aaa501ac24 Change-Id: Ie0322e5346b94932a2eddc0b7aad5a384768b888
* Add 'preloadcontent' and 'editintro' in API prop=infoBartosz Dziewoński2023-05-201-0/+3
| | | | | | | | Deprecate 'preload', which only supported one way of generating preloaded content, and was confused about empty string and null. Bug: T45683 Change-Id: Ie9f123920b69e41a186bc1c1c5db1bc0a6092a75
* Merge "api: Use a temp placeholder for signature on preview/pst"jenkins-bot2023-05-101-0/+8
|\
| * api: Use a temp placeholder for signature on preview/pstUmherirrender2023-05-041-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For pst on parse/compare/editstash/(all)revisions/(all)deletedrevisions Do not show the IP when IP masking is enabled, instead show a previous aquired temp name or a placeholder on preview. MediaWiki itself used this for the ajax preview on GUI's action=edit Cannot acquire a new unsaved temp user as api parse does not persist the global session (each request results in a new id) and it would require a db write on a read request. Bug: T331397 Change-Id: I74bb4d655f371bd99e3b618d1a0ac45d730c746c
* | Expose automatic temporary user info in the APIBartosz Dziewoński2023-04-281-0/+1
|/ | | | | | | | | | | | | action=query&prop=info&intestactions=...: Add &intestactionsautocreate=1 to also check whether the actions would result in a creation of a temporary user account. action=query&meta=siteinfo: Add &siprop=autocreatetempuser to output the configuration of temporary user accounts. Bug: T335532 Change-Id: I62b4bb630decac92cbb8c7ddf00307df0dadb516
* 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
* search: Make TitleMatcher a MediaWiki service objectDerick Alangi2023-02-031-0/+1
| | | | | | | | | | | @note: Deprecated SearchEngine::getNearMatcher and ::getDefaultMatcher() and begin using the new interfaces. Renamed SearchNearMatcher to depict what it really does like TitleMatcher when searching. Also, I pulled out SpecialSearchTestMockResultSet class to a separate file. Change-Id: I09990e9f263c075a6ab137ee5bcb7285359f057c
* api: Replace deprecated Linker::formatCommentUmherirrender2022-12-111-0/+6
| | | | | Bug: T324906 Change-Id: I1fcb7bd9d84754793c07ac9e39e50c38b364e4c1
* api: Deprecate ApiQuery::getNamedDB and ::selectNamedDB()Timo Tijhof2022-08-221-2/+7
| | | | | | | | | | | | | | | | | | The Rdbms library already takes care of caching and re-using connections nowdays. Perhaps in a past where DBConnRef was less common or not yet created this made sense, but we've now adopted that universally. I don't know of a current use case for WMF, given the removal of non-vertical query groups in T263127 (e.g. we keep "api" for all API traffic, but not e.g. something individual classes would change). For now I've documented that in someone does run into this, perhaps in third-party code, that we recommend instead to override getDB() instead of relying on this central mechanism. E.g. overriddet getDB() to return `wfGetDB(DB_REPLICA,'mygroup')`. Bug: T263127 Change-Id: I4c3cc7868f1f4210ee655541eb6a45705c643c70
* api: Support for links migration in ApiQueryBacklinksAmir Sarabadani2022-07-291-0/+9
| | | | | | Bug: T312865 Bug: T314112 Change-Id: Ic30a658f9cce503a2afbca826a3b828e087f0e65
* api: Replace numerous deprecated constantsReedy2022-06-061-8/+9
| | | | Change-Id: I34ffcb70efbfa257da8dab6e0790aa0d697caf5b
* Use injection for LinksMigration on LinkBatch, action, api, special pageUmherirrender2022-05-101-0/+25
| | | | | | | | Even the service does not long stay in that classes, it should be injected to avoid global state Bug: T304780 Change-Id: Ib488037f5a6966ab61042ed3cd889ddc50f1ba8e
* Merge "api: Change UserOptionsLookup to GenderCache in list=users"jenkins-bot2022-04-141-1/+1
|\
| * api: Change UserOptionsLookup to GenderCache in list=usersUmherirrender2022-04-141-1/+1
| | | | | | | | | | | | | | | | | | | | Getting only the gender option from the UserOptionsLookup is expensive, because each option results in one query to load all options. The GenderCache allows for prefilling the gender for multiple users and results in only one query. That can make a difference if multiple user names are requested. Change-Id: Id954a636452d5729eb3b8050db4a0068bf02c9ed
* | Remove usages of deprecated Title::getRestrictionTypesUmherirrender2022-04-131-0/+1
| | | | | | | | | | Bug: T306131 Change-Id: Id7b2849bb1c31dbd79acbeb607dfc4f7869e6142
* | Use MainConfigNames instead of string literals, #2Aryeh Gregor2022-04-131-3/+4
|/ | | | | | | This covers all occurrences of /onfig->.*get( '/ in includes/. Undoubtedly there are still plenty more to go. Change-Id: I33196c4153437778496f40436bcde399638ac361