A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://phabricator.wikimedia.org/T388663 below:

⚓ T388663 Instead of calling Event::create() extensions should use MediaWiki notification system

The interface for triggering new notifications via the Echo extension using Event::create( array $info ) is being deprecated. Developers should now use the newly built Notification service, implemented in T383992, to trigger notifications. The New interface provides type safety and triggers NotificationMiddleware (T387996) to manage the notifications (filtering/decorating/replacing).
With MediaWiki being responsible for triggering notifications, there is no need to check whether the Echo extension is present (as calling Event::create() might cause PHP Fatal error when Echo extension is not present/loaded). Additionally MediaWiki notification system provides a way to register new Notification handlers, which could be used to delivery Notifications via channels other than Echo.

Change Details:

• The legacy method of triggering notifications by calling Event::create( array $info ) is now deprecated.
• Developers must transition to using the new Notification service, introduced in T383992, for all new notification triggers.
• This change is part of ongoing efforts to modernize and unify notification delivery in MediaWiki, providing a more robust and maintainable API for extension developers.

Migration Steps

• Review the MediaWiki documentation for up-to-date instructions on how to use the new Notification service:
https://www.mediawiki.org/wiki/Manual:Notifications
• Update any code that directly calls Event::create( $info ) to use the new Notification service instead.
• Refer to the migration guide and examples provided in the linked documentation to ensure compatibility and best practices.

Both Echo interface and new NotificationService are similar, instead of calling

Event::create( [ 'type' => 'notification_type', ... ] );

you need to call:

$this->notifications->notify(
	new WikiNotification( 'notification_type', $title, $user, $possibleAdditionalParams  ),
	new RecipientSet( $recipient )
);

An example of migration: https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Thanks/+/1108513/18/includes/Api/ApiCoreThank.php

Note - the first argument of notify() method is a MediaWiki\Notification\Notification instance. We provided multiple definitions like

You may need to implement your own notification type - this will allow you to type the parameters. For a MediaWiki code example, please refer to MediaWiki\Watchlist\RecentChangeNotification.

Rationale:

This deprecation ensures that all notifications are triggered through a unified, well-documented service, improving maintainability and user experience across MediaWiki installations. The new Notification service is designed to provide a consistent API for all notification types.

For further details, see the project documentation available on https://www.mediawiki.org/wiki/Manual:Notifications.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4