aboutsummaryrefslogtreecommitdiffstats
path: root/includes/User.php
Commit message (Collapse)AuthorAgeFilesLines
* Add a central ID lookup serviceBrad Jorsch2015-12-021-5334/+0
| | | | | | | | | | | | | | | | Anything that wants to be "central" right now has to depend on CentralAuth, and then either can't work without CentralAuth or has to branch all over the place based on whether CentralAuth is present. Most of the time all it really needs is a mapping from local users to central user IDs and back or the ability to query whether the local user is attached on some other wiki, so let's make an interface for that in core. See I52aa0460 for an example implementation (CentralAuth), and Ibd192e29 for an example use (OAuth). Bug: T111302 Change-Id: I49568358ec35fdfd0b9e53e441adabded5c7b80f
* Skip User name->id cache on READ_LATESTGergő Tisza2015-11-201-1/+1
| | | | | | | This avoids mishaps when User::idFromName is called first without, then with READ_LATEST. Change-Id: I4ea723d9568f77d91a4ab3a9d963652cc00d6c89
* Update cached user ID after user is added to the databaseGergő Tisza2015-11-201-1/+2
| | | | | Bug: T119021 Change-Id: I5e0599d1d045b0389a7825fddc2b346e4cfd001d
* User: Migrate from foreign cache to global cache for UserRightsProxyTimo Tijhof2015-11-021-9/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | Avoid having one wiki access another wiki's local keyspace. Instead, use the global keyspace to share values across wikis. Also, imitating wfMemcKey from wfForeignMemcKey was semantically incorrect due to $wgCachePrefix having precedence. Most interfaces (e.g. UserRightsProxy, FileRepo, JobQueue etc.) only have access to the wiki id (dbname + prefix). The local cache configuration for wgCachePrefix is not and shouldn't have to be exposed. Start enforcing that local cache keys are left private and to share keys, one must use global keys. Global keys (prefixed with "global:") have their own space and we can use the wiki-id as regular key segment for keys about users. Also: * Expose a method to keep formatting of this key in one place. As it used used in many different places in core, as well as in CentralAuth. * Make use of wfWikiId() in getDefaultKeyspace() to avoid duplicating this logic. Change-Id: I58836a24b9e239f460ab489bd2fe8ced8259833c
* Disallow User::setPassword() on users not in databaseBrad Jorsch2015-10-301-26/+19
| | | | | | | | | | Change I2c736ad mostly removed the password handling from the User object, but left in a little password handling to preserve the existing ability to call $user->setPassword() before the user was actually added to the database. That ability is now removed. Bug: T47716 Change-Id: Id3d40742f2e2b197ad6facd149cc6350006bf289
* objectcache: Introduce IExpiringStore for convenient TTL constantsTimo Tijhof2015-10-281-3/+4
| | | | | | | Also consistently use self:: instead of BagOStuff:: for constants referenced within the BagOStuff class. Change-Id: I20fde9fa5cddcc9e92fa6a02b05dc7effa846742
* Migrate more callers away from $wgMemcAaron Schulz2015-10-261-5/+5
| | | | | | | Callers should use more expliciy lazy-loaded cache factory methods. Change-Id: Ifa0bf389720a09a931ee6466b993f787d83a09a7
* Remove unused fields from UserAaron Schulz2015-10-261-17/+4
| | | | Change-Id: Ib209747f1ebd1433969b13b1ecb86d3b57f9be9a
* Fix undefined variable in User::setNewpasswordBryan Davis2015-10-201-0/+5
| | | | | | Follow up to I2c736ad to fix use of undefined `$id` variable. Change-Id: I04bd9c1dd7e3e1e63b8008d02df91cfb1ad971a3
* Merge "Remove empty line comments"jenkins-bot2015-10-141-1/+1
|\
| * Remove empty line commentsumherirrender2015-10-141-1/+1
| | | | | | | | | | | | | | Remove empty line comments as found by the MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.EmptyComment sniff Change-Id: I5d694f7a7d3bc97e16300ba03c60ad17f3c912a5
* | User: Mostly remove password handlingBrad Jorsch2015-10-131-223/+260
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | AuthManager is coming, which will make it easier to add alternative methods of authentication. But in order to do that, we need to finally get around to ripping the password-related bits out of the User class. The password expiration handling isn't used anywhere in core or extensions in Gerrit beyond testing for expired passwords on login and resetting the expiry date on password change. Those bits have been inlined and the functions removed; AuthManager will allow each "authentication provider" to handle its own password expiration. The methods for fetching passwords, including the fact that mPassword and other fields are public, has also been removed. This is already broken in combination with basically any extension that messes with authentication, and the major use outside of that was in creating system users like MassMessage's "MediaWiki message delivery" user. Password setting methods are silently deprecated, since most of the replacements won't be available until AuthManager. But uses in unit testing can be replaced with TestUser::setPasswordForUser() immediately. User::randomPassword() and User::getPasswordFactory() don't really belong in User either. For the former a new PasswordFactory method has been created, while the latter should just be replaced by the two lines to create a PasswordFactory via its constructor. Bug: T47716 Change-Id: I2c736ad72d946fa9b859e6cd335fa58aececc0d5
* Change getCacheSetOptions() callers to use "Database"Aaron Schulz2015-10-051-1/+1
| | | | | | | * This is less verbose that DatabaseBase * Also add a few WAN cache doc comments Change-Id: I5b6de6d0ffa06753ea96c50b63db7dae796475dc
* Make WANObjectCache sets account for slave lagAaron Schulz2015-10-051-1/+1
| | | | | | | | | | | | | | * This gets lag information that is useful when the calling code is about to run queries that will have their results cached. * This is now used in place of trxTimestamp() for WANObjectCache set() and getWithSetCallback(). * The WAN cache will use a low TTL if the lag is too high to avoid caching stale data for weeks. * Bumped MAX_COMMIT_DELAY as nothing enforces it. Bug: T113204 Change-Id: I2a95b4088cff42d6e980351555f81a4b13519e24
* Add null to @return tags if a method can return nullThiemo Mättig2015-10-051-1/+1
| | | | Change-Id: I420998351663d92c4a101f61842e40591eebcd5f
* Made User::loadFromId() skip cache with READ_LATESTAaron Schulz2015-09-301-3/+3
| | | | | | | | * That flag is used for anti-dependencies and thus should never rely on cache Bug: T95839 Change-Id: I4ffc8325e55588ef649b96e7b90bc95282f765a9
* FauxResponse: Honor cookie options, and other cleanupBrad Jorsch2015-09-291-1/+1
| | | | | | | | | | | | | | | | | We have this nice class for unit testing cookie-setting, but the cookie-setting method ignores all the parameters! Fix that. Also provide accessors to check the entire set of cookie data, and the set cookies as a whole. While this does change the semantics of FauxRequest::getcookie() in that the name now needs to be prefixed, no extension in Gerrit uses this method so we should be fine. Also clean up the case of the setCookie and getCookie methods while we're at it. Since PHP method names are case-insensitive, this doesn't even break compatibility with extensions. Change-Id: Ib44a074bf9796bc0b470d557e39465792f399d30
* User::incEditCountImmediate(): Add explicit IS NOT NULL checkKevin Israel2015-09-291-1/+1
| | | | | | | | | | | | | | | | | | | Within the UPDATE query, if user_editcount IS NULL, user_editcount+1 will also be NULL, and the change becomes a no-op. So in MySQL, the number of affected rows would be zero, which is the number of rows that actually changed. However, other DBMSs (e.g. PostgreSQL, SQLite) do count no-op changes, meaning the code would not initialize user_editcount if it were NULL. Explicitly checking for NULL should ensure consistent behavior across database types. Also, if the CLIENT_FOUND_ROWS flag is set when connecting to MySQL, the server returns "Rows matched:" instead of "Changed:" as the affected row count. This change would be necessary if MediaWiki, like Drupal, is changed to use that flag <https://www.drupal.org/node/805858>. Change-Id: Idac160bae56adc5c5d17f8558c55d87000019741
* Added $opts to WANObjectCache::set() to detect snapshot lagAaron Schulz2015-09-281-1/+2
| | | | | | | | * This can avoid some stale write race conditions * Made use of this option in a few key places * HOLDOFF_TTL was also bumped Change-Id: I83505a59cce0119e456191c3100f7d97bc86bdbf
* Merge "Fixed sanity cache clear in User::saveSettings()"jenkins-bot2015-09-281-10/+18
|\
| * Fixed sanity cache clear in User::saveSettings()Aaron Schulz2015-09-281-10/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | * This works by adding a refresh mode to clearSharedCache() when we want to purge the cache in case it might stale to avoid further CAS errors. Because an exception will be thrown, the usual DB callback will not get fired, so avoid using commit hooks when doing these cache purges. * Also lowered the tombstone TTL for such purges, since no data actually changed. Bug: T114023 Change-Id: Iaad87b4ed24733dac40bc9607d3c97c940710087
* | Merge "Avoid CAS errors on double post to ApiOptions"jenkins-bot2015-09-281-6/+3
|\ \ | |/ |/|
| * Avoid CAS errors on double post to ApiOptionsAaron Schulz2015-09-241-6/+3
| | | | | | | | | | Bug: T95839 Change-Id: I62f8eea31164be1ab0eacf31c494f0b296b367f2
* | Fix issues identified by SpaceBeforeSingleLineComment sniffVivek Ghaisas2015-09-261-11/+11
| | | | | | | | Change-Id: I048ccb1fa260e4b7152ca5f09b053defdd72d8f9
* | Updated key WANObjectCache::delete() callers to avoid racesAaron Schulz2015-09-261-3/+7
|/ | | | | | | | | * They now issue the delete() write before COMMIT of the relevant DB (or immediately if no trx is active) * This can avoid some stale write race conditions * Updated the WAN cache delete() docs Change-Id: Id54887976051120b76528070d5f2ceb357d57897
* Fix PHP notice when logging the result of a DNS blacklist check.Skizzerz2015-09-231-2/+4
| | | | | | | | When the array syntax is used for the DNS blacklist, PHP throws a notice about array to string conversion. This change ensures that the correct string name is used regardless of what type of blacklist entry is used. Change-Id: I2511a8320474a02d8f321d04f005bb9d18fb15b3
* Add the performer to the UserRightsChanged hookKunal Mehta2015-09-221-1/+1
| | | | | | | | This allows extensions (e.g. Echo) to detect who made the change without relying upon $wgUser. It also allows for differentiation between autopromotion entries which will pass in `false` as the performer. Change-Id: Idebd78b54dcea1bdc84c83f402e87b240ab4ade1
* Merge "Add new authentication-related hooks (and remove one) replacing some ↵jenkins-bot2015-09-221-1/+3
|\ | | | | | | AuthPlugin methods"
| * Add new authentication-related hooks (and remove one) replacing some ↵Brad Jorsch2015-09-181-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | AuthPlugin methods * LocalUserCreated: Replaces AuthPlugin::initUser() * UserGroupsChanged: Replaces AuthPlugin::updateExternalDBGroups() ** The similar UserRights hook is deprecated, mainly to get rid of the passing of $user by reference. * UserIsHidden: Replaces AuthPluginUser::isHidden() * UserIsLocked: Replaces AuthPluginUser::isLocked() * UserLoggedIn: Replaces AuthPlugin::updateUser() Also, AuthPlugin::updateExternalDB() is deprecated in favor of the existing UserSaveSettings hook. Also, 'ResetSessionID' has been removed. Nothing uses it, I don't know why I even added it in the first place. Also, replacing the User object passed to AuthPlugin::initUser() and AuthPlugin::updateUser() will now raise a warning. Change-Id: If7474cfb26a29b11c2e78147069419ca3b1cba95
* | Merge "Use User::equals() where applicable in the class"jenkins-bot2015-09-181-1/+1
|\ \ | |/ |/|
| * Use User::equals() where applicable in the classMichał Roszka2015-09-181-1/+1
| | | | | | | | | | | | It is a minor cleanup operation. I replaced a comparison of user 'mId' with a corresponding 'User::equals()' call. Change-Id: I89dea55789f343e794429c38934c263168ef608d
* | Removed clearSharedCache() hack in User.phpAaron Schulz2015-09-081-8/+0
| | | | | | | | | | | | * WAN cache key salting/tombstones makes this overkill now Change-Id: I078daacc5d2987858d720677f11e9828d71021e2
* | Merge "Default the "watchlisttoken" value to a derived HMAC value"jenkins-bot2015-09-081-5/+10
|\ \
| * | Default the "watchlisttoken" value to a derived HMAC valueAaron Schulz2015-09-031-5/+10
| |/ | | | | | | | | | | | | | | | | | | | | | | * This got created if unset on API or GUI preferences access, which leads to writes on GET requests. Try to avoid that deriving it from user_token, unless overriden. This also means that changing the password always resets the key, which is how these things work on most sites anyway. * The whole getTokenFromOption() method is deprecated, and this functionality is already in OAuth. Bug: T92357 Change-Id: I96c0d6f6e535e67545049f01205430249eea8da0
* / Avoid some unused parameter IDEA errors in User.phpAaron Schulz2015-09-041-4/+4
|/ | | | Change-Id: I75e56ab02af6aee5dbed1735ae8a3a415094508d
* Optimized notification timestamp clearingAaron Schulz2015-08-121-1/+1
| | | | | | | | | | | * Hint that mariadb can avoid scanning already NULL rows since we want to set them all to NULL. This lets the index with the timestamp be used, which avoids logs of scanning for users with many rows. For non-parallel replication, this also avoids slave lag in particular. Bug: T107923 Change-Id: I8cded5476ef6adb2f8fea57239afd6e9b2a49708
* Make Special:ConfirmEmail load the user from the masterAaron Schulz2015-08-041-11/+16
| | | | | | | * This can help guard against stale reads if the user was created or changed a second ago. Bug: T105896 Change-Id: Ib2a59762cd8f4a4b7ad86d0700f186bee1d5b2d1
* Fixed missing space in User CAS exceptionAaron Schulz2015-07-231-1/+1
| | | | Change-Id: Ibb34a3bd33c1eb92a2e2787a7e2402615ef02ccd
* Clean up UserMailer::send() parametersKunal Mehta2015-07-201-1/+3
| | | | | | | | $replyto and $contentType should now be passed as an array of $options. This will make it easier to add more options in the future without having a long list of optional parameters. Change-Id: I2c38bb438bd01e0ed2552024a40311f3e8e2dc08
* Defer user_newtalk updates in clearNotification() to post-sendAaron Schulz2015-07-171-11/+16
| | | | | | | | * Also only issue DELETE if notifications exist. Previously, this would issue a DELETE for all self talk page views. Bug: T92007 Change-Id: Ifef11c9e5175d68d9615e59e2ed7de2f2c57bde1
* Merge "Tweaked User::READ_LOCKING to use LOCK IN SHARE MODE"jenkins-bot2015-07-161-6/+4
|\
| * Tweaked User::READ_LOCKING to use LOCK IN SHARE MODEAaron Schulz2015-07-141-6/+4
| | | | | | | | | | | | | | * This better alignes with IDBAccessObject docs and still locks out INSERTs Change-Id: Ib8713938e0afa14bee6f90bc51d6331eaf356447
* | Merge "Upgraded User::saveSettings logged errors to exceptions"jenkins-bot2015-07-151-4/+2
|\ \
| * | Upgraded User::saveSettings logged errors to exceptionsAaron Schulz2015-07-101-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | * This gives more visibility and the error rate is not extreme (and mostly affects certain users due to usage patterns). Change-Id: I3eae28a584e4db8ae40ae80087a97c416b3bd3e8
* | | Merge "Fixed User class IDE warnings"jenkins-bot2015-07-151-34/+36
|\ \ \
| * | | Fixed User class IDE warningsAaron Schulz2015-07-131-34/+36
| | | | | | | | | | | | | | | | Change-Id: I68c30fd81a266aa1acdf74162bfa864b67922347
* | | | Add "purpose" to password validity checkcsteipp2015-07-141-2/+3
| |_|/ |/| | | | | | | | | | | | | | | | | | | | | | | Allow callers to specify why they are checking a passwords validity, so some checks can be modified. Only check the default policy on creation, since the account doesn't exist it's not a member of any groups. Bug: T104615 Change-Id: I56b66002562aaa1493d94a90309bc8e4ae3841c8
* | | Revert "Add 'AuthPluginStrict' log to identify users who are unable to ↵Legoktm2015-07-131-1/+0
|/ / | | | | | | | | | | | | | | | | | | | | authenticate" Does not work as it will also log failed login attempts due to a wrong password. This reverts commit 9a97a7530f2a637cbb95603cfa4e0b51da753207. Change-Id: I6abd19da4e6939315a7fe6f7debe5227b68d38a7
* | Add 'AuthPluginStrict' log to identify users who are unable to authenticateKunal Mehta2015-07-131-0/+1
| | | | | | | | | | | | | | To be able to identify any users who are unable to log in when switching from allowing local authentication to strict. Change-Id: I2ebdccdad9c7794d1c1b13db6a646a43bc770c4e
* | Merge "Made the prior user existence check in LoginForm use DB_MASTER"jenkins-bot2015-07-111-3/+13
|\ \