aboutsummaryrefslogtreecommitdiffstats
path: root/includes/user
Commit message (Collapse)AuthorAgeFilesLines
* Use type declaration on undocumented private functionsUmherirrender2025-04-021-1/+1
| | | | Change-Id: I0d8d2237500ed6f18439410c902d47c42e4119bc
* Replace a number of uses of class aliases with the real thingsJames D. Forrester2025-03-263-0/+6
| | | | | | | Found via disabling phan's alias support for a run (and ignoring wgLang's hard-coded state of being a \Language, alas). Change-Id: I4753bcd84d72d6de111fc7ffc5841fa417bf7333
* Namespace all remaining files in includes/skinJames D. Forrester2025-03-251-1/+1
| | | | | Bug: T353458 Change-Id: I3e829e35c93bcaae75e401b1801bddf93c0b416c
* Namespace all remaining files in includes/exceptionJames D. Forrester2025-03-253-3/+3
| | | | | | | | | In MediaWiki/Exception, to follow PSR-4 per plural vs. singular (this can be changed later if people really care). Also, move the couple of exceptions in here that were already namespaced in the MW-top-level into the new space. Bug: T353458 Change-Id: I12ed850ae99effb699a6d7ada173f54e72f0570e
* Namespace all remaining files in includes/jobqueueJames D. Forrester2025-03-202-2/+2
| | | | | Bug: T353458 Change-Id: I95690a312e356c45dbeed607d32fb0e4626690cf
* Namespace all remaining files in includes/loggingJames D. Forrester2025-03-191-1/+1
| | | | | Bug: T353458 Change-Id: Ibe1810f1c71316a9124e1dc6ae405097dafd5267
* Fix expensive computations before cache hit and add additional caching to ↵Dylan F2025-03-163-30/+52
| | | | | | | | | | | DefaultOptionsLookup * Moved getCacheKey to UserOptionsLookup * Added caching to DefaultOptionsLookup after conditional options * Move expensive getDefaultOptions to after cache miss Bug: T386883 Change-Id: I307e1d30e84396b56d919993aef4d411ecae8ea1
* Merge "Avoid trying to load the session user in MW_NO_SESSION endpoints"jenkins-bot2025-03-111-0/+10
|\
| * Avoid trying to load the session user in MW_NO_SESSION endpointsGergő Tisza2025-03-101-0/+10
| | | | | | | | | | | | | | | | | | | | | | Trying to load the session user in an MW_NO_SESSION resulted in an exception thrown from SessionManager::getSessionFromInfo(), but User::$mLoadedItems has been set by that point, so if something catches the exception, future attempts to access that user object would result in unexpected behavior. Bug: T388066 Change-Id: Ia3f6d0a96209471db3ce1baf6870a57e1cf1b6b2
* | user: Allow gender to be a global preferenceTim Starling2025-03-066-1/+118
|/ | | | | | | | | | | | | | | | | | | | | | | | GenderCache gets the "gender" user preference directly out of the core database. Thus it does not respect global preferences. So: * Add UserOptionsLookup::getOptionBatchForUserNames(), which gets a single user preference for a set of named users. * Add UserOptionsStore::fetchBatchForUserNames() as a backend. This is a new interface method so is a breaking change. * Have GenderCache call the new interface. The no-database case in ServiceWiring is apparently no longer reachable from the installer due to my previous patch which split MediaWikiTitleCodec. Performance generally degrades from one query to three. For change lists and user page namespace redirects, it shouldn't be a problem, but for the {{GENDER}} parser function there may be a user-visible performance degradation. Bug: T386584 Depends-On: Id02489a597f96cd1cd6db08e16b3624542fdf1f7 Change-Id: I9646b5422afce356e9a1dceeb09d8d4e286dc65e
* user: Add filtered versions of CentralIdLookup::lookupUserNamesTim Starling2025-03-062-7/+105
| | | | | | | | | | | | | | | | * Add a batch version of CentralIdLookup::isOwned(), to support the linked bug. * Add test. * Fix error in LocalIdLookupTest::provideIsAttachedShared() which failed to provide the shared case due to an incorrect loop bound. This test has been non-functional since it was introduced in 2015. * Fix error in LocalIdLookupTest::newLookup() which failed to override the config. Bug: T386584 Depends-On: Ie63ed1f14c9ba4f9cefcceef05d5585a6676f111 Depends-On: I83716f7930bd0d2de4761cc5b04d9d3ff4172da2 Change-Id: I99dd733547f46e635c2f363166ce111e76e06a5e
* user: Add CentralIdLookup::FILTER_ constantsTim Starling2025-03-061-0/+4
| | | | | | | | | Add constants to be used in the subsequent commit, so that the CentralAuth implementation can be merged before the abstract method is introduced. Bug: T386584 Change-Id: If7ee55e0a26546429cc92ec3adf9ba86325bc49d
* Merge "Re-apply "Drop all 49 remaining class_aliases from MediaWiki 1.40""jenkins-bot2025-03-052-6/+0
|\
| * Re-apply "Drop all 49 remaining class_aliases from MediaWiki 1.40"Daimona Eaytoy2025-03-052-6/+0
| | | | | | | | | | | | | | | | | | This reverts commit 1695950bccb1ca7eba98952753708ae7c4b76d8d and re-applies commit I8f3c2ea021d0f6e. Reason for revert: the remaining usages have been updated in Ida665f486eff384. Bug: T166010 Change-Id: I43f06e6872b264e43aef7fa7c2ac47159926a694
* | Merge "Revert "Drop all 49 remaining class_aliases from MediaWiki 1.40""jenkins-bot2025-03-042-0/+6
|\|
| * Revert "Drop all 49 remaining class_aliases from MediaWiki 1.40"Ahmon Dancy2025-03-042-0/+6
| | | | | | | | | | | | | | | | | | This reverts commit db47e7f7154a2121bce6d3d9e93a74486bf765f3. Reason for revert: Broke scap sync-world in beta, and possibly caused T387938 Bug: T166010 Change-Id: If608c3e27081bb36b284ad16a5b912dd51b3557e
* | Merge "Drop all 49 remaining class_aliases from MediaWiki 1.40"jenkins-bot2025-03-042-6/+0
|\|
| * Drop all 49 remaining class_aliases from MediaWiki 1.40James D. Forrester2025-03-042-6/+0
| | | | | | | | | | | | | | Bug: T166010 Depends-On: Iba93dd9749656e641c427e01790d7a14cd1a2dc2 Depends-On: I97ccc2c49ce09ca96192bf6ffdc833c1765c3faa Change-Id: I8f3c2ea021d0f6e574dde901f0bfd4a0408f5455
* | block: DatabaseBlock constructor caller migrationTim Starling2025-03-041-1/+2
|/ | | | | | | | | | | | | | | | | | | | | | | | | | There's about 100 callers of the DatabaseBlock constructor in core tests, most of them passing an address parameter which needs access to the global service container to parse. Many are passing the constructed object straight to DatabaseBlockStore::insertBlock(). So add insertWithParams() for their convenience, which has some handy shortcut parameters, has service access, and throws on failure. The calling code tends to be shorter than before. For unit tests trying to construct DatabaseBlock objects without a service container, direct construction of BlockTarget subclasses is warranted. Add a default to the $wikiId parameters for their convenience. MockBlockManager had its own 'target' parameter, mixed in with block options, carrying its own special idea of a target, which conflicted with DatabaseBlock's new 'target' parameter. Harmonise the parameters and fix the callers. Bug: T382106 Bug: T385966 Change-Id: I78b45a6003b62962211379c36da5587081f90f00
* Merge "UserGroupManager: Consistently format parameters in hook call in ↵jenkins-bot2025-03-031-1/+2
|\ | | | | | | addUserToAutopromoteOnceGroups"
| * UserGroupManager: Consistently format parameters in hook call in ↵Reedy2025-03-011-1/+2
| | | | | | | | | | | | addUserToAutopromoteOnceGroups Change-Id: I13fd30654fe56fb4417a1eab76137a2c891179f1
* | Replace remaining gendered pronounsTacsipacsi2025-03-021-1/+1
|/ | | | | | | | | | | | | | | | | | | | | | To respect all genders, fix comments to not assume users use binary pronouns (or even that users are “he”s), but rather use singular “they”. Also fix some typos that happened to result in gendered pronouns, and a few incorrect commas and missing articles in comments near the fixed pronouns. I skipped four files: - HISTORY – the release notes were made with the wording they were made with, I’m not sure if rewording them afterwards is okay - tests/phpunit/data/preprocess/All_system_messages.{txt,expected} – these are test cases generated from somewhere, I’d regenerate them rather than updating - languages/i18n/qqq.json – fixed on Translatewiki instead to make their edit histories more useful Bug: T387626 Change-Id: I282406a0e1407be548e917735fe7eb9a6bf8b136
* Hard-deprecate User::getGlobalBlockDreamy Jazz2025-02-281-0/+1
| | | | | | | | | | | | | | | | | | Why: * User::getGlobalBlock is no longer used in WMF deployed code after the merging of d4d993be5c1ce6ac9f3b88ff651b8e89334bc852 for T363185. * We can now hard deprecate the method per the stable interface policy. ** Doing this is needed so that we can remove the method in the next MW release. What: * Add a wfDeprecated call in User::getGlobalBlock to cause deprecation warnings, making it hard deprecated. Bug: T387574 Change-Id: I880f2c1e833823bf1ac08d6744d638ad342821cb
* Merge "Revert "user: Make UserArrayFromResult::$current protected""jenkins-bot2025-02-261-2/+1
|\
| * Revert "user: Make UserArrayFromResult::$current protected"Thiemo Kreuz (WMDE)2025-02-251-2/+1
| | | | | | | | | | | | | | | | | | | | | | This reverts commit 7d13edebd6ac9fd4d40cb91378dfd4254f6e4d11. Reason for revert: Not needed any more. Now properly fixed in the CentralAuth subclass. Bug: T387148 Change-Id: I763f68fa8a9d2da7ac108987c46c0d7207595e72 Depends-On: I7f12fd1aad54bd6a423a77b77e301dd8f515f969
* | Merge "user: Add UserOptionsManager::GLOBAL_CREATE"jenkins-bot2025-02-241-9/+38
|\ \ | |/ |/|
| * user: Add UserOptionsManager::GLOBAL_CREATETim Starling2025-02-241-9/+38
| | | | | | | | | | | | | | | | | | Provide an interface allowing extensions to add global preferences. Add test for all the $global values. Bug: T386592 Change-Id: Id982656e228efaa97068b90f5137a0495c86fae5
* | user: Make UserArrayFromResult::$current protectedDaimona Eaytoy2025-02-241-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | The property used to be public, but it was made private in Id90b6838429eca4b. Unfortunately, CentralAuth extends this class and references the `$current` property directly. So, make it protected and add a note about CentralAuth being naughty, to prevent this from happening again. Follow-up to Id90b6838429eca4b. Bug: T387148 Change-Id: Ie65381a4fe642ba79f7b845c448e9731dc22647a
* | Merge "Code cleanup in UserArray & UserArrayFromResult"jenkins-bot2025-02-242-40/+18
|\ \
| * | Code cleanup in UserArray & UserArrayFromResultthiemowmde2025-02-242-40/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Just a few modernizations, utilizing more recent PHP features. Notable: * Much more strict language-level types. E.g. it's not allowed to call newFromNames with a single string any more. (Was never allowed and doesn't make any sense anyway.) * Drop unnecessary @covers tags in the test for the reasons explained in I2678992. Motivated by I15d9134. Depends-On: Ia88a8e724bb35781286528fa6403b2fe8ee3cfab Change-Id: Id90b6838429eca4bd662546e89fb1a91a8ae7c4f
* | | user: Avoid array_fill_keys in fetchRegistrationBatchUmherirrender2025-02-221-5/+3
| |/ |/| | | | | | | | | An array is already filled to get unique values, reuse the array. Change-Id: If662794e8fd84359e8eb07c0b7ba09043fd68a62
* | user: Introduce TempUserDetailsLookup serviceMáté Szabó2025-02-201-0/+96
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Why: - The TSP team would like to adjust the rendering of user links associated with temporary accounts, depending on whether the temporary account is expired. - This requires a mechanism to efficiently retrieve the expiration status of temporary accounts, even when rendering large lists with many user links, e.g. Special:RecentChanges or page histories. What: - Introduce the TempUserDetailsLookup class and service that holds the expiration status of temporary accounts in an in-memory LRU cache. This uses the new UserRegistrationLookup::getFirstRegistrationBatch API. - Provide a preloadExpirationStatus() method, similar to GenderCache or LinkBatch, that allows callers to prefetch expiration status for a batch of users. A followup patchset will add these to pagers as needed. Bug: T358469 Change-Id: I98ec17046c0863878eba3768d83f083bc2753e6f
* | Merge "Remove deprecated UserOptionsManager methods"jenkins-bot2025-02-201-60/+0
|\ \
| * | Remove deprecated UserOptionsManager methodsTim Starling2025-02-181-60/+0
| | | | | | | | | | | | | | | | | | And clean up related code and comments. Change-Id: I3932725de5a732cbdab1c0a7db3ea26965d563fc
* | | Merge "Disallow setting passwords for temporary accounts"jenkins-bot2025-02-191-2/+7
|\ \ \
| * | | Disallow setting passwords for temporary accountsDreamy Jazz2025-02-191-2/+7
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Why: * Temporary accounts are automatically created when a user makes an edit, and therefore do not have a password set by the user who created the temporary account * Currently, there is no limitation that prevents a password being set for a temporary account. ** This means that the createAndPromote.php maintenance script can set a password for a temporary account or create a new temporary account with a specified password. * A temporary account having a password allows a user to login to the account, even after the account has expired. ** This should not be allowed, and as such we should reject any attempts to set or change the password for a temporary account. What: * Update User::checkPasswordValidity to reject any password provided if the user matches the temporary account name format. * Add tests for this. Bug: T386775 Change-Id: I5354d240678fca9dbf3ed699370cf1a4df96b2f9
* / / user: Implement batch user registration lookupsMáté Szabó2025-02-193-1/+80
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Why: - The TSP team would like to change the way expired temporary account user links are displayed, which requires an efficient way to fetch their registration timestamps. - On WMF wikis, which use CentralAuth, this requires fetching the first (i.e. global) registration timestamp of the account, rather than the naïve approach of using the registration timestamp from the local user table. - MediaWiki provides the UserRegistrationLookup facade to transparently fetch the earliest registration timestamp for a single user, but offers no batch interface to do the same. - Since user links are often rendered in large pagers, a batch interface is needed. What: - Add IUserRegistrationProvider::fetchRegistrationBatch(), which takes an iterable of UserIdentities and returns a map of their registration timestamps (or null if not available), keyed by user ID. Although this interface is marked as stable to implement, its sole non-core implementor according to codesearch is CentralAuth. - Add UserRegistrationLookup::getFirstRegistrationBatch(), which delegates to fetchRegistrationBatch() on configured registration providers and returns the earliest registration timestamp for each user in the batch. - To avoid potential interface incompatibility in WMF production, this depends on CentralAuth implementing the new IUserRegistrationProvider method first. Bug: T358469 Depends-On: Ibe28163e962161567d486607e36d999a36a1e604 Change-Id: I1f6af2693a8f0c5c854b8a6b04edd1eb21934007
* | Merge "user: Use TS_MW to compare timestamps in UserRegistrationProvider"jenkins-bot2025-02-132-12/+12
|\ \
| * | user: Use TS_MW to compare timestamps in UserRegistrationProviderUmherirrender2025-02-132-12/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It is valid to use TS_MW for chronological compare as the timestamp stored in a string is ordered from the most significant datetime information (year) to the lowest (seconds). It is not needed to convert to unix. It would not be valid to use TS_MW format to calculate time differents. This is how it is used in the database schema from mediawiki as well. Also replace array + min() with variable + if. Change-Id: Id41e660f3952876e20ac4e88502d7e2757299573
* | | Merge "Replace call_user_func with dynamic function call"jenkins-bot2025-02-131-1/+1
|\ \ \ | |/ / |/| |
| * | Replace call_user_func with dynamic function callUmherirrender2025-02-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Use modern php syntax to call a callable. Reduce the stack trace to improve performance and better IDE and static analyzer support Change-Id: I9ef131032a662a3b8db69aa7079dbd51f88f575a
* | | Merge "Replace a few misplaces is_object checks"jenkins-bot2025-02-122-2/+2
|\ \ \
| * | | Replace a few misplaces is_object checksthiemowmde2025-02-122-2/+2
| | |/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | is_object is very rarely what we actually need. In many cases we know exactly what the object can be, and should check for that specific class or for null. A database row is an instance of stdClass. Checking that with is_object also works but is less correct and would allow stuff we cannot accept in these places. Change-Id: I1dc663d7325cabc059ef11c4845b0189208e907f
* | | Merge "user: Use TS_MW to compare timestamps in ConditionalDefaultsLookup"jenkins-bot2025-02-121-4/+1
|\ \ \ | |/ / |/| |
| * | user: Use TS_MW to compare timestamps in ConditionalDefaultsLookupUmherirrender2025-01-111-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It is valid to use TS_MW for chronological compare as the timestamp stored in a string is ordered from the most significant datetime information (year) to the lowest (seconds). It is not needed to convert to unix. It would not be valid to use TS_MW format to calculate time differents. This is how it is used in the database schema from mediawiki as well. Bug: T378764 Change-Id: Ifc8dbc0a87d286fb63f200b1f255cb11cc70b1f3
* | | Merge "UserArray: Return UserArray for the empty cases too"jenkins-bot2025-02-121-10/+10
|\ \ \ | |_|/ |/| |
| * | UserArray: Return UserArray for the empty cases tooBartosz Dziewoński2025-02-111-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, if we couldn't make a database query, the method returned an empty ArrayIterator instead of an empty UserArray, which precluded using native PHP type hints (or could cause type errors if they were used). But we can easily use an UserArray, so let's do that. Change-Id: I15d9134d9a157af22f07ab4df5d7a645f14a6fe9
* | | RenameUser: Introduce RenameUserJob to run rename jobxtex2025-02-111-0/+9
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | RenameUserJob is moved to Job/RenameUserTableJob because there are two kinds of jobs now. The newly added RenameUserDerivedJob is used for performing user-renames across a wiki family using virtual domains or shared tables. Most code are moved from SpecialRenameUser and maintenance/renameUser. The new service, RenameUserFactory is added for constructing RenameUser easier. When a global rename happen, the central wiki will enqueue RenameUserDerivedJobs for other wikis in the same family. The derived jobs will check if the central wiki has the same user table as local, and perform updates to local tables. A new user-right 'renameuser-global' is also added because wiki families may want global users to be renamed only by a limit set of users or on a certain global wiki. Bug: T104830 Change-Id: Ic4120cbd9a4850dfe22d009daa171199fe7c5e39
* | Remove 2-line PHPDocs that just repeat the types from the codethiemowmde2025-01-1711-48/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Same as Ia294bf4 did for 1-line comments. This patch removes slightly more complex 2-line PHPDoc comments that don't add any new information to the code, but literally repeat what the code already says. They say "don't document the code, code the documentation", and we are doing this more and more. We just tend to forget to remove the obsolete comments. Note I'm also removing a line of text in a few cases when it's very short and literally says the same as the method name. Again, such comments add zero new information. Change-Id: I01535404bab458c6c47e48e5456403b7a64198ed
* | Merge "Remove trivial 1-line PHPDocs that just repeat the code"jenkins-bot2025-01-163-12/+1
|\ \