aboutsummaryrefslogtreecommitdiffstats
path: root/includes/api/ApiQueryUsers.php
Commit message (Collapse)AuthorAgeFilesLines
...
* Remove $wgDisableUserGroupExpiry feature flagThis, that and the other2017-05-061-4/+2
| | | | | | | | | | This feature flag was added to comply with WMF's schema change policy. It is no longer needed now that the feature is enabled on WMF sites. External MW installations will run update.php or manually do DB updates as required before upgrading MW. Bug: T162517 Change-Id: I5b532d79fd1e8b178490cf2617499ae62967de2c
* 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
* Make user_groups queries honor $wgDisableUserGroupExpiryThis, that and the other2017-01-311-2/+4
| | | | | | Follow-up to Icf78cce3f3e362677d10897b8d1103b3df91fa08. Change-Id: I94102ceb00398940965280d8742a2747631dcc87
* Disregard expired user_group rows in special page and API DB queriesThis, that and the other2017-01-271-2/+7
| | | | | | | An essential follow-up to I93c955dc7a970f78e32aa503c01c67da30971d1a. Bug: T12493 Change-Id: Icf78cce3f3e362677d10897b8d1103b3df91fa08
* User group memberships that expireThis, that and the other2017-01-271-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds an ug_expiry column to the user_groups table, a timestamp giving a date when the user group expires. A new UserGroupMembership class, based on the Block class, manages entries in this table. When the expiry date passes, the row in user_groups is ignored, and will eventually be purged from the DB when UserGroupMembership::insert is next called. Old, expired user group memberships are not kept; instead, the log entries are available to find the history of these memberships, similar to the way it has always worked for blocks and protections. Anyone getting user group info through the User object will get correct information. However, code that reads the user_groups table directly will now need to skip over rows with ug_expiry < wfTimestampNow(). See UsersPager for an example of how to do this. NULL is used to represent infinite (no) expiry, rather than a string 'infinity' or similar (except in the API). This allows existing user group assignments and log entries, which are all infinite in duration, to be treated the same as new, infinite-length memberships, without special casing everything. The whole thing is behind the temporary feature flag $wgDisableUserGroupExpiry, in accordance with the WMF schema change policy. The opportunity has been taken to refactor some static user-group-related functions out of User into UserGroupMembership, and also to add a primary key (ug_user, ug_group) to the user_groups table. There are a few breaking changes: - UserRightsProxy-like objects are now required to have a getGroupMemberships() function. - $user->mGroups (on a User object) is no longer present. - Some protected functions in UsersPager are altered or removed. - The UsersPagerDoBatchLookups hook (unused in any Wikimedia Git-hosted extension) has a change of parameter. Bug: T12493 Depends-On: Ia9616e1e35184fed9058d2d39afbe1038f56d7fa Depends-On: I86eb1d5619347ce54a5f33a591417742ebe5d6f8 Change-Id: I93c955dc7a970f78e32aa503c01c67da30971d1a
* ApiQueryUsers: Add ability to search by user IDrlot2016-12-081-51/+89
| | | | | | | Added new 'userids' parameter to ApiQueryUsers.php. It accepts user ID numbers. Bug: T34494 Change-Id: I8021bc8660f19e90f0f7d43ea0e82d5258c586ab
* API: i18n for warnings and errorsBrad Jorsch2016-12-061-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* API: Don't require 'users' parameter to contain all valid usernamesBrad Jorsch2016-08-221-1/+0
| | | | | | | | | Instead, go back to validating the individual values so one invalid name doesn't cause the whole module to error out. The code for that was all still there, just unused since Ic67fb540. Bug: T142895 Change-Id: Ia5eae51d69185580ac2c772afc198a92813e407a
* Remove $wgDisableAuthManagerGergő Tisza2016-08-091-6/+3
| | | | Change-Id: I2b2c9693a275fcc026916bd97f303e7a5c8df341
* Return error message in users API cancreate fieldGergő Tisza2016-05-301-2/+5
| | | | | | | That API field exposes AuthManager::canCreateAccount, where the error message is important. Change-Id: Idef441b311b94ff0cb6c4deaed1ac93959ee7ee8
* API changes for AuthManagerBrad Jorsch2016-05-161-1/+12
| | | | | | | | | | | | | | | | | | | | | | | Changes here are: * action=login is deprecated for use other than bot passwords * list=users will indicate if a missing user name is creatable. * Added action=query&meta=authmanagerinfo * Added action=clientlogin is to be used to log into the main account * action=createaccount is changed in a non-BC manner * Added action=linkaccount * Added action=unlinkaccount * Added action=changeauthenticationdata * Added action=removeauthenticationdata * Added action=resetpassword Bug: T110276 Bug: T110747 Bug: T110751 Bug: T32788 Bug: T67857 Bug: T28597 Bug: T76103 Change-Id: I244fa9b1e0623247d6d9fa30990411c6df94a496
* Convert all array() syntax to []Kunal Mehta2016-02-171-34/+34
| | | | | | | | | | 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: Flag "user" parameters in various modules as type 'user'Brad Jorsch2016-01-091-0/+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
* API: Allow querying central user infoBrad Jorsch2015-12-021-0/+9
| | | | | | | | | meta=siteinfo gets a list of all configured central ID lookup providers and which one is being used as the default, while meta=userinfo, list=users, and list=allusers get the ability to return the IDs and attachment status. Change-Id: Iea15b6c22baac79b3f8ca6df0e20a6a4299507d2
* ApiBase::PARAM_DFLT => null is the default anywayThiemo Mättig2015-10-051-1/+0
| | | | Change-Id: Ic3deeb6b3d7cacbdb85da9ba3cb19051c1182b8f
* API: Use message-per-value for apihelp-query+users-param-propumherirrender2015-08-061-1/+2
| | | | | | | | | | | Use message-per-value for message apihelp-query+users-param-prop to allow smaller strings for translation. Each prop in a message also will show up a new parameter on the help page without the adjust of the translation (but than in english instead of fully skip it). Change-Id: Ic467e2edc130018c61a30c61864f1f0de89540ff
* Cast various things that are supposed to be intsBrad Jorsch2015-05-061-2/+2
| | | | | | | | | | | | | Mysqli is returning SELECTed ints as strings rather than as ints, I'm guessing to avoid problems with 64-bit int types on 32-bit systems. PHP mostly doesn't care, but it causes API JSON output to have strings instead of ints all over the place. This also fixes ForeignAPIFile::getUser( 'id' ) returning the user *name*. Bug: T98276 Change-Id: Ie6591d72b3ac40172f8176a8ca8b6fad8e9275a5
* Change API result data structure to be cleaner in new formatsBrad Jorsch2015-04-201-6/+9
| | | | | | | | | | | 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-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* New convenience method ApiBase::lacksSameOriginSecurity()Ricordisamoa2015-02-271-2/+3
| | | | | | For consistent handling of API requests with the 'callback' argument. Change-Id: Ic6e3483f5e8819498c693650a11728efc1bafcc0
* 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-23/+3
| | | | | | | | | 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
* Remove ApiQueryUsers::getAutoGroups (deprecated 1.20)umherirrender2014-09-261-13/+0
| | | | Change-Id: Idb43eca139c3e63f8a53ef076b2dfa7c5e3941b5
* API: Add timestamp of block to blockinfoDerk-Jan Hartman2014-09-141-0/+1
| | | | | | | | | | | | | | This change affects list=allusers, list=users and meta=userinfo. Note: This change also add block expiry to meta=userinfo. Unlike this field in other modules, it formats the timestamp properly, instead of just dumping db contents. Resurrecting from abandoned change Ifdeac5c5f547 Bug: 63326 Change-Id: I4b3e55fe2d07271e1ded89d36d0b98de0e643177
* API: Overhaul token handlingBrad Jorsch2014-08-261-0/+3
| | | | | | | | | | | | | | | | | | | | 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-67/+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
* Use precise ApiMain/ApiQuery type hints in all API modulesThiemo Mättig2014-05-161-1/+1
| | | | | | | | | | | | | | | | | Which type is used depends on the ApiModuleManager responsible for the API module. There are two managers, one in ApiMain and one in ApiQuery. Both contain a list of API modules they instantiate. Both use $this as the first parameter in the constructors of the individual modules. There is no other regular way to instantiate the modules, so we know the type must either be ApiMain or ApiQuery. The lists don't intersect. I would have prefered the naming scheme $mainModule for ApiMain modules and $queryModule for ApiQuery modules but since this doesn't add much I left the shorter variable names untouched. Change-Id: Ie6bf19150f1c9b619655a06a8e051412665e54db
* Make users API cache mode public if blockinfo is not queriedGergő Tisza2014-04-221-1/+24
| | | | | | | | | | Blockinfo is currently the only piece of information (apart from tokens) in the users API which might change depending on the permissions of the user making the query. There is no point in making the API request uncacheable if blockinfo is not requested. Change-Id: I533f622b7d9077589f148fbb6de98b15ef1c212a
* Fixed some @params documentation (includes/api)umherirrender2014-04-181-4/+4
| | | | | | | | | Swapped some "$var type" to "type $var" or added missing types before the $var. Changed some other types to match the more common spelling. Makes beginning of some text in captial. Also added some missing @param. Change-Id: I758fa4ad80ac95e2ddd3770bcb9b7d2e57ec34ea
* Add final period to API module descriptionsaddshore2014-03-101-1/+1
| | | | Change-Id: Icae68c1ab1fd0006e00a3a9a56ae8f831d3d0d45
* Remove unneeded uses of else{} in api/Siebrand Mazeland2013-11-181-5/+1
| | | | | | | Fixed a little documentation issue, removed a line of unreachable code and fixed up two formatting issues in the process. Change-Id: If29391ee1a0daf19973437f36c3216b8716debd0
* Fix CodeSniffer errors and warnings on some API classesSiebrand Mazeland2013-11-151-1/+2
| | | | Change-Id: Id5fd7180f3a1d62663f79b27ad5108062607596a
* I'm in your API classes updating your formattingSiebrand Mazeland2013-11-141-4/+6
| | | | Change-Id: I6087573dfdc6edcd63062508056ebcf3502e03f2
* Make User::getEditCount() always return an integerJuliusz Gonera2013-07-181-1/+1
| | | | | | | | | The docs comment says it returns an int but it often returned a string. This led to casting this value into an integer in other parts of the codebase and in extensions (grep MobileFrontend or Echo for EditCount). Bug: 51633 Change-Id: I6fe5b26c24e674e8148c1fd278774b3fabe844c5
* Set context when using UserrightsPageumherirrender2013-05-241-0/+2
| | | | | | | SpecialPage::getContext called and $mContext is null. Return RequestContext::getMain(); for sanity Change-Id: Ie0ed360835164e8a4eb1c675ec8edd944ab95898
* Fixed spacing in api folderumherirrender2013-04-201-1/+1
| | | | | | | Added spaces before if, foreach Added some braces for one line statements Change-Id: Id7779dca4d1185245cf5764102b8de8b232c34b6
* Fix align of block commentsumherirrender2013-03-071-6/+6
| | | | Change-Id: I88ea33a125a71671886b49e4ebf4c1d0a1cce572
* Use 'email' instead of 'e-mail' in API texts.Alex Monk2013-03-021-1/+1
| | | | | Bug: 45633 Change-Id: Ieddc066be4051a20f0500b52e6b021e877d6c97d
* fix some spacingumherirrender2013-02-041-1/+1
| | | | Change-Id: I670a7baf3ba1e70d18346bb00938d518ba2063bd
* (bug 35885) remove api version string and parameterYuri Astrakhan2013-01-181-4/+0
| | | | | | | | | API was using SVN's version keyword which GIT does not support. All related methods were either removed, or for those that could have been used from extensions, emptied out. api.php?version now shows unrecognized param warning. Change-Id: I910ca1448ed2ed697ac19b17c486d130aa1d7e03
* Minor cleanupYuri Astrakhan2013-01-121-1/+1
| | | | | | Fixed spacing, eol chars, "string" --> 'string' Change-Id: I630247c6c5b469efb67ec9de32e8533ae88e59fb
* Fixup a couple of uses of return values of functions that return voidReedy2012-12-091-1/+1
| | | | Change-Id: I7c8f08c5b436cb3209fd98b9479a50abe223cccc
* Minor fixes to User and ApiQueryUsersMarius Hoch2012-11-091-1/+1
| | | | | | | | I've fixed several PHP notices and the problem that rights returned by User::getRights() might have duplicates if altered by a hook (same for User::getEffectiveGroups). Change-Id: Id92af387d8c09414076bac40e83052cd6f913f42
* Make action=query&list=users use User::getRights()Hoo man2012-10-241-24/+30
| | | | | | | | | | | | | | | | | | | | | | Made action=query&list=users use User::getRights() if usprop rights given. This not only removes redundant code, but makes it execute the UserGetRights hook, so that this now includes rights given by Extensions (eg. CentralAuth does that). Patch Set 2: Modified the User class to be able to inject further data into User::newFromRow() and using that to inject the groups taken out of one SQL query (for performance reasons). Furthermore I've split up the query in ApiQueryUsers.php into one for user data and one for the groups, to only have one row for each user. After all the perfomance of this should now be ok, not extremly good, but bearable (though I couldn't test it deeply, as I don't have much data in my CentralAuth environment). Change-Id: Ie5b2924abb82ac254c77e1d04cc4d5b308962dad
* Follow-up I0b781c11 (2a55449): use User::getAutomaticGroups().Alexandre Emsenhuber2012-08-031-11/+6
| | | | | | | | | | No need to duplicate the code of User::getAutomaticGroups() in ApiQueryUsers::getAutoGroups(), instead just call that method directly. Also deprecated the latter in favour of the former and replaced all calls in core. Change-Id: I224cb610cbd6a927a4c7f7137951416368f8cb5d
* Fix bug causing API to list anons as autoconfirmed in certain casesCatrope2012-08-021-1/+3
| | | | | | | | | | | | | | | | On a stock install, the autoconfirmed requirements default to zero, so anons qualify for autoconfirmed. They don't actually get it because User::getEffectiveGroups() only checks for autopromote groups for logged-in users. However, ApiQueryUsers::getAutoGroups() (which duplicates this logic for some reason) didn't use the same rule and applied autopromote groups to anons too, which caused discrepancies betwen the API output and wgUserGroups. Krinkle noticed this because a QUnit test for mw.user.getGroups() was failing while logged out: the API response included autoconfirmed but wgUserGroups didn't. Change-Id: I0b781c11e06d3cc7176b2fb3ba06979d3637f970
* escape HTML elements in docblock with double quotesAntoine Musso2012-07-151-1/+1
| | | | | | | | | | | | | | | | | | Doxygen choke on text enclosed by '<' and '>' since it tries to interpret them as HTML or XML elements. This patch adds double quotes in includes/api/*.php files around the two following strings: <Firstname>.<Lastname>@gmail.com <Firstname><Lastname>@gmail.com Which becomes: "<Firstname>.<Lastname>@gmail.com" "<Firstname><Lastname>@gmail.com" Tested locally, it prevents doxygen 1.8.0 related warnings. Change-Id: I36d82eb3fd4989ee3ffc65b0b527b83711d1ba69
* Added result properties to action=paraminfoPetr Onderka2012-06-061-0/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Added information about the properties of the results of API calls to action=paraminfo, including information about "property groups": what should the prop parameter be set to to get that property. Uses the same format for types as parameters already do. The output format of some modules doesn't fit this, so the result properties for them weren't added, or only partially. Partially implemented modules: * expandtemplates: parsetree is in its own tag * protect, allusers, backlinks, deletedrevs, info, imageinfo, logevents, querypage, recentchanges, revisions, searchinfo, usercontribs, userinfo, users, watchlist, upload: response with partially complex structure Not implemented modules: * feedcontributions, feedwatchlist, opensearch, rds: non-standard reponse * help: error is normal response; not very useful for automated tools anyway * paraminfo, parse, pageprops, siteinfo, userrights: response with complex structure Change-Id: Iff2a9bef79f994e73eef3062b4dd5461bff968ab
* user table: replace some '*' with explicit fields in selectsumherirrender2012-05-251-1/+1
| | | | | | It is good practice to select only fields, which are used later Change-Id: Iaaa252d594112894334a8ee9916007352d5bc4e7