aboutsummaryrefslogtreecommitdiffstats
path: root/includes/ServiceWiring.php
Commit message (Collapse)AuthorAgeFilesLines
* editpage: Refactor user right, rate limit and block checks to use AuthorityBartosz Dziewoński2025-04-051-4/+1
| | | | | | | | | | | | | | | | | | | | | Replace EditRightConstraint, UserBlockConstraint, and most of UserRateLimitConstraint with the new AuthorizationConstraint. Instead of many separate checks, everything is now handled by one authorizeWrite() call. Move 'editcontentmodel' rate limit to ContentModelChangeConstraint (by making it use authorizeWrite()). Keep 'linkpurge' rate limit in a separate check, renamed from UserRateLimitConstraint to LinkPurgeRateLimitConstraint, since the way it works in unusual and not portable to Authority without more refactoring in EditPage. AuthorizationConstraint needs some special handling to produce the idiosyncratic result codes required by EditPage, but luckily PermissionStatus gives us everything we need for that. Bug: T271975 Bug: T386346 Change-Id: Ic9f6f2fbd29efa3e349517013da540a363c263b5
* Merge "Migrate MediaWiki.jobqueue to statslib"jenkins-bot2025-03-261-2/+2
|\
| * Migrate MediaWiki.jobqueue to statslibAtieno2025-03-241-2/+2
| | | | | | | | | | | | | | | | This patch migrates the `MediaWiki.jobqueue` metric to the new Prometheus format. Bug: T359472 Change-Id: Ie1d54721a1849619fe9a33b74ad1c231868b1c26
* | Replace a number of uses of class aliases with the real thingsJames D. Forrester2025-03-261-0/+7
|/ | | | | | | 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
* Trigger $wgUsersNotifiedOnAllChanges emails via NotificationsPiotr Miazga2025-03-211-1/+5
| | | | | | | | | | | | | | | | | | Migrate the Admin ENotif notifications from EmailNotification into new MediaWiki Notifications system. We already migrated email rendering/composing logic away from EmailNotification class, therefore we can reuse the RecentChangeMailComposer class to compose and send emails. The Admin notifications have the smallest impact and let us verify readability of this approach. This PR introduces: - the MediaWiki Notifications handler responsible for handling Watchlist, UserTalk and Admin notifications - Base event class for RecentChange notification Bug: T387988 Change-Id: I2a9c1f63794ef32de2f0e912d6554e418985f58e
* Merge "notifications: Introduce Notification Middleware and ↵jenkins-bot2025-03-211-0/+9
|\ | | | | | | NotificationEnvelope"
| * notifications: Introduce Notification Middleware and NotificationEnvelopePiotr Miazga2025-03-211-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To allow ourselves esier processing/modifying Notifications lets introduce an idea of NotificationsEnvelope which represents a Notification being sent and list of recipients. The middleware approach will allow us to modify the Notification behaviour by letting extensions to inject/modify the Notifications. Each Middleware will retrieve a list of Envelopes MediaWiki wants to send. Middlewares should iterate over envelopes and decide if those want to add/remove/replace Notifications and/or Recipients. Bug: T387996 Change-Id: Ib3ee35c75b2f4dcfdc516b9259a852dc73c4a778
* | Namespace all remaining files in includes/loggingJames D. Forrester2025-03-191-0/+1
| | | | | | | | | | Bug: T353458 Change-Id: Ibe1810f1c71316a9124e1dc6ae405097dafd5267
* | Namespace all remaining files in includes/filerepoJames D. Forrester2025-03-191-0/+1
| | | | | | | | | | Bug: T353458 Change-Id: I35864ad9bd48701703c51367d62f8ebde963c52d
* | Fix uses of TempFSFileFactory's old class aliasJames D. Forrester2025-03-171-1/+1
| | | | | | | | | | | | | | Follow-up to 0fe5cc829ecfc7b0476d69821c446516483d24fe. Bug: T382910 Change-Id: I8bd2e5d5815f37944ec4bfc5f586701a1116069b
* | Fix expensive computations before cache hit and add additional caching to ↵Dylan F2025-03-161-1/+2
|/ | | | | | | | | | | 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 "GenderCache: Clean up optional/unused constructor params"jenkins-bot2025-03-111-1/+1
|\
| * GenderCache: Clean up optional/unused constructor paramsBartosz Dziewoński2025-03-101-1/+1
| | | | | | | | | | | | Depends-On: I81df79e5c036392d6c17589935f4420a5e4a387b Depends-On: I208c75db3b1049fa7cdd64a86ea8f08f02a67063 Change-Id: I209ad728f3033c19d6109fcc4a7fa425754f2bbb
* | language: Remove LanguageFactory dependency from MessageCacheTim Starling2025-03-101-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Now that MessageParser has been split out, MessageCache has no remaining calls to Language methods except for getCode(). The only non-deprecated usage of Language is as a parameter to the callbacks registered by the MessageCacheFetchOverrides hook. Review of all MessageCacheFetchOverrides handlers in Code Search shows that none are actually using the Language parameter. None of the closures even declare a third parameter. A Language object is a complex and inefficient way to pass a language code. So: * Revert the deprecation of string language codes in the language passed to MessageCache::get(). * Pass a string code internally instead of a Language object. * Relax the validation applied to string language codes, so that it is similar to LanguageFactory. Callers were often passing a Language object with a code like "qqx" which is not a known language tag, but is allowed as a parameter to LanguageFactory::getLanguage(). * Remove the third and fourth parameters to the override callbacks. * Remove the LanguageFactory constructor parameter. Depends-On: Ic4beec7373e799e51082957ab96d26e4c692c413 Change-Id: Ia9ddb1b83a6f20d3f7cee2afaf5987dbc99ea00b
* | Merge "DeletePage: emit PageDeletedEvent"jenkins-bot2025-03-101-0/+1
|\ \ | |/ |/|
| * DeletePage: emit PageDeletedEventdaniel2025-03-101-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Why: - We want to replace the PageDeletionComplete hook with an event - We want to validate our design for the hierarchical event type system and the modeling of page events. What: - Introduce PageDeletedEvent - Make DeletePage emit PageDeletedEvent - Move update triggers from DeletePage into ingress objects: - search index - message cache - module cache Bug: T379932 Change-Id: I01490fbaf33118eba109aa91908783117ba5aa20
* | user: Allow gender to be a global preferenceTim Starling2025-03-061-6/+13
|/ | | | | | | | | | | | | | | | | | | | | | | | 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
* Merge "block: DatabaseBlock constructor caller migration"jenkins-bot2025-03-041-0/+1
|\
| * block: DatabaseBlock constructor caller migrationTim Starling2025-03-041-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | language: MessageCache cleanupTim Starling2025-03-041-3/+3
|/ | | | | | | | | | | | | | | | | | * Make normalizeKey() be non-static, since it needs a service. No extension callers in code search. * Move MSG_CACHE_VERSION from a define() to a private const. * Improve comments. Remove excessively obvious comments. In getLocalCache() remove incorrect param doc. * Rename property cacheVolatile to isCacheVolatile. Rename two local variables containing the same concept to $isCacheVolatile. * Rename property clusterCache to mainCache. * Rename $volatilityOnlyStaleness to $isStaleDueToVolatility * Rename property disable to disabled. * Rename WAIT_SEC to LOCK_WAIT_TIME for consistency with LOCK_TTL. * Simplify load() by moving the debug message to disable(). * Separate words with camel case, space or hyphen. Change-Id: I43bbe1d747c9648b8c3e78579c788538a27f4cd6
* Split MediaWikiTitleCodecTim Starling2025-03-031-13/+11
| | | | | | | | | | | | | | | | | | | | | | | | For the linked bug, I would really like GenderCache to use UserOptionsManager. But all user-related services need UserNameUtils which depends on TitleParser, and TitleFormatter needs GenderCache to correctly format NS_USER titles. Having TitleFormatter and TitleParser together in a single class creates an intractable dependency loop. So, split MediaWikiTitleCodec. On Daniel's advice I converted the existing TitleParser and TitleFormatter interfaces to classes. The code was always structured to allow this. Extensions require surprisingly few updates. MediaWikiTitleCodec remains only for its deprecated static methods. The implementations were split cleanly with no need for shared code. The tests did have a little bit of shared code, for round-trip testing, so I added a shared test base class for that. Bug: T386584 Depends-On: Ibf307e953b666d8923bc96a507907421558da378 Depends-On: I47e83e95727e6830500e9af7cff92e7d3f91167e Depends-On: Id9c045864a9dc3c640a896e6b34f516c7e42b050 Change-Id: I3dcce6639ed01c7611a663671c872cec775bdaa2
* Merge "linker: Render expired temporary account names differently"jenkins-bot2025-02-251-1/+2
|\
| * linker: Render expired temporary account names differentlyMáté Szabó2025-02-201-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Why: - We would like to make the user links associated with expired temporary accounts visually distinguishable from non-expired ones using strikethrough styling and an information tooltip. - The designs call for using Codex tooltips for the latter. Using the Vue directive for this would require us to take a dependency on Codex and Vue for every page that renders user links, and render a small Vue.js app for each expired temporary user link, which does not seem practical. - We can, however, use Codex styles and implement our own simple tooltip functionality without taking on unnecessary dependencies. - This requires adding a new RL module to every page that uses userLink(), so we should update userLink() to do this for us instead of having to update every core and extension page that needs this. What: - Add a strikethrough to expired temporary account links as per the design specification. - Render a tooltip, hidden by default, for expired temporary account links that is styled using Codex styles. - Implement a simple jQuery tooltip handler for expired temporary account links. - Avoid caching expired temporary account link in UserLinkRenderer to ensure each of them receives a unique ID. - Add required ResourceLoader modules directly to the output in userLink(). Bug: T358469 Change-Id: I4f70ff15becbc4991c4f1b0307a14d5354c79dc1
* | Merge "LinkBatch: Introduce addUser() helper"jenkins-bot2025-02-251-0/+1
|\|
| * LinkBatch: Introduce addUser() helperMáté Szabó2025-02-201-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Why: - After I4f70ff15becbc4991c4f1b0307a14d5354c79dc1, it will become necessary to prefetch the expiration status of temporary accounts when rendering user links via UserLinkRenderer for a large list of users. - We would ideally like to accomplish this without requiring every user of UserLinkRenderer to take a direct dependency on TempUserDetailsLookup, which exposes this functionality. - Since most users of UserLinkRenderer / Linker::userLink() already use LinkBatch to prefetch page existence for the user and user talk pages that UserLinkRenderer will link to, encapsulating the TempUserDetailsLookup interaction within LinkBatch seems like a decent middle ground. What: - Add LinkBatch::addUser(), which takes a UserIdentity and adds its user and user talk pages to the batch while also triggering a batch lookup of expiration status for users added this way when execute() is called. Bug: T358469 Change-Id: Ic837961296cc4bf166dde79c7f073cc50ce925da
* | Merge "user: Introduce TempUserDetailsLookup service"jenkins-bot2025-02-211-0/+8
|\|
| * user: Introduce TempUserDetailsLookup serviceMáté Szabó2025-02-201-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Split MessageParser out of MessageCacheTim Starling2025-02-211-2/+12
|/ | | | | | | | | | | | | | | | | | | | | | | | | | MessageCache has enough to do without also being a parser. Split a MessageParser class out of MessageCache and make it a service. * MessageCache::parseWithPostprocessing() becomes MessageParser::parse() because every caller wants postprocessing so it makes sense to use the shorter name for this. * MessageCache::parse() becomes MessageParser ::parseWithoutPostprocessing(). I changed the return type from ParserOutput|string to ParserOutput, which is a followup to I8a1fa84e650d920d07d74722d8059d5afeedec6b. Narrowing the return type does not break b/c so it is possible to make this change for both variants. * In the new methods, a null title is always a convenience alias for a placeholder title (Special:Badtitle). This reflects the convention in Parser::setPage(). The old MessageCache::parse() retains its b/c fallback to $wgTitle. MessageCache::transform() had the potential to fall back to the title used in the previous call, a fragile mechanism which I removed without deprecation. * For consistency, allow a string language in all new methods. * In EmailNotification, clean up an early attempt at global state avoidance. Change-Id: I05ab21508d5f8394189fd41ac6a2254ac0e0d785
* block: Add a BlockTarget class hierarchyTim Starling2025-02-191-10/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Main change: * Add a class hierarchy representing block targets, representing a target and type. * Add BlockTargetFactory, replacing BlockUtils. * Add CrossWikiBlockTargetFactory, replacing BlockUtilsFactory. * Construct a BlockTarget object early in the request flow and pass it down through the layers, instead of having every layer interpret UserIdentity|string target specifications. Also: * Remove Block::TYPE_ID. Nothing uses it in code search, so there's no point in porting it to the new system. * Stop using the type constants as specificity scores. Add BlockTarget::getSpecificity(). * Add DatabaseBlockStore::newUnsaved() to replace direct construction of DatabaseBlock in insertBlock() callers. There are many such callers in tests. This is part of the effort to remove the service container usage in DatabaseBlock::__construct(). * Make DatabaseBlock::getRangeStart() and getRangeEnd() return null if the block is not a range, since that is convenient for their only caller following the resolution of T51504. * Add DatabaseBlock::getIpHex() which similarly maps to a DB field in the new schema. * In ApiBlock and ApiUnblock, have ParamValidator provide UserIdentity objects instead of converting to a string and back to a UserIdentity again. Bug: T382106 Change-Id: I2ce1a82f3fbb3cf18aa2d17986d46dbdcc70c761
* Merge "Hooks: Remove FauxGlobalHooksArray"jenkins-bot2025-02-181-8/+0
|\
| * Hooks: Remove FauxGlobalHooksArraydaniel2025-02-181-8/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Why: - $wgHooks should work like a regular configuration variable which cannot be modified after bootstrap. - FauxGlobalHooksArray was in place to trigger deprecation warnings for write access to $wgHooks since 1.40. What: - Remove FauxGlobalHooksArray and supporting code Bug: T331602 Change-Id: I8d881857850a906b893cf3066dcfbe277f9b0b14
* | Merge "Add a built-in way to send notifications"jenkins-bot2025-02-181-0/+9
|\ \
| * | Add a built-in way to send notificationsBartosz Dziewoński2025-02-121-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Create a provider pattern for sending notifications (T383992). There is no base notifications handler in core; they can only be provided by extensions. A handler in the Echo extension, compatible with the existing Echo notifications system, will be implemented in T383993. Co-Authored-By: Piotr Miazga <pmiazga@wikimedia.org> Bug: T383992 Change-Id: I16b309935c3d29c3cde4459b5e36abce063a8534
* | | block: Add $wgAutoblockExemptionsTaavi Väänänen2025-02-181-0/+4
| |/ |/| | | | | | | | | | | | | | | Add a new option to exempt users from autoblocks in the configuration, instead of editing a MediaWiki space page on every wiki. The use case for this is WMCS ranges (see T386689). Bug: T240542 Change-Id: I704b34b81214e7a1ac819fefa7ad3c2c87305647
* | linker: Introduce UserLinkRenderer serviceMáté Szabó2025-02-131-0/+9
|/ | | | | | | | | | | | | | | | | | | | | | | Why: - The TSP team would like to render user links for expired temporary accounts differently. - User links are currently rendered by Linker::userLink(), which is in need of some refactoring as documented in T308000 and elsewhere. - We should take this opportunity to clean up relevant code before implementing our temporary account-related changes on top. What: - Introduce a new UserLinkRenderer class and service, and move the functionality of Linker::userLink() to this class. - Soft-deprecate Linker::userLink() and have it delegate to the new service. - Move and expand related test cases. Bug: T358469 Bug: T308000 Change-Id: I974c4d92c5281067d53bb3bdc94eb0e290b7cadb
* Merge "Migrate MediaWiki.RateLimiter to statslib"jenkins-bot2025-02-111-1/+1
|\
| * Migrate MediaWiki.RateLimiter to statslibAndrea Denisse Gómez-Martínez2025-02-101-1/+1
| | | | | | | | | | | | | | | | This patch migrates the `MediaWiki.RateLimiter` metric to the new Prometheus format. Bug: T359367 Change-Id: Ic5098c9d9a2b7fd1aa4f7f6abde46ceb2cf58887
* | RenameUser: Introduce RenameUserJob to run rename jobxtex2025-02-111-1/+15
|/ | | | | | | | | | | | | | | | | | | | | 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
* PageUpdater: move more updates to ingress objectsdaniel2025-02-061-7/+3
| | | | | | | | | | | | This moves the following update logic out of DerivedPageDataUpdater::doUpdates into listeners for the PageUpdated event: - ResourceLoader: WikiModule::invalidateModuleCache to ResourceLoaderEventIngress. - TalkPageNotifications: TalkPageNotificationManager::setUserHasNewMessages to UserNotificationEventIngress. Bug: T378936 Change-Id: I5f2083b09d90cbd20abe2e8143a000dfc4d02aae
* WANObjectCache: trace basic operationsChris Danis2025-01-301-0/+1
| | | | | | | | | | | | Follows the instrumentation collected in Iab20f86139fd9388ccd881be28ed324b7f64c533 I'm not sure if including all the keys/checkKeys is useful, or if I should be performing some aggregation or other summary. Perhaps using determineKeyGroupForStats() ? Bug: T340552 Change-Id: I53dd29ad131a2d81312c64bdf68155d48144a364
* ObjectCacheFactory: use Tracer telemetryChris Danis2025-01-271-1/+2
| | | | | Bug: T340552 Change-Id: Ief4258ef6d46fb237837907c6ecb96bb3afe6d81
* Merge "Add faux service for SessionManager"jenkins-bot2025-01-201-0/+6
|\
| * Add faux service for SessionManagerGergő Tisza2024-11-111-0/+6
| | | | | | | | | | | | | | | | | | Make SessionManager accessible from the service container, to make manual debugging via shell.php more convenient (and also to allow getting a SessionManager instance in a future-proof manner). Change-Id: Iac1393ff5970cac76c9e7af22c2490cf737f8628
* | Merge "ConditionalDefaultsLookup: Move the hook call to the service itself"jenkins-bot2025-01-161-5/+2
|\ \
| * | ConditionalDefaultsLookup: Move the hook call to the service itselfMartin Urbanec2025-01-141-5/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As part of T383701, I am planning to add a new hook to the service, to allow extensions to modify ConditionalUserOptions. That hook would be cubersome to call from ServiceWiring. In order to maintain a single pattern, this patch refactors the service to contain the call. Bug: T383701 Change-Id: Idf5e84543f996a500a66c72b6bac97d188995de9
* | | Merge "Tag page creations of previously deleted page"jenkins-bot2025-01-141-0/+1
|\ \ \
| * | | Tag page creations of previously deleted pageKgraessle2025-01-141-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | adds a new tag in core titled mw-recreated to note when a new page is a recreation Bug: T56145 Co-Authored-by: Rockingpenny4 <rockingpenny4@gmail.com> Change-Id: Ib8ffe3fba73d0464f3fd353138456b07e7afc7d7
* | | | Merge "HttpRequestFactory: use Tracer telemetry"jenkins-bot2025-01-141-1/+1
|\ \ \ \
| * | | | HttpRequestFactory: use Tracer telemetryChris Danis2025-01-131-1/+1
| |/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | This will attach HTTP request spans to the Mediawiki-created span, instead of the Envoy-created span. Bug: T340552 Change-Id: Icf61c35468bce41fe3f7051221f2b81c55030166
* | | | Merge "DomainEventSource: introduce dispatch modes"jenkins-bot2025-01-131-2/+1
|\ \ \ \ | |/ / / |/| | |