diff --git a/extension.json b/extension.json index 40c539d23..04c92b59a 100644 --- a/extension.json +++ b/extension.json @@ -1061,10 +1061,6 @@ "MediaWiki\\Extension\\Notifications\\AttributeManager": "includes/AttributeManager.php", "EchoCallbackIterator": "includes/Iterator/CallbackIterator.php", "MediaWiki\\Extension\\Notifications\\Iterator\\CallbackIterator": "includes/Iterator/CallbackIterator.php", - "EchoDataOutputFormatter": "includes/DataOutputFormatter.php", - "EchoDeferredMarkAsDeletedUpdate": "includes/DeferredMarkAsDeletedUpdate.php", - "EchoDiffGroup": "includes/EchoDiffGroup.php", - "EchoDiffParser": "includes/EchoDiffParser.php", "EchoDiscussionParser": "includes/DiscussionParser.php", "MediaWiki\\Extension\\Notifications\\DiscussionParser": "includes/DiscussionParser.php", "EchoEditUserTalkPresentationModel": "includes/Formatters/EchoEditUserTalkPresentationModel.php", @@ -1088,16 +1084,13 @@ "EchoPresentationModelSection": "includes/Formatters/EchoPresentationModelSection.php", "MediaWiki\\Extension\\Notifications\\Formatters\\EchoPresentationModelSection": "includes/Formatters/EchoPresentationModelSection.php", "EchoServices": "includes/EchoServices.php", - "EchoSummaryParser": "includes/EchoSummaryParser.php", "EchoSuppressionRowUpdateGenerator": "includes/schemaUpdate.php", - "EchoUnreadWikis": "includes/UnreadWikis.php", "EchoUserLocator": "includes/UserLocator.php", "MediaWiki\\Extension\\Notifications\\UserLocator": "includes/UserLocator.php", "GenerateSampleNotifications": "maintenance/generateSampleNotifications.php", "MWEchoDbFactory": "includes/DbFactory.php", "MediaWiki\\Extension\\Notifications\\DbFactory": "includes/DbFactory.php", "MWEchoEventLogging": "includes/EventLogging.php", - "MWEchoNotifUser": "includes/NotifUser.php", "ProcessEchoEmailBatch": "maintenance/processEchoEmailBatch.php", "RecomputeNotifCounts": "maintenance/recomputeNotifCounts.php", "RemoveInvalidNotification": "maintenance/removeInvalidNotification.php", diff --git a/includes/Api/ApiEchoMarkRead.php b/includes/Api/ApiEchoMarkRead.php index 787fa6baf..b11fa3628 100644 --- a/includes/Api/ApiEchoMarkRead.php +++ b/includes/Api/ApiEchoMarkRead.php @@ -6,8 +6,8 @@ use ApiBase; use MediaWiki\Extension\Notifications\AttributeManager; use MediaWiki\Extension\Notifications\Controller\NotificationController; use MediaWiki\Extension\Notifications\DbFactory; +use MediaWiki\Extension\Notifications\NotifUser; use MediaWiki\WikiMap\WikiMap; -use MWEchoNotifUser; use Wikimedia\ParamValidator\ParamValidator; class ApiEchoMarkRead extends ApiBase { @@ -24,7 +24,7 @@ class ApiEchoMarkRead extends ApiBase { $this->dieReadOnly(); } - $notifUser = MWEchoNotifUser::newFromUser( $user ); + $notifUser = NotifUser::newFromUser( $user ); $params = $this->extractRequestParams(); diff --git a/includes/Api/ApiEchoNotifications.php b/includes/Api/ApiEchoNotifications.php index b2feb6250..9dde60c55 100644 --- a/includes/Api/ApiEchoNotifications.php +++ b/includes/Api/ApiEchoNotifications.php @@ -6,17 +6,17 @@ use ApiBase; use ApiQuery; use ApiQueryBase; use Config; -use EchoDataOutputFormatter; use EchoForeignNotifications; use EchoServices; use MediaWiki\Extension\Notifications\AttributeManager; use MediaWiki\Extension\Notifications\Bundler; use MediaWiki\Extension\Notifications\Controller\NotificationController; +use MediaWiki\Extension\Notifications\DataOutputFormatter; use MediaWiki\Extension\Notifications\Mapper\NotificationMapper; use MediaWiki\Extension\Notifications\Model\Notification; +use MediaWiki\Extension\Notifications\NotifUser; use MediaWiki\Extension\Notifications\SeenTime; use MediaWiki\WikiMap\WikiMap; -use MWEchoNotifUser; use Title; use User; use Wikimedia\ParamValidator\ParamValidator; @@ -320,7 +320,7 @@ class ApiEchoNotifications extends ApiQueryBase { while ( $notifs !== [] ) { /** @var Notification $notif */ $notif = array_shift( $notifs ); - $output = EchoDataOutputFormatter::formatOutput( $notif, $format, $user, $this->getLanguage() ); + $output = DataOutputFormatter::formatOutput( $notif, $format, $user, $this->getLanguage() ); if ( $output !== false ) { $result['list'][] = $output; } elseif ( $bundler && $notif->getBundledNotifications() ) { @@ -350,7 +350,7 @@ class ApiEchoNotifications extends ApiQueryBase { */ protected function getPropCount( User $user, array $sections, $groupBySection ) { $result = []; - $notifUser = MWEchoNotifUser::newFromUser( $user ); + $notifUser = NotifUser::newFromUser( $user ); $global = $this->crossWikiSummary ? 'preference' : false; $totalRawCount = 0; @@ -445,7 +445,7 @@ class ApiEchoNotifications extends ApiQueryBase { // Format output like any other notification $notif = Notification::newFromRow( $row ); - $output = EchoDataOutputFormatter::formatOutput( $notif, $format, $user, $this->getLanguage() ); + $output = DataOutputFormatter::formatOutput( $notif, $format, $user, $this->getLanguage() ); // Add cross-wiki-specific data $output['section'] = $section ?: 'all'; diff --git a/includes/Api/ApiEchoUnreadNotificationPages.php b/includes/Api/ApiEchoUnreadNotificationPages.php index c65697685..2c2e89636 100644 --- a/includes/Api/ApiEchoUnreadNotificationPages.php +++ b/includes/Api/ApiEchoUnreadNotificationPages.php @@ -7,12 +7,12 @@ use ApiQueryBase; use ApiUsageException; use EchoServices; use MediaWiki\Extension\Notifications\DbFactory; +use MediaWiki\Extension\Notifications\NotifUser; use MediaWiki\Logger\LoggerFactory; use MediaWiki\Page\PageRecord; use MediaWiki\Page\PageStore; use MediaWiki\Title\TitleFactory; use MediaWiki\WikiMap\WikiMap; -use MWEchoNotifUser; use Title; use Wikimedia\ParamValidator\ParamValidator; use Wikimedia\ParamValidator\TypeDef\IntegerDef; @@ -198,7 +198,7 @@ class ApiEchoUnreadNotificationPages extends ApiQueryBase { return [ 'pages' => $result, - 'totalCount' => MWEchoNotifUser::newFromUser( $this->getUser() )->getLocalNotificationCount(), + 'totalCount' => NotifUser::newFromUser( $this->getUser() )->getLocalNotificationCount(), ]; } diff --git a/includes/Controller/ModerationController.php b/includes/Controller/ModerationController.php index 5581d6790..aebee8753 100644 --- a/includes/Controller/ModerationController.php +++ b/includes/Controller/ModerationController.php @@ -5,8 +5,8 @@ namespace MediaWiki\Extension\Notifications\Controller; use DeferredUpdates; use MediaWiki\Extension\Notifications\Mapper\EventMapper; use MediaWiki\Extension\Notifications\Mapper\NotificationMapper; +use MediaWiki\Extension\Notifications\NotifUser; use MediaWiki\MediaWikiServices; -use MWEchoNotifUser; use User; /** @@ -43,7 +43,7 @@ class ModerationController { // users whose notifications have been moderated. foreach ( $affectedUserIds as $userId ) { $user = User::newFromId( $userId ); - MWEchoNotifUser::newFromUser( $user )->resetNotificationCount(); + NotifUser::newFromUser( $user )->resetNotificationCount(); } } ); } diff --git a/includes/Controller/NotificationController.php b/includes/Controller/NotificationController.php index ced8af283..c32c9b4d9 100644 --- a/includes/Controller/NotificationController.php +++ b/includes/Controller/NotificationController.php @@ -16,12 +16,12 @@ use MediaWiki\Extension\Notifications\Iterator\FilteredSequentialIterator; use MediaWiki\Extension\Notifications\Jobs\NotificationDeleteJob; use MediaWiki\Extension\Notifications\Jobs\NotificationJob; use MediaWiki\Extension\Notifications\Model\Event; +use MediaWiki\Extension\Notifications\NotifUser; use MediaWiki\Extension\Notifications\OnWikiList; use MediaWiki\Logger\LoggerFactory; use MediaWiki\MediaWikiServices; use MediaWiki\Revision\RevisionStore; use MediaWiki\User\UserIdentity; -use MWEchoNotifUser; use Title; use User; @@ -80,7 +80,7 @@ class NotificationController { * @return int Notification count, with ceiling applied */ public static function getCappedNotificationCount( int $count ): int { - return min( $count, MWEchoNotifUser::MAX_BADGE_COUNT + 1 ); + return min( $count, NotifUser::MAX_BADGE_COUNT + 1 ); } /** diff --git a/includes/DataOutputFormatter.php b/includes/DataOutputFormatter.php index 9bc8aad84..3140d1a56 100644 --- a/includes/DataOutputFormatter.php +++ b/includes/DataOutputFormatter.php @@ -1,5 +1,9 @@ class @@ -157,7 +164,7 @@ class EchoDataOutputFormatter { $formatted = self::formatNotification( $event, $user, $format, $lang ); if ( $formatted === false ) { // Can't display it, so mark it as read - EchoDeferredMarkAsDeletedUpdate::add( $event ); + DeferredMarkAsDeletedUpdate::add( $event ); return false; } $output['*'] = $formatted; diff --git a/includes/DeferredMarkAsDeletedUpdate.php b/includes/DeferredMarkAsDeletedUpdate.php index 0902907c7..9e2dcd224 100644 --- a/includes/DeferredMarkAsDeletedUpdate.php +++ b/includes/DeferredMarkAsDeletedUpdate.php @@ -1,5 +1,9 @@ debug( - 'EchoDeferredMarkAsDeletedUpdate: Event {eventId} was found unrenderable' . + 'DeferredMarkAsDeletedUpdate: Event {eventId} was found unrenderable' . ' but its associated title exists on primary database. Skipping.', [ 'eventId' => $event->getId(), diff --git a/includes/EchoDiffGroup.php b/includes/DiffGroup.php similarity index 97% rename from includes/EchoDiffGroup.php rename to includes/DiffGroup.php index c9871ad58..bf014b71e 100644 --- a/includes/EchoDiffGroup.php +++ b/includes/DiffGroup.php @@ -1,4 +1,7 @@ $this->prefixLength ) { @@ -222,7 +226,7 @@ class EchoDiffParser { } if ( $change === null ) { // @phan-suppress-next-line PhanTypeMismatchArgument - $change = new EchoDiffGroup( $this->leftPos, $this->rightPos ); + $change = new DiffGroup( $this->leftPos, $this->rightPos ); } $change->subtract( $line ); $this->leftPos++; @@ -235,7 +239,7 @@ class EchoDiffParser { } if ( $change === null ) { // @phan-suppress-next-line PhanTypeMismatchArgument - $change = new EchoDiffGroup( $this->leftPos, $this->rightPos ); + $change = new DiffGroup( $this->leftPos, $this->rightPos ); } $change->add( $line ); $this->rightPos++; diff --git a/includes/DiscussionParser.php b/includes/DiscussionParser.php index f3c280d8c..1e082651d 100644 --- a/includes/DiscussionParser.php +++ b/includes/DiscussionParser.php @@ -3,8 +3,6 @@ namespace MediaWiki\Extension\Notifications; use Article; -use EchoDiffParser; -use EchoSummaryParser; use Language; use MediaWiki\Extension\Notifications\Hooks\HookRunner; use MediaWiki\Extension\Notifications\Model\Event; @@ -28,9 +26,11 @@ abstract class DiscussionParser { /** @var string|null */ protected static $timestampRegex; + /** @var array[][] */ protected static $revisionInterpretationCache = []; - /** @var EchoDiffParser|null */ + + /** @var DiffParser|null */ protected static $diffParser; /** @@ -157,7 +157,7 @@ abstract class DiscussionParser { global $wgEchoMaxMentionsInEditSummary; if ( $wgEchoMaxMentionsInEditSummary > 0 && !$user->isBot() && !$isRevert ) { - $summaryParser = new EchoSummaryParser(); + $summaryParser = new SummaryParser(); $usersInSummary = $summaryParser->parse( $revision->getComment()->text ); // Don't allow pinging yourself @@ -1000,7 +1000,7 @@ abstract class DiscussionParser { */ public static function getMachineReadableDiff( $oldText, $newText ) { if ( !isset( self::$diffParser ) ) { - self::$diffParser = new EchoDiffParser; + self::$diffParser = new DiffParser; } return self::$diffParser->getChangeSet( $oldText, $newText ); diff --git a/includes/EmailBatch.php b/includes/EmailBatch.php index 1bdf7f350..550d1549f 100644 --- a/includes/EmailBatch.php +++ b/includes/EmailBatch.php @@ -13,7 +13,6 @@ use MediaWiki\Languages\LanguageFactory; use MediaWiki\MediaWikiServices; use MediaWiki\User\UserOptionsManager; use MWEchoEventLogging; -use MWEchoNotifUser; use stdClass; use User; use UserMailer; @@ -350,7 +349,7 @@ class EmailBatch { return; } - $format = MWEchoNotifUser::newFromUser( $this->mUser )->getEmailFormat(); + $format = NotifUser::newFromUser( $this->mUser )->getEmailFormat(); if ( $format == EmailFormat::HTML ) { $htmlEmailDigestFormatter = new EchoHtmlDigestEmailFormatter( $this->mUser, $this->language, $frequency ); $htmlContent = $htmlEmailDigestFormatter->format( $this->events, 'email' ); diff --git a/includes/ForeignNotifications.php b/includes/ForeignNotifications.php index b9033eb7a..c62c62385 100644 --- a/includes/ForeignNotifications.php +++ b/includes/ForeignNotifications.php @@ -1,12 +1,14 @@ counts[$section] ?? 0; } - return MWEchoNotifUser::capNotificationCount( $count ); + return NotifUser::capNotificationCount( $count ); } /** @@ -155,7 +157,7 @@ class EchoForeignNotifications { return; } - $unreadWikis = EchoUnreadWikis::newFromUser( $this->user ); + $unreadWikis = UnreadWikis::newFromUser( $this->user ); if ( !$unreadWikis ) { return; } diff --git a/includes/Gateway/UserNotificationGateway.php b/includes/Gateway/UserNotificationGateway.php index 6aa201f80..678c245c7 100644 --- a/includes/Gateway/UserNotificationGateway.php +++ b/includes/Gateway/UserNotificationGateway.php @@ -4,8 +4,8 @@ namespace MediaWiki\Extension\Notifications\Gateway; use Config; use MediaWiki\Extension\Notifications\DbFactory; +use MediaWiki\Extension\Notifications\NotifUser; use MediaWiki\User\UserIdentity; -use MWEchoNotifUser; /** * Database gateway which handles direct database interaction with the @@ -128,7 +128,7 @@ class UserNotificationGateway { } /** - * Mark all notification as read, use MWEchoNotifUser::markAllRead() instead + * Mark all notification as read, use NotifUser::markAllRead() instead * @deprecated may need this when running in a job or revive this when we * have updateJoin() */ @@ -161,7 +161,7 @@ class UserNotificationGateway { public function getCappedNotificationCount( $dbSource, array $eventTypesToLoad = [], - $cap = MWEchoNotifUser::MAX_BADGE_COUNT + $cap = NotifUser::MAX_BADGE_COUNT ) { // double check if ( !in_array( $dbSource, [ DB_REPLICA, DB_PRIMARY ] ) ) { @@ -196,7 +196,7 @@ class UserNotificationGateway { /** * IMPORTANT: should only call this function if the number of unread notification * is reasonable, for example, unread notification count is less than the max - * display defined in MWEchoNotifUser::MAX_BADGE_COUNT + * display defined in oNotifUser::MAX_BADGE_COUNT * @param string $type * @return int[] */ diff --git a/includes/Hooks.php b/includes/Hooks.php index ffae3443a..966fb588a 100644 --- a/includes/Hooks.php +++ b/includes/Hooks.php @@ -61,7 +61,6 @@ use MediaWiki\User\Options\Hook\LoadUserOptionsHook; use MediaWiki\User\Options\Hook\SaveUserOptionsHook; use MediaWiki\User\UserIdentity; use MediaWiki\WikiMap\WikiMap; -use MWEchoNotifUser; use OutputPage; use RecentChange; use ResourceLoaderEchoImageModule; @@ -938,7 +937,7 @@ class Hooks implements } else { $markAsReadIds = array_map( 'intval', $markAsReadIds ); // Look up the notifications on the foreign wiki - $notifUser = MWEchoNotifUser::newFromUser( $user ); + $notifUser = NotifUser::newFromUser( $user ); $notifInfo = $notifUser->getForeignNotificationInfo( $markAsReadIds, $markAsReadWiki, $request ); foreach ( $notifInfo as $id => $info ) { $subtractions[$info['section']]++; @@ -947,7 +946,7 @@ class Hooks implements // Schedule a deferred update to mark these notifications as read on the foreign wiki DeferredUpdates::addCallableUpdate( static function () use ( $user, $markAsReadIds, $markAsReadWiki, $request ) { - $notifUser = MWEchoNotifUser::newFromUser( $user ); + $notifUser = NotifUser::newFromUser( $user ); $notifUser->markReadForeign( $markAsReadIds, $markAsReadWiki, $request ); } ); @@ -957,7 +956,7 @@ class Hooks implements // Schedule a deferred update to mark local target_page and ?markasread= notifications as read if ( $eventIds ) { DeferredUpdates::addCallableUpdate( static function () use ( $user, $eventIds ) { - $notifUser = MWEchoNotifUser::newFromUser( $user ); + $notifUser = NotifUser::newFromUser( $user ); $notifUser->markRead( $eventIds ); } ); } @@ -1004,7 +1003,7 @@ class Hooks implements $subtractions = self::processMarkAsRead( $user, $out->getRequest(), $title ); // Add a "My notifications" item to personal URLs - $notifUser = MWEchoNotifUser::newFromUser( $user ); + $notifUser = NotifUser::newFromUser( $user ); $msgCount = $notifUser->getMessageCount() - $subtractions[AttributeManager::MESSAGE]; $alertCount = $notifUser->getAlertCount() - $subtractions[AttributeManager::ALERT]; // But make sure we never show a negative number (T130853) @@ -1058,7 +1057,7 @@ class Hooks implements $msgLinkClasses[] = 'mw-echo-notifications-badge-all-read'; } - if ( $msgCount > MWEchoNotifUser::MAX_BADGE_COUNT ) { + if ( $msgCount > NotifUser::MAX_BADGE_COUNT ) { $msgLinkClasses[] = 'mw-echo-notifications-badge-long-label'; } @@ -1077,7 +1076,7 @@ class Hooks implements $alertLinkClasses[] = 'mw-echo-notifications-badge-all-read'; } - if ( $alertCount > MWEchoNotifUser::MAX_BADGE_COUNT ) { + if ( $alertCount > NotifUser::MAX_BADGE_COUNT ) { $alertLinkClasses[] = 'mw-echo-notifications-badge-long-label'; } @@ -1225,7 +1224,7 @@ class Hooks implements $user = $out->getUser(); if ( $user->isRegistered() ) { - $notifUser = MWEchoNotifUser::newFromUser( $user ); + $notifUser = NotifUser::newFromUser( $user ); $lastUpdate = $notifUser->getGlobalUpdateTime(); if ( $lastUpdate !== false ) { $modifiedTimes['notifications-global'] = $lastUpdate; @@ -1326,7 +1325,7 @@ class Hooks implements // update runs (T318081) return; } - MWEchoNotifUser::newFromUser( $user )->resetNotificationCount(); + NotifUser::newFromUser( $user )->resetNotificationCount(); } ); } } @@ -1410,7 +1409,7 @@ class Hooks implements public function onUserClearNewTalkNotification( $user, $oldid ) { if ( $user->isRegistered() ) { DeferredUpdates::addCallableUpdate( static function () use ( $user ) { - MWEchoNotifUser::newFromUser( $user )->clearUserTalkNotifications(); + NotifUser::newFromUser( $user )->clearUserTalkNotifications(); } ); } } @@ -1463,7 +1462,7 @@ class Hooks implements public static function getConfigVars( RL\Context $context, Config $config ) { return [ - 'EchoMaxNotificationCount' => MWEchoNotifUser::MAX_BADGE_COUNT, + 'EchoMaxNotificationCount' => NotifUser::MAX_BADGE_COUNT, 'EchoPollForUpdates' => $config->get( 'EchoPollForUpdates' ) ]; } diff --git a/includes/Jobs/NotificationDeleteJob.php b/includes/Jobs/NotificationDeleteJob.php index 8def485eb..0dd56d2e1 100644 --- a/includes/Jobs/NotificationDeleteJob.php +++ b/includes/Jobs/NotificationDeleteJob.php @@ -4,8 +4,8 @@ namespace MediaWiki\Extension\Notifications\Jobs; use Job; use MediaWiki\Extension\Notifications\Mapper\NotificationMapper; +use MediaWiki\Extension\Notifications\NotifUser; use MediaWiki\MediaWikiServices; -use MWEchoNotifUser; use Title; use User; @@ -58,7 +58,7 @@ class NotificationDeleteJob extends Job { $notifMapper->deleteByUserEventOffset( $user, $notif->getEvent()->getId() ); - $notifUser = MWEchoNotifUser::newFromUser( $user ); + $notifUser = NotifUser::newFromUser( $user ); $notifUser->resetNotificationCount(); } diff --git a/includes/Model/Notification.php b/includes/Model/Notification.php index db840e7e7..1fbf64536 100644 --- a/includes/Model/Notification.php +++ b/includes/Model/Notification.php @@ -6,8 +6,8 @@ use InvalidArgumentException; use MediaWiki\Extension\Notifications\Bundleable; use MediaWiki\Extension\Notifications\Hooks\HookRunner; use MediaWiki\Extension\Notifications\Mapper\NotificationMapper; +use MediaWiki\Extension\Notifications\NotifUser; use MediaWiki\MediaWikiServices; -use MWEchoNotifUser; use stdClass; use User; @@ -119,7 +119,7 @@ class Notification extends AbstractEntity implements Bundleable { $this->bundleHash = $hash; } - $notifUser = MWEchoNotifUser::newFromUser( $this->user ); + $notifUser = NotifUser::newFromUser( $this->user ); // Add listener to refresh notification count upon insert $notifMapper->attachListener( 'insert', 'refresh-notif-count', diff --git a/includes/NotifUser.php b/includes/NotifUser.php index 9da1ae7fe..232cd6c59 100644 --- a/includes/NotifUser.php +++ b/includes/NotifUser.php @@ -1,8 +1,12 @@ isRegistered() ) { throw new InvalidArgumentException( 'User must be logged in to view notification!' ); } $services = MediaWikiServices::getInstance(); - return new MWEchoNotifUser( + return new NotifUser( $user, $services->getMainWANObjectCache(), new UserNotificationGateway( @@ -192,7 +200,7 @@ class MWEchoNotifUser { /** * Retrieves number of unread notifications that a user has, would return - * MWEchoNotifUser::MAX_BADGE_COUNT + 1 at most. + * NotifUser::MAX_BADGE_COUNT + 1 at most. * * If $wgEchoCrossWikiNotifications is disabled, the $global parameter is ignored. * @@ -490,7 +498,7 @@ class MWEchoNotifUser { $this->cache->delete( $globalMemcKey ); } - $uw = EchoUnreadWikis::newFromUser( $this->mUser ); + $uw = UnreadWikis::newFromUser( $this->mUser ); if ( $uw ) { // Immediately compute new local counts and timestamps $newLocalData = $this->computeLocalCountsAndTimestamps( DB_PRIMARY ); @@ -748,7 +756,7 @@ class MWEchoNotifUser { /** * Helper function to produce the capped number of notifications - * based on the value of MWEchoNotifUser::MAX_BADGE_COUNT + * based on the value of NotifUser::MAX_BADGE_COUNT * * @param int $number Raw notification count to cap * @return int Capped notification count diff --git a/includes/Notifier.php b/includes/Notifier.php index 428b620cf..34419114d 100644 --- a/includes/Notifier.php +++ b/includes/Notifier.php @@ -11,7 +11,6 @@ use MediaWiki\Extension\Notifications\Model\Event; use MediaWiki\Extension\Notifications\Model\Notification; use MediaWiki\MediaWikiServices; use MWEchoEventLogging; -use MWEchoNotifUser; use User; use UserMailer; @@ -131,7 +130,7 @@ class Notifier { * @return array|false An array of 'subject' and 'body', or false if things went wrong */ private static function generateEmail( Event $event, User $user ) { - $emailFormat = MWEchoNotifUser::newFromUser( $user )->getEmailFormat(); + $emailFormat = NotifUser::newFromUser( $user )->getEmailFormat(); $services = MediaWikiServices::getInstance(); $userOptionsLookup = $services->getUserOptionsLookup(); $lang = $services->getLanguageFactory() diff --git a/includes/Special/SpecialNotifications.php b/includes/Special/SpecialNotifications.php index cfae7b2d1..32f149448 100644 --- a/includes/Special/SpecialNotifications.php +++ b/includes/Special/SpecialNotifications.php @@ -2,12 +2,12 @@ namespace MediaWiki\Extension\Notifications\Special; -use EchoDataOutputFormatter; use Html; +use MediaWiki\Extension\Notifications\DataOutputFormatter; +use MediaWiki\Extension\Notifications\NotifUser; use MediaWiki\Extension\Notifications\OOUI\LabelIconWidget; use MediaWiki\Extension\Notifications\SeenTime; use MWEchoEventLogging; -use MWEchoNotifUser; use OOUI; use SpecialPage; @@ -69,7 +69,7 @@ class SpecialNotifications extends SpecialPage { $notif = []; foreach ( $notifications as $notification ) { - $output = EchoDataOutputFormatter::formatOutput( $notification, 'special', $user, $this->getLanguage() ); + $output = DataOutputFormatter::formatOutput( $notification, 'special', $user, $this->getLanguage() ); if ( $output ) { $notif[] = $output; } @@ -121,7 +121,7 @@ class SpecialNotifications extends SpecialPage { if ( $anyUnread ) { $markReadSpecialPage = new SpecialNotificationsMarkRead(); $markReadSpecialPage->setContext( $this->getContext() ); - $notifUser = MWEchoNotifUser::newFromUser( $user ); + $notifUser = NotifUser::newFromUser( $user ); $unreadCount = $notifUser->getAlertCount() + $notifUser->getMessageCount(); $markAllAsReadText = $this diff --git a/includes/Special/SpecialNotificationsMarkRead.php b/includes/Special/SpecialNotificationsMarkRead.php index a3e7d6c9a..c984ebebb 100644 --- a/includes/Special/SpecialNotificationsMarkRead.php +++ b/includes/Special/SpecialNotificationsMarkRead.php @@ -4,7 +4,7 @@ namespace MediaWiki\Extension\Notifications\Special; use FormSpecialPage; use HTMLForm; -use MWEchoNotifUser; +use MediaWiki\Extension\Notifications\NotifUser; use SpecialPage; /** @@ -135,7 +135,7 @@ class SpecialNotificationsMarkRead extends FormSpecialPage { * @return bool */ public function onSubmit( array $data ) { - $notifUser = MWEchoNotifUser::newFromUser( $this->getUser() ); + $notifUser = NotifUser::newFromUser( $this->getUser() ); // Allow for all IDs if ( $data['id'] === [ 'ALL' ] ) { diff --git a/includes/EchoSummaryParser.php b/includes/SummaryParser.php similarity index 86% rename from includes/EchoSummaryParser.php rename to includes/SummaryParser.php index 410c875a2..2fda1b753 100644 --- a/includes/EchoSummaryParser.php +++ b/includes/SummaryParser.php @@ -1,13 +1,18 @@ userLookup = $userLookup; diff --git a/includes/UnreadWikis.php b/includes/UnreadWikis.php index 3f7412eb3..d762338f4 100644 --- a/includes/UnreadWikis.php +++ b/includes/UnreadWikis.php @@ -1,14 +1,17 @@ dbFactory->getSharedDb( $index ); diff --git a/includes/UserMergeHooks.php b/includes/UserMergeHooks.php index 7f45c243d..918feb8d8 100644 --- a/includes/UserMergeHooks.php +++ b/includes/UserMergeHooks.php @@ -9,7 +9,6 @@ use MediaWiki\Extension\UserMerge\Hooks\AccountDeleteTablesHook; use MediaWiki\Extension\UserMerge\Hooks\AccountFieldsHook; use MediaWiki\Extension\UserMerge\Hooks\MergeAccountFromToHook; use MWEchoDbFactory; -use MWEchoNotifUser; use User; class UserMergeHooks implements @@ -106,9 +105,9 @@ class UserMergeHooks implements } } - MWEchoNotifUser::newFromUser( $oldUser )->resetNotificationCount(); + NotifUser::newFromUser( $oldUser )->resetNotificationCount(); if ( $newUser->isRegistered() ) { - MWEchoNotifUser::newFromUser( $newUser )->resetNotificationCount(); + NotifUser::newFromUser( $newUser )->resetNotificationCount(); } } ); } diff --git a/maintenance/backfillUnreadWikis.php b/maintenance/backfillUnreadWikis.php index 7af1d74e5..c03f4a2fe 100644 --- a/maintenance/backfillUnreadWikis.php +++ b/maintenance/backfillUnreadWikis.php @@ -2,6 +2,8 @@ use MediaWiki\Extension\Notifications\AttributeManager; use MediaWiki\Extension\Notifications\DbFactory; +use MediaWiki\Extension\Notifications\NotifUser; +use MediaWiki\Extension\Notifications\UnreadWikis; use MediaWiki\MediaWikiServices; use MediaWiki\WikiMap\WikiMap; @@ -60,8 +62,8 @@ class BackfillUnreadWikis extends Maintenance { $user = User::newFromRow( $row ); } - $notifUser = MWEchoNotifUser::newFromUser( $user ); - $uw = EchoUnreadWikis::newFromUser( $user ); + $notifUser = NotifUser::newFromUser( $user ); + $uw = UnreadWikis::newFromUser( $user ); if ( $uw ) { $alertCount = $notifUser->getNotificationCount( AttributeManager::ALERT, false ); $alertUnread = $notifUser->getLastUnreadNotificationTime( AttributeManager::ALERT, false ); diff --git a/maintenance/recomputeNotifCounts.php b/maintenance/recomputeNotifCounts.php index e95a9ae65..b6b16b28c 100644 --- a/maintenance/recomputeNotifCounts.php +++ b/maintenance/recomputeNotifCounts.php @@ -6,6 +6,7 @@ */ use MediaWiki\Extension\Notifications\DbFactory; +use MediaWiki\Extension\Notifications\NotifUser; require_once getenv( 'MW_INSTALL_PATH' ) !== false ? getenv( 'MW_INSTALL_PATH' ) . '/maintenance/Maintenance.php' @@ -79,7 +80,7 @@ class RecomputeNotifCounts extends Maintenance { } else { $user = User::newFromId( is_object( $rowOrID ) ? $rowOrID->notification_user : $rowOrID ); } - $notifUser = MWEchoNotifUser::newFromUser( $user ); + $notifUser = NotifUser::newFromUser( $user ); $notifUser->resetNotificationCount(); } $count += count( $batch ); diff --git a/tests/phpunit/MWEchoNotifUserTest.php b/tests/phpunit/NotifUserTest.php similarity index 91% rename from tests/phpunit/MWEchoNotifUserTest.php rename to tests/phpunit/NotifUserTest.php index 9c97c0318..bd7094f72 100644 --- a/tests/phpunit/MWEchoNotifUserTest.php +++ b/tests/phpunit/NotifUserTest.php @@ -6,6 +6,7 @@ use MediaWiki\Extension\Notifications\Mapper\NotificationMapper; use MediaWiki\Extension\Notifications\Mapper\TargetPageMapper; use MediaWiki\Extension\Notifications\Model\Event; use MediaWiki\Extension\Notifications\Model\Notification; +use MediaWiki\Extension\Notifications\NotifUser; use MediaWiki\MediaWikiServices; use MediaWiki\User\TalkPageNotificationManager; use MediaWiki\User\UserFactory; @@ -13,10 +14,10 @@ use MediaWiki\User\UserGroupManager; use MediaWiki\User\UserOptionsLookup; /** - * @covers \MWEchoNotifUser + * @covers \MediaWiki\Extension\Notifications\NotifUser * @group Echo */ -class MWEchoNotifUserTest extends MediaWikiIntegrationTestCase { +class NotifUserTest extends MediaWikiIntegrationTestCase { /** * @var WANObjectCache @@ -33,7 +34,7 @@ class MWEchoNotifUserTest extends MediaWikiIntegrationTestCase { public function testNewFromUser() { $exception = false; try { - MWEchoNotifUser::newFromUser( User::newFromId( 0 ) ); + NotifUser::newFromUser( User::newFromId( 0 ) ); } catch ( Exception $e ) { $exception = true; $this->assertEquals( "User must be logged in to view notification!", @@ -41,8 +42,8 @@ class MWEchoNotifUserTest extends MediaWikiIntegrationTestCase { } $this->assertTrue( $exception, "Got exception" ); - $notifUser = MWEchoNotifUser::newFromUser( User::newFromId( 2 ) ); - $this->assertInstanceOf( MWEchoNotifUser::class, $notifUser ); + $notifUser = NotifUser::newFromUser( User::newFromId( 2 ) ); + $this->assertInstanceOf( NotifUser::class, $notifUser ); } public function testGetEmailFormat() { @@ -54,7 +55,7 @@ class MWEchoNotifUserTest extends MediaWikiIntegrationTestCase { ->with( $user, 'echo-email-format' ) ->willReturn( $pref ); $this->setService( 'UserOptionsLookup', $userOptionsLookup ); - $notifUser = MWEchoNotifUser::newFromUser( $user ); + $notifUser = NotifUser::newFromUser( $user ); $this->setMwGlobals( 'wgAllowHTMLEmail', true ); $this->assertEquals( $notifUser->getEmailFormat(), $pref ); @@ -65,7 +66,7 @@ class MWEchoNotifUserTest extends MediaWikiIntegrationTestCase { public function testMarkRead() { $this->setService( 'UserFactory', $this->createMock( UserFactory::class ) ); $this->setService( 'TalkPageNotificationManager', $this->createMock( TalkPageNotificationManager::class ) ); - $notifUser = new MWEchoNotifUser( + $notifUser = new NotifUser( User::newFromId( 2 ), $this->cache, $this->mockUserNotificationGateway( [ 'markRead' => true ] ), @@ -78,7 +79,7 @@ class MWEchoNotifUserTest extends MediaWikiIntegrationTestCase { $this->assertFalse( $notifUser->markRead( [] ) ); $this->assertTrue( $notifUser->markRead( [ 1 ] ) ); - $notifUser = new MWEchoNotifUser( + $notifUser = new NotifUser( User::newFromId( 2 ), $this->cache, $this->mockUserNotificationGateway( [ 'markRead' => false ] ), @@ -98,7 +99,7 @@ class MWEchoNotifUserTest extends MediaWikiIntegrationTestCase { $this->setService( 'UserGroupManager', $this->createMock( UserGroupManager::class ) ); $this->setService( 'UserOptionsLookup', $this->createMock( UserOptionsLookup::class ) ); // Successful mark as read & non empty fetch - $notifUser = new MWEchoNotifUser( + $notifUser = new NotifUser( User::newFromId( 2 ), $this->cache, $this->mockUserNotificationGateway( [ 'markRead' => true ] ), @@ -111,7 +112,7 @@ class MWEchoNotifUserTest extends MediaWikiIntegrationTestCase { $this->assertTrue( $notifUser->markAllRead() ); // Unsuccessful mark as read & non empty fetch - $notifUser = new MWEchoNotifUser( + $notifUser = new NotifUser( User::newFromId( 2 ), $this->cache, $this->mockUserNotificationGateway( [ 'markRead' => false ] ), @@ -124,7 +125,7 @@ class MWEchoNotifUserTest extends MediaWikiIntegrationTestCase { $this->assertFalse( $notifUser->markAllRead() ); // Successful mark as read & empty fetch - $notifUser = new MWEchoNotifUser( + $notifUser = new NotifUser( User::newFromId( 2 ), $this->cache, $this->mockUserNotificationGateway( [ 'markRead' => true ] ), @@ -137,7 +138,7 @@ class MWEchoNotifUserTest extends MediaWikiIntegrationTestCase { $this->assertFalse( $notifUser->markAllRead() ); // Unsuccessful mark as read & empty fetch - $notifUser = new MWEchoNotifUser( + $notifUser = new NotifUser( User::newFromId( 2 ), $this->cache, $this->mockUserNotificationGateway( [ 'markRead' => false ] ), @@ -188,7 +189,7 @@ class MWEchoNotifUserTest extends MediaWikiIntegrationTestCase { } protected function newNotifUser() { - return new MWEchoNotifUser( + return new NotifUser( User::newFromId( 2 ), $this->cache, $this->mockUserNotificationGateway(), diff --git a/tests/phpunit/EchoSummaryParserTest.php b/tests/phpunit/SummaryParserTest.php similarity index 87% rename from tests/phpunit/EchoSummaryParserTest.php rename to tests/phpunit/SummaryParserTest.php index f2afaecbb..4a53be64d 100644 --- a/tests/phpunit/EchoSummaryParserTest.php +++ b/tests/phpunit/SummaryParserTest.php @@ -1,9 +1,11 @@ getName(), $this->existingUsers ) ) { return crc32( $user->getName() ); } diff --git a/tests/phpunit/UnreadWikisTest.php b/tests/phpunit/UnreadWikisTest.php index ea1750564..7cd3aeae6 100644 --- a/tests/phpunit/UnreadWikisTest.php +++ b/tests/phpunit/UnreadWikisTest.php @@ -1,18 +1,19 @@ dbFactory = $this->mockDbFactory( $this->db ); $unread->updateCount( 'foobar', @@ -33,7 +34,7 @@ class UnreadWikisTest extends MediaWikiIntegrationTestCase { } public function testUpdateCountFalse() { - $unread = TestingAccessWrapper::newFromObject( new EchoUnreadWikis( 1 ) ); + $unread = TestingAccessWrapper::newFromObject( new UnreadWikis( 1 ) ); $unread->dbFactory = $this->mockDbFactory( $this->db ); $unread->updateCount( 'foobar', diff --git a/tests/phpunit/unit/DiffParserTest.php b/tests/phpunit/unit/DiffParserTest.php index 215aa4d2b..18abaa004 100644 --- a/tests/phpunit/unit/DiffParserTest.php +++ b/tests/phpunit/unit/DiffParserTest.php @@ -3,7 +3,7 @@ use MediaWiki\Extension\Notifications\DiscussionParser; /** - * @covers \EchoDiffParser + * @covers \MediaWiki\Extension\Notifications\DiffParser * @group Echo */ class DiffParserTest extends MediaWikiUnitTestCase {