Umherirrender has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/364302 )
Change subject: Break long lines
......................................................................
Break long lines
Change-Id: I9d87142796e99fcfac94a300b16e8d169bb1e8af
---
M Hooks.php
M composer.json
M maintenance/backfillReadBundles.php
M maintenance/backfillUnreadWikis.php
M maintenance/generateSampleNotifications.php
M maintenance/removeOrphanedEvents.php
M maintenance/testDiscussionParser.php
M maintenance/updateEchoSchemaForSuppression.php
M phpcs.xml
M tests/phpunit/AttributeManagerTest.php
M tests/phpunit/DiscussionParserTest.php
M tests/phpunit/TalkPageFunctionalTest.php
M tests/phpunit/controller/NotificationControllerTest.php
M tests/phpunit/gateway/UserNotificationGatewayTest.php
M tests/phpunit/mapper/NotificationMapperTest.php
15 files changed, 392 insertions(+), 158 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Echo
refs/changes/02/364302/1
diff --git a/Hooks.php b/Hooks.php
index a8d3e2f..6df16d0 100644
--- a/Hooks.php
+++ b/Hooks.php
@@ -17,7 +17,8 @@
$wgDefaultUserOptions['echo-email-format'] =
'plain-text'; /*EchoHooks::EMAIL_FORMAT_PLAIN_TEXT*/
}
- // Set all of the events to notify by web but not email by
default (won't affect events that don't email)
+ // Set all of the events to notify by web but not email by
default
+ // (won't affect events that don't email)
foreach ( $wgEchoNotificationCategories as $category =>
$categoryData ) {
$wgDefaultUserOptions["echo-subscriptions-email-{$category}"] = false;
$wgDefaultUserOptions["echo-subscriptions-web-{$category}"] = true;
@@ -37,10 +38,13 @@
*/
public static function initEchoExtension() {
global $wgEchoNotifications, $wgEchoNotificationCategories,
$wgEchoNotificationIcons,
- $wgEchoEventLoggingSchemas,
$wgEchoMentionStatusNotifications, $wgAllowArticleReminderNotification;
+ $wgEchoEventLoggingSchemas,
$wgEchoMentionStatusNotifications,
+ $wgAllowArticleReminderNotification;
// allow extensions to define their own event
- Hooks::run( 'BeforeCreateEchoEvent', [ &$wgEchoNotifications,
&$wgEchoNotificationCategories, &$wgEchoNotificationIcons ] );
+ Hooks::run( 'BeforeCreateEchoEvent', [
+ &$wgEchoNotifications, &$wgEchoNotificationCategories,
&$wgEchoNotificationIcons
+ ] );
// Only allow mention status notifications when enabled
if ( !$wgEchoMentionStatusNotifications ) {
@@ -192,42 +196,65 @@
$updater->addExtensionTable( 'echo_target_page',
"$dir/db_patches/echo_target_page.sql" );
if ( $updater->getDB()->getType() === 'sqlite' ) {
- $updater->modifyExtensionField( 'echo_event',
'event_agent', "$dir/db_patches/patch-event_agent-split.sqlite.sql" );
- $updater->modifyExtensionField( 'echo_event',
'event_variant', "$dir/db_patches/patch-event_variant_nullability.sqlite.sql" );
- $updater->addExtensionField( 'echo_target_page',
'etp_id', "$dir/db_patches/patch-multiple_target_pages.sqlite.sql" );
- $updater->dropExtensionField( 'echo_target_page',
'etp_user', "$dir/db_patches/patch-drop-echo_target_page-etp_user.sqlite.sql" );
+ $updater->modifyExtensionField( 'echo_event',
'event_agent',
+
"$dir/db_patches/patch-event_agent-split.sqlite.sql" );
+ $updater->modifyExtensionField( 'echo_event',
'event_variant',
+
"$dir/db_patches/patch-event_variant_nullability.sqlite.sql" );
+ $updater->addExtensionField( 'echo_target_page',
'etp_id',
+
"$dir/db_patches/patch-multiple_target_pages.sqlite.sql" );
+ $updater->dropExtensionField( 'echo_target_page',
'etp_user',
+
"$dir/db_patches/patch-drop-echo_target_page-etp_user.sqlite.sql" );
// There is no need to run the patch-event_extra-size
or patch-event_agent_ip-size because
// sqlite ignores numeric arguments in parentheses that
follow the type name (ex: VARCHAR(255))
// see http://www.sqlite.org/datatype3.html Section 2.2
for more info
} else {
- $updater->modifyExtensionField( 'echo_event',
'event_agent', "$dir/db_patches/patch-event_agent-split.sql" );
- $updater->modifyExtensionField( 'echo_event',
'event_variant', "$dir/db_patches/patch-event_variant_nullability.sql" );
- $updater->modifyExtensionField( 'echo_event',
'event_extra', "$dir/db_patches/patch-event_extra-size.sql" );
- $updater->modifyExtensionField( 'echo_event',
'event_agent_ip', "$dir/db_patches/patch-event_agent_ip-size.sql" );
- $updater->addExtensionField( 'echo_target_page',
'etp_id', "$dir/db_patches/patch-multiple_target_pages.sql" );
- $updater->dropExtensionField( 'echo_target_page',
'etp_user', "$dir/db_patches/patch-drop-echo_target_page-etp_user.sql" );
+ $updater->modifyExtensionField( 'echo_event',
'event_agent',
+ "$dir/db_patches/patch-event_agent-split.sql" );
+ $updater->modifyExtensionField( 'echo_event',
'event_variant',
+
"$dir/db_patches/patch-event_variant_nullability.sql" );
+ $updater->modifyExtensionField( 'echo_event',
'event_extra',
+ "$dir/db_patches/patch-event_extra-size.sql" );
+ $updater->modifyExtensionField( 'echo_event',
'event_agent_ip',
+ "$dir/db_patches/patch-event_agent_ip-size.sql"
);
+ $updater->addExtensionField( 'echo_target_page',
'etp_id',
+
"$dir/db_patches/patch-multiple_target_pages.sql" );
+ $updater->dropExtensionField( 'echo_target_page',
'etp_user',
+
"$dir/db_patches/patch-drop-echo_target_page-etp_user.sql" );
}
$updater->addExtensionField( 'echo_notification',
'notification_bundle_base',
"$dir/db_patches/patch-notification-bundling-field.sql"
);
- // This index was renamed twice, first from type_page to
event_type and later from event_type to echo_event_type
+ // This index was renamed twice, first from type_page to
event_type and
+ // later from event_type to echo_event_type
if ( $updater->getDB()->indexExists( 'echo_event', 'type_page',
__METHOD__ ) ) {
- $updater->addExtensionIndex( 'echo_event',
'event_type', "$dir/db_patches/patch-alter-type_page-index.sql" );
+ $updater->addExtensionIndex( 'echo_event', 'event_type',
+
"$dir/db_patches/patch-alter-type_page-index.sql" );
}
- $updater->dropExtensionTable( 'echo_subscription',
"$dir/db_patches/patch-drop-echo_subscription.sql" );
- $updater->dropExtensionField( 'echo_event', 'event_timestamp',
"$dir/db_patches/patch-drop-echo_event-event_timestamp.sql" );
+ $updater->dropExtensionTable( 'echo_subscription',
+ "$dir/db_patches/patch-drop-echo_subscription.sql" );
+ $updater->dropExtensionField( 'echo_event', 'event_timestamp',
+
"$dir/db_patches/patch-drop-echo_event-event_timestamp.sql" );
$updater->addExtensionField( 'echo_email_batch',
'eeb_event_hash',
"$dir/db_patches/patch-email_batch-new-field.sql" );
- $updater->addExtensionField( 'echo_event', 'event_page_id',
"$dir/db_patches/patch-add-echo_event-event_page_id.sql" );
- $updater->addExtensionIndex( 'echo_event', 'echo_event_type',
"$dir/db_patches/patch-alter-event_type-index.sql" );
- $updater->addExtensionIndex( 'echo_notification',
'echo_user_timestamp', "$dir/db_patches/patch-alter-user_timestamp-index.sql" );
- $updater->addExtensionIndex( 'echo_notification',
'echo_notification_event',
"$dir/db_patches/patch-add-notification_event-index.sql" );
+ $updater->addExtensionField( 'echo_event', 'event_page_id',
+
"$dir/db_patches/patch-add-echo_event-event_page_id.sql" );
+ $updater->addExtensionIndex( 'echo_event', 'echo_event_type',
+ "$dir/db_patches/patch-alter-event_type-index.sql" );
+ $updater->addExtensionIndex( 'echo_notification',
'echo_user_timestamp',
+ "$dir/db_patches/patch-alter-user_timestamp-index.sql"
);
+ $updater->addExtensionIndex( 'echo_notification',
'echo_notification_event',
+
"$dir/db_patches/patch-add-notification_event-index.sql" );
$updater->addPostDatabaseUpdateMaintenance(
'RemoveOrphanedEvents' );
- $updater->addExtensionField( 'echo_event', 'event_deleted',
"$dir/db_patches/patch-add-echo_event-event_deleted.sql" );
- $updater->addExtensionIndex( 'echo_notification',
'echo_notification_user_read_timestamp',
"$dir/db_patches/patch-add-user_read_timestamp-index.sql" );
- $updater->addExtensionIndex( 'echo_target_page',
'echo_target_page_page_event', "$dir/db_patches/patch-add-page_event-index.sql"
);
- $updater->addExtensionIndex( 'echo_event',
'echo_event_page_id', "$dir/db_patches/patch-add-event_page_id-index.sql" );
- $updater->dropExtensionIndex( 'echo_notification',
'user_event', "$dir/db_patches/patch-notification-pk.sql" );
+ $updater->addExtensionField( 'echo_event', 'event_deleted',
+
"$dir/db_patches/patch-add-echo_event-event_deleted.sql" );
+ $updater->addExtensionIndex( 'echo_notification',
'echo_notification_user_read_timestamp',
+
"$dir/db_patches/patch-add-user_read_timestamp-index.sql" );
+ $updater->addExtensionIndex( 'echo_target_page',
'echo_target_page_page_event',
+ "$dir/db_patches/patch-add-page_event-index.sql" );
+ $updater->addExtensionIndex( 'echo_event', 'echo_event_page_id',
+ "$dir/db_patches/patch-add-event_page_id-index.sql" );
+ $updater->dropExtensionIndex( 'echo_notification', 'user_event',
+ "$dir/db_patches/patch-notification-pk.sql" );
}
/**
@@ -288,7 +315,8 @@
'rtl' =>
"$wgExtensionAssetsPath/Echo/images/betafeatures-icon-notifications-rtl.svg",
'ltr' =>
"$wgExtensionAssetsPath/Echo/images/betafeatures-icon-notifications-ltr.svg",
],
- 'info-link' =>
'https://www.mediawiki.org/wiki/Special:Mylanguage/Help:Notifications/Cross-wiki',
+ 'info-link' =>
+
'https://www.mediawiki.org/wiki/Special:Mylanguage/Help:Notifications/Cross-wiki',
// Link to discussion about the feature - talk
pages might work
'discussion-link' =>
'https://www.mediawiki.org/wiki/Help_talk:Notifications',
];
@@ -373,7 +401,8 @@
'section' => 'echo/emailsettings',
'options' => [
wfMessage(
'echo-pref-email-format-html' )->plain() => EchoEmailFormat::HTML,
- wfMessage(
'echo-pref-email-format-plain-text' )->plain() => EchoEmailFormat::PLAIN_TEXT,
+ wfMessage(
'echo-pref-email-format-plain-text' )->plain() =>
+ EchoEmailFormat::PLAIN_TEXT,
]
];
}
@@ -388,7 +417,8 @@
// See if user is eligible to receive this notification
(per user group restrictions)
if ( $attributeManager->getCategoryEligibility( $user,
$category ) ) {
- $categoriesAndPriorities[$category] =
$attributeManager->getCategoryPriority( $category );
+ $categoriesAndPriorities[$category] =
+ $attributeManager->getCategoryPriority(
$category );
}
}
asort( $categoriesAndPriorities );
@@ -413,10 +443,12 @@
$rows = [];
$tooltips = [];
foreach ( $validSortedCategories as $category ) {
- $categoryMessage = wfMessage( 'echo-category-title-' .
$category )->numParams( 1 )->escaped();
+ $categoryMessage = wfMessage( 'echo-category-title-' .
$category )
+ ->numParams( 1 )->escaped();
$rows[$categoryMessage] = $category;
if ( isset(
$wgEchoNotificationCategories[$category]['tooltip'] ) ) {
- $tooltips[$categoryMessage] = wfMessage(
$wgEchoNotificationCategories[$category]['tooltip'] )->text();
+ $tooltips[$categoryMessage] =
+ wfMessage(
$wgEchoNotificationCategories[$category]['tooltip'] )->text();
}
}
@@ -425,11 +457,15 @@
foreach ( $wgEchoNotifiers as $notifierType => $notifierData ) {
foreach ( $validSortedCategories as $category ) {
// See if this notify type is non-dismissable
- if (
!$attributeManager->isNotifyTypeDismissableForCategory( $category,
$notifierType ) ) {
+ if ( !$attributeManager
+ ->isNotifyTypeDismissableForCategory(
$category, $notifierType )
+ ) {
$forceOptionsOn[] =
"$notifierType-$category";
}
- if (
!$attributeManager->isNotifyTypeAvailableForCategory( $category, $notifierType
) ) {
+ if ( !$attributeManager
+ ->isNotifyTypeAvailableForCategory(
$category, $notifierType )
+ ) {
$forceOptionsOff[] =
"$notifierType-$category";
}
}
@@ -529,8 +565,10 @@
* @param $undidRevId Int
* @return bool true in all cases
*/
- public static function onPageContentSaveComplete( &$article, &$user,
$content, $summary, $minoredit,
- $watchthis, $sectionanchor, &$flags, $revision, &$status,
$baseRevId, $undidRevId = 0 ) {
+ public static function onPageContentSaveComplete(
+ &$article, &$user, $content, $summary, $minoredit,
+ $watchthis, $sectionanchor, &$flags, $revision, &$status,
$baseRevId, $undidRevId = 0
+ ) {
global $wgEchoNotifications;
if ( !$revision ) {
@@ -556,25 +594,30 @@
if ( $user->isLoggedIn() && $status->value['revision'] ) {
$thresholdCount = $user->getEditCount();
if ( in_array( $thresholdCount, $thresholds ) ) {
- DeferredUpdates::addCallableUpdate( function ()
use ( $user, $title, $thresholdCount ) {
- $notificationMapper = new
EchoNotificationMapper();
- $notifications =
$notificationMapper->fetchByUser( $user, 10, null, [ 'thank-you-edit' ] );
- /** @var EchoNotification $notification
*/
- foreach ( $notifications as
$notification ) {
- if (
$notification->getEvent()->getExtraParam( 'editCount' ) === $thresholdCount ) {
-
LoggerFactory::getInstance( 'Echo' )->debug(
- '{user} (id:
{id}) has already been thanked for their {count} edit',
- [
- 'user'
=> $user->getName(),
- 'id' =>
$user->getId(),
- 'count'
=> $thresholdCount,
- ]
- );
- return;
+ DeferredUpdates::addCallableUpdate(
+ function () use ( $user, $title,
$thresholdCount ) {
+ $notificationMapper = new
EchoNotificationMapper();
+ $notifications =
$notificationMapper->fetchByUser(
+ $user, 10, null, [
'thank-you-edit' ]
+ );
+ /** @var EchoNotification
$notification */
+ foreach ( $notifications as
$notification ) {
+ if (
$notification->getEvent()->getExtraParam( 'editCount' ) ===
+ $thresholdCount
+ ) {
+
LoggerFactory::getInstance( 'Echo' )->debug(
+ '{user}
(id: {id}) has already been thanked for their {count} edit',
+ [
+
'user' => $user->getName(),
+
'id' => $user->getId(),
+
'count' => $thresholdCount,
+ ]
+ );
+ return;
+ }
}
- }
- EchoEvent::create( [
+ EchoEvent::create( [
'type' =>
'thank-you-edit',
'title' => $title,
'agent' => $user,
@@ -583,9 +626,9 @@
'notifyAgent'
=> true,
'editCount' =>
$thresholdCount,
]
- ]
- );
- } );
+ ] );
+ }
+ );
}
}
@@ -791,7 +834,9 @@
// Rollback or undo should not trigger link notification
// @Todo Implement a better solution so it doesn't depend on
the checking of
// a specific set of request variables
- if ( $wgRequest->getVal( 'wpUndidRevision' ) ||
$wgRequest->getVal( 'action' ) == 'rollback' ) {
+ if ( $wgRequest->getVal( 'wpUndidRevision' ) ||
+ $wgRequest->getVal( 'action' ) == 'rollback'
+ ) {
return true;
}
@@ -800,7 +845,8 @@
// 2. content namespace pages &&
// 3. non-transcluding pages &&
// 4. non-redirect pages
- if ( $table !== 'pagelinks' || !MWNamespace::isContent(
$linksUpdate->mTitle->getNamespace() )
+ if ( $table !== 'pagelinks' ||
+ !MWNamespace::isContent(
$linksUpdate->mTitle->getNamespace() )
|| !$linksUpdate->mRecursive ||
$linksUpdate->mTitle->isRedirect()
) {
return true;
@@ -986,7 +1032,9 @@
// HACK: inverted icons only work in the "MediaWiki" OOUI theme
// Avoid flashes in skins that don't use it (T111821)
- $sk->getOutput()->setupOOUI( strtolower( $sk->getSkinName() ),
$sk->getOutput()->getLanguage()->getDir() );
+ $sk->getOutput()->setupOOUI(
+ strtolower( $sk->getSkinName() ),
$sk->getOutput()->getLanguage()->getDir()
+ );
$msgLinkClasses = [ "mw-echo-notifications-badge",
"mw-echo-notification-badge-nojs" ];
$alertLinkClasses = [ "mw-echo-notifications-badge",
"mw-echo-notification-badge-nojs" ];
@@ -995,7 +1043,9 @@
if (
$msgCount != 0 && // no unread notifications
$msgNotificationTimestamp !== false && // should
already always be false if count === 0
- ( $seenMsgTime === null || $seenMsgTime <
$msgNotificationTimestamp->getTimestamp( TS_ISO_8601 ) ) // there are no unseen
notifications
+ // there are no unseen notifications
+ ( $seenMsgTime === null ||
+ $seenMsgTime < $msgNotificationTimestamp->getTimestamp(
TS_ISO_8601 ) )
) {
$msgLinkClasses[] = 'mw-echo-unseen-notifications';
$hasUnseen = true;
@@ -1010,7 +1060,9 @@
if (
$alertCount != 0 && // no unread notifications
$alertNotificationTimestamp !== false && // should
already always be false if count === 0
- ( $seenAlertTime === null || $seenAlertTime <
$alertNotificationTimestamp->getTimestamp( TS_ISO_8601 ) ) // all notifications
have already been seen
+ // all notifications have already been seen
+ ( $seenAlertTime === null ||
+ $seenAlertTime <
$alertNotificationTimestamp->getTimestamp( TS_ISO_8601 ) )
) {
$alertLinkClasses[] = 'mw-echo-unseen-notifications';
$hasUnseen = true;
@@ -1104,17 +1156,21 @@
* @see
http://www.mediawiki.org/wiki/Manual:Hooks/AbortWatchlistEmailNotification
* @param $targetUser User
* @param $title Title
- * @param $emailNotification EmailNotification The email notification
object that sends non-echo notifications
+ * @param $emailNotification EmailNotification The email notification
object that
+ * sends non-echo notifications
* @return bool
*/
- public static function onSendWatchlistEmailNotification( $targetUser,
$title, $emailNotification ) {
+ public static function onSendWatchlistEmailNotification(
+ $targetUser, $title, $emailNotification
+ ) {
// If a user is watching his/her own talk page, do not send
talk page watchlist
// email notification if the user is receiving Echo talk page
notification
if ( $title->isTalkPage() &&
$targetUser->getTalkPage()->equals( $title ) ) {
$attributeManager =
EchoAttributeManager::newFromGlobalVars();
$events = $attributeManager->getUserEnabledEvents(
$targetUser, 'email' );
if ( in_array( 'edit-user-talk', $events ) ) {
- // Do not send watchlist email notification,
the user will receive an Echo notification
+ // Do not send watchlist email notification,
+ // the user will receive an Echo notification
return false;
}
}
@@ -1162,8 +1218,10 @@
$modifiedTimes['notifications-global'] =
$lastUpdate;
}
- $modifiedTimes['notifications-seen-alert'] =
EchoSeenTime::newFromUser( $user )->getTime( 'alert' );
- $modifiedTimes['notifications-seen-message'] =
EchoSeenTime::newFromUser( $user )->getTime( 'message' );
+ $modifiedTimes['notifications-seen-alert'] =
EchoSeenTime::newFromUser( $user )
+ ->getTime( 'alert' );
+ $modifiedTimes['notifications-seen-message'] =
EchoSeenTime::newFromUser( $user )
+ ->getTime( 'message' );
}
}
@@ -1212,7 +1270,8 @@
if (
$victimId && // No notifications for anonymous users
- !$oldRevision->getContent()->equals(
$newRevision->getContent() ) // No notifications for null rollbacks
+ // No notifications for null rollbacks
+ !$oldRevision->getContent()->equals(
$newRevision->getContent() )
) {
EchoEvent::create( [
'type' => 'reverted',
@@ -1336,8 +1395,10 @@
$autoSubject = wfMessage( 'defemailsubject', $from->name
)->inContentLanguage()->text();
if ( $subject === $autoSubject ) {
- $autoFooter = "\n\n-- \n" . wfMessage(
'emailuserfooter', $from->name, $address->name )->inContentLanguage()->text();
- $textWithoutFooter = preg_replace( '/' . preg_quote(
$autoFooter, '/' ) . '$/', '', $text );
+ $autoFooter = "\n\n-- \n" . wfMessage(
'emailuserfooter', $from->name, $address->name )
+ ->inContentLanguage()->text();
+ $textWithoutFooter =
+ preg_replace( '/' . preg_quote( $autoFooter,
'/' ) . '$/', '', $text );
$preview = $wgContLang->truncate( $textWithoutFooter,
125 );
} else {
$preview = $subject;
@@ -1365,8 +1426,12 @@
// array( tableName, idField, textField )
$dbw = MWEchoDbFactory::newFromDefault()->getEchoDb( DB_MASTER
);
$updateFields[] = [ 'echo_event', 'event_agent_id', 'db' =>
$dbw ];
- $updateFields[] = [ 'echo_notification', 'notification_user',
'db' => $dbw, 'options' => [ 'IGNORE' ] ];
- $updateFields[] = [ 'echo_email_batch', 'eeb_user_id', 'db' =>
$dbw, 'options' => [ 'IGNORE' ] ];
+ $updateFields[] = [
+ 'echo_notification', 'notification_user', 'db' => $dbw,
'options' => [ 'IGNORE' ]
+ ];
+ $updateFields[] = [
+ 'echo_email_batch', 'eeb_user_id', 'db' => $dbw,
'options' => [ 'IGNORE' ]
+ ];
return true;
}
@@ -1410,7 +1475,14 @@
return true;
}
- public static function onArticleDeleteComplete( WikiPage &$article,
User &$user, $reason, $articleId, Content $content = null, LogEntry $logEntry )
{
+ public static function onArticleDeleteComplete(
+ WikiPage &$article,
+ User &$user,
+ $reason,
+ $articleId,
+ Content $content = null,
+ LogEntry $logEntry
+ ) {
\DeferredUpdates::addCallableUpdate( function () use (
$articleId ) {
$eventMapper = new EchoEventMapper();
$eventIds = $eventMapper->fetchIdsByPage( $articleId );
diff --git a/composer.json b/composer.json
index 49c2a1c..1366381 100644
--- a/composer.json
+++ b/composer.json
@@ -7,7 +7,7 @@
"scripts": {
"test": [
"parallel-lint . --exclude vendor",
- "phpcs -p"
+ "phpcs -p -s"
],
"fix": [
"phpcbf"
diff --git a/maintenance/backfillReadBundles.php
b/maintenance/backfillReadBundles.php
index db38cee..3b22e1b 100644
--- a/maintenance/backfillReadBundles.php
+++ b/maintenance/backfillReadBundles.php
@@ -27,7 +27,9 @@
[ 'notification_user', 'notification_event' ],
$this->mBatchSize
);
- $iterator->setFetchColumns( [
'notification_bundle_display_hash', 'notification_read_timestamp' ] );
+ $iterator->setFetchColumns( [
+ 'notification_bundle_display_hash',
'notification_read_timestamp'
+ ] );
$unreadNonBase = $dbr->selectSQLText(
'echo_notification',
@@ -64,7 +66,8 @@
);
if ( !$result ) {
- $this->output( "Failed to set
read_timestamp on notifications with bundle_display_hash: $displayHash\n" );
+ $this->output( "Failed to set
read_timestamp on notifications with " .
+ "bundle_display_hash:
$displayHash\n" );
}
$processed += $dbw->affectedRows();
diff --git a/maintenance/backfillUnreadWikis.php
b/maintenance/backfillUnreadWikis.php
index c89f24e..08b7372 100644
--- a/maintenance/backfillUnreadWikis.php
+++ b/maintenance/backfillUnreadWikis.php
@@ -22,10 +22,17 @@
$rebuild = $this->hasOption( 'rebuild' );
if ( $rebuild ) {
- $iterator = new BatchRowIterator(
$dbFactory->getSharedDb( DB_SLAVE ), 'echo_unread_wikis', 'euw_user',
$this->mBatchSize );
+ $iterator = new BatchRowIterator(
+ $dbFactory->getSharedDb( DB_SLAVE ),
+ 'echo_unread_wikis',
+ 'euw_user',
+ $this->mBatchSize
+ );
$iterator->addConditions( [ 'euw_wiki' => wfWikiID() ]
);
} else {
- $iterator = new BatchRowIterator( wfGetDB( DB_SLAVE ),
'user', 'user_id', $this->mBatchSize );
+ $iterator = new BatchRowIterator(
+ wfGetDB( DB_SLAVE ), 'user', 'user_id',
$this->mBatchSize
+ );
$iterator->setFetchColumns( User::selectFields() );
}
@@ -33,7 +40,9 @@
foreach ( $iterator as $batch ) {
foreach ( $batch as $row ) {
if ( $rebuild ) {
- $user =
$lookup->localUserFromCentralId( $row->euw_user, CentralIdLookup::AUDIENCE_RAW
);
+ $user = $lookup->localUserFromCentralId(
+ $row->euw_user,
CentralIdLookup::AUDIENCE_RAW
+ );
} else {
$user = User::newFromRow( $row );
}
@@ -44,21 +53,34 @@
$notifUser = MWEchoNotifUser::newFromUser(
$user );
$uw = EchoUnreadWikis::newFromUser( $user );
if ( $uw ) {
- $alertCount =
$notifUser->getNotificationCount( true, DB_SLAVE, EchoAttributeManager::ALERT,
false );
- $alertUnread =
$notifUser->getLastUnreadNotificationTime( true, DB_SLAVE,
EchoAttributeManager::ALERT, false );
+ $alertCount =
$notifUser->getNotificationCount(
+ true, DB_SLAVE,
EchoAttributeManager::ALERT, false
+ );
+ $alertUnread =
$notifUser->getLastUnreadNotificationTime(
+ true, DB_SLAVE,
EchoAttributeManager::ALERT, false
+ );
- $msgCount =
$notifUser->getNotificationCount( true, DB_SLAVE,
EchoAttributeManager::MESSAGE, false );
- $msgUnread =
$notifUser->getLastUnreadNotificationTime( true, DB_SLAVE,
EchoAttributeManager::MESSAGE, false );
+ $msgCount =
$notifUser->getNotificationCount(
+ true, DB_SLAVE,
EchoAttributeManager::MESSAGE, false
+ );
+ $msgUnread =
$notifUser->getLastUnreadNotificationTime(
+ true, DB_SLAVE,
EchoAttributeManager::MESSAGE, false
+ );
- if ( ( $alertCount !== 0 &&
$alertUnread === false ) || ( $msgCount !== 0 && $msgUnread === false ) ) {
- // If there are alerts, there
should be an alert timestamp (same for messages).
+ if ( ( $alertCount !== 0 &&
$alertUnread === false ) ||
+ ( $msgCount !== 0 && $msgUnread
=== false )
+ ) {
+ // If there are alerts,
+ // there should be an alert
timestamp (same for messages).
- // Otherwise, there is a race
condition between the two values, indicating there's already
- // just been an updateCount
call, so we can skip this user.
+ // Otherwise, there is a race
condition between the two values, indicating
+ // there's already just been an
updateCount call, so we can skip this user.
continue;
}
- $uw->updateCount( wfWikiID(),
$alertCount, $alertUnread, $msgCount, $msgUnread );
+ $uw->updateCount(
+ wfWikiID(), $alertCount,
$alertUnread, $msgCount, $msgUnread
+ );
}
}
diff --git a/maintenance/generateSampleNotifications.php
b/maintenance/generateSampleNotifications.php
index ed6070c..474628e 100644
--- a/maintenance/generateSampleNotifications.php
+++ b/maintenance/generateSampleNotifications.php
@@ -67,7 +67,9 @@
$user = $this->getOptionUser( 'user' );
$agent = $this->getOptionUser( 'agent' );
$otherUser = $this->getOptionUser( 'other' );
- $title = Title::newFromText( 'This is a pretty long page title
lets see if it is going to be truncated' );
+ $title = Title::newFromText(
+ 'This is a pretty long page title lets see if it is
going to be truncated'
+ );
$types = $this->getOption( 'types' );
if ( $types ) {
@@ -148,7 +150,10 @@
}
private function generateRandomString( $length = 10 ) {
- return substr( str_shuffle(
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" ), 0, $length
);
+ return substr(
+ str_shuffle(
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" ),
+ 0, $length
+ );
}
protected function confirm() {
@@ -197,22 +202,27 @@
}
private function generateMention( User $user, User $agent, User
$otherUser, Title $title ) {
- $mention = "== section {$this->generateRandomString()}
==\nHello [[User:{$user->getName()}]] \n~~~~\n";
+ $mention = "== section {$this->generateRandomString()} ==" .
+ "\nHello [[User:{$user->getName()}]] \n~~~~\n";
// article talk
- $this->output( "{$agent->getName()} is mentioning
{$user->getName()} on {$title->getTalkPage()->getPrefixedText()}\n" );
+ $this->output( "{$agent->getName()} is mentioning
{$user->getName()} on " .
+ "{$title->getTalkPage()->getPrefixedText()}\n" );
$this->addToPageContent( $title->getTalkPage(), $agent,
$mention );
// agent tak
- $this->output( "{$agent->getName()} is mentioning
{$user->getName()} on {$agent->getTalkPage()->getPrefixedText()}\n" );
+ $this->output( "{$agent->getName()} is mentioning
{$user->getName()} on " .
+ "{$agent->getTalkPage()->getPrefixedText()}\n" );
$this->addToPageContent( $agent->getTalkPage(), $agent,
$mention );
// user talk
- $this->output( "{$agent->getName()} is mentioning
{$user->getName()} on {$otherUser->getTalkPage()->getPrefixedText()}\n" );
+ $this->output( "{$agent->getName()} is mentioning
{$user->getName()} on " .
+ "{$otherUser->getTalkPage()->getPrefixedText()}\n" );
$this->addToPageContent( $otherUser->getTalkPage(), $agent,
$mention );
// any other page
- $this->output( "{$agent->getName()} is mentioning
{$user->getName()} on {$title->getPrefixedText()}\n" );
+ $this->output( "{$agent->getName()} is mentioning
{$user->getName()} on " .
+ "{$title->getPrefixedText()}\n" );
$this->addToPageContent( $title, $agent, $mention );
}
@@ -231,11 +241,16 @@
// revert (undo)
$moai = Title::newFromText( 'Moai' );
$page = WikiPage::factory( $moai );
- $this->output( "{$agent->getName()} is reverting
{$user->getName()}'s edit on {$moai->getPrefixedText()}\n" );
+ $this->output( "{$agent->getName()} is reverting
{$user->getName()}'s edit on " .
+ "{$moai->getPrefixedText()}\n" );
$this->addToPageContent( $moai, $agent, "\ncreating a good
revision here\n" );
$this->addToPageContent( $moai, $user, "\nadding a line here\n"
);
- $content = $page->getUndoContent( $page->getRevision(),
$page->getRevision()->getPrevious() );
- $status = $page->doEditContent( $content, 'undo', 0, false,
$agent, null, [], $page->getRevision()->getId() );
+ $content = $page->getUndoContent(
+ $page->getRevision(),
$page->getRevision()->getPrevious()
+ );
+ $status = $page->doEditContent(
+ $content, 'undo', 0, false, $agent, null, [],
$page->getRevision()->getId()
+ );
if ( !$status->isGood() ) {
$this->error( "Failed to undo
{$moai->getPrefixedText()}: {$status->getMessage()}" );
}
@@ -243,13 +258,16 @@
// rollback
$moai2 = Title::newFromText( 'Moai2' );
$page = WikiPage::factory( $moai2 );
- $this->output( "{$agent->getName()} is rolling back
{$user->getName()}'s edits on {$moai2->getPrefixedText()}\n" );
+ $this->output( "{$agent->getName()} is rolling back
{$user->getName()}'s edits on " .
+ "{$moai2->getPrefixedText()}\n" );
$this->addToPageContent( $moai2, $agent, "\ncreating a good
revision here\n" );
$this->addToPageContent( $moai2, $user, "\nadding a line
here\n" );
$this->addToPageContent( $moai2, $user, "\nadding a line
here\n" );
$details = [];
$token = $agent->getEditToken( 'rollback', null );
- $errors = $page->doRollback( $user->getName(), 'generating
reverted notification', $token, false, $details, $agent );
+ $errors = $page->doRollback(
+ $user->getName(), 'generating reverted notification',
$token, false, $details, $agent
+ );
if ( $errors ) {
$this->error( serialize( $errors ) );
}
@@ -281,8 +299,12 @@
private function generateUserRights( User $user, User $agent ) {
$this->output( "{$agent->getName()} is changing
{$user->getName()}'s rights\n" );
$this->createUserRightsNotification( $user, $agent, [
'OnlyAdd-1' ], null );
- $this->createUserRightsNotification( $user, $agent, null, [
'JustRemove-1', 'JustRemove-2' ] );
- $this->createUserRightsNotification( $user, $agent, [ 'Add-1',
'Add-2' ], [ 'Remove-1', 'Remove-2' ] );
+ $this->createUserRightsNotification(
+ $user, $agent, null, [ 'JustRemove-1', 'JustRemove-2' ]
+ );
+ $this->createUserRightsNotification(
+ $user, $agent, [ 'Add-1', 'Add-2' ], [ 'Remove-1',
'Remove-2' ]
+ );
}
private function createUserRightsNotification( User $user, User $agent,
$add, $remove ) {
@@ -306,7 +328,10 @@
}
$this->output( "Generating CX notifications\n" );
- foreach ( [ 'cx-first-translation', 'cx-tenth-translation',
'cx-hundredth-translation' ] as $eventType ) {
+ foreach ( [
+ 'cx-first-translation', 'cx-tenth-translation',
'cx-hundredth-translation'
+ ] as $eventType
+ ) {
EchoEvent::create(
[
'type' => $eventType,
@@ -334,7 +359,8 @@
$pageLinking = $this->generateNewPageTitle();
$content = "checkout
[[{$pageBeingLinked->getPrefixedText()}]]!";
- $this->output( "{$agent->getName()} is linking to
{$pageBeingLinked->getPrefixedText()} from {$pageLinking->getPrefixedText()}\n"
);
+ $this->output( "{$agent->getName()} is linking to
{$pageBeingLinked->getPrefixedText()} " .
+ "from {$pageLinking->getPrefixedText()}\n" );
$this->addToPageContent( $pageLinking, $agent, $content );
}
@@ -343,7 +369,8 @@
$this->addToPageContent( $pageBeingLinked, $user, "this is a
new page" );
$content = "checkout
[[{$pageBeingLinked->getPrefixedText()}]]!";
- $this->output( "{$agent->getName()} is linking to
{$pageBeingLinked->getPrefixedText()} from multiple pages\n" );
+ $this->output( "{$agent->getName()} is linking to
{$pageBeingLinked->getPrefixedText()} " .
+ "from multiple pages\n" );
$this->addToPageContent( $this->generateNewPageTitle(), $agent,
$content );
$this->addToPageContent( $this->generateNewPageTitle(), $agent,
$content );
$this->addToPageContent( $this->generateNewPageTitle(), $agent,
$content );
@@ -403,7 +430,8 @@
],
'agent' => $agent,
] );
- $this->output( "{$agent->getName()} is thanking
{$user->getName()} for edit {$revision->getId()} on
{$title->getPrefixedText()}\n" );
+ $this->output( "{$agent->getName()} is thanking
{$user->getName()} for edit " .
+ "{$revision->getId()} on {$title->getPrefixedText()}\n"
);
}
private function generateMultipleEditThanks( User $user, User $agent,
User $otherUser ) {
if ( !class_exists( 'ThanksHooks' ) ) {
@@ -432,7 +460,8 @@
],
'agent' => $otherUser,
] );
- $this->output( "{$agent->getName()} and {$otherUser->getName()}
are thanking {$user->getName()} for edit {$revision->getId()} on
{$title->getPrefixedText()}\n" );
+ $this->output( "{$agent->getName()} and {$otherUser->getName()}
are thanking " .
+ "{$user->getName()} for edit {$revision->getId()} on
{$title->getPrefixedText()}\n" );
}
private function generateEducationProgram( User $user, User $agent ) {
@@ -443,12 +472,17 @@
$chem101 = Title::newFromText( 'School/Chemistry101' );
if ( !$chem101->exists() ) {
- $this->addToPageContent( $chem101, $agent, "\nThis is
the main page for the Chemistry 101 course\n" );
+ $this->addToPageContent(
+ $chem101, $agent, "\nThis is the main page for
the Chemistry 101 course\n"
+ );
}
- $notificationManager =
EducationProgram\Extension::globalInstance()->getNotificationsManager();
+ $notificationManager =
+
EducationProgram\Extension::globalInstance()->getNotificationsManager();
- $this->output( "{$agent->getName()} is adding
{$user->getName()} to {$chem101->getPrefixedText()} as instructor, student,
campus volunteer and online volunteer.\n" );
+ $this->output(
+ "{$agent->getName()} is adding {$user->getName()} to
{$chem101->getPrefixedText()} " .
+ "as instructor, student, campus volunteer and
online volunteer.\n" );
$types = [
'ep-instructor-add-notification',
@@ -468,7 +502,7 @@
}
// NOTE: Not generating 'ep-course-talk-notification' for now
- // as it requires a full setup to actually work (institution,
course, instructors, students).
+ // as it requires a full setup to actually work (institution,
course, instructors, students)
}
private function generateWikibase( User $user, User $agent ) {
@@ -482,7 +516,8 @@
$helpPage = Title::newFromText( 'Project:Wikidata' );
$this->addToPageContent( $helpPage, $user, "this is the help
page" );
- $this->output( "{$agent->getName()} is connecting
{$user->getName()}'s page {$title->getPrefixedText()} to an item\n" );
+ $this->output( "{$agent->getName()} is connecting
{$user->getName()}'s page " .
+ "{$title->getPrefixedText()} to an item\n" );
EchoEvent::create( [
'type' =>
Wikibase\Client\Hooks\EchoNotificationsHandlers::NOTIFICATION_TYPE,
'title' => $title,
diff --git a/maintenance/removeOrphanedEvents.php
b/maintenance/removeOrphanedEvents.php
index eb0cba2..c25f319 100644
--- a/maintenance/removeOrphanedEvents.php
+++ b/maintenance/removeOrphanedEvents.php
@@ -18,7 +18,8 @@
public function __construct() {
parent::__construct();
- $this->mDescription = "Remove rows from echo_event that don't
have corresponding rows in echo_notification";
+ $this->mDescription = "Remove rows from echo_event that don't
have corresponding rows " .
+ "in echo_notification";
$this->setBatchSize( 500 );
diff --git a/maintenance/testDiscussionParser.php
b/maintenance/testDiscussionParser.php
index 4aef748..6cd6419 100644
--- a/maintenance/testDiscussionParser.php
+++ b/maintenance/testDiscussionParser.php
@@ -84,7 +84,8 @@
$user = $pageData['revisions'][0]['user'];
print
"http://en.wikipedia.org/w/index.php?diff=prev&oldid=$revid\n";
- EchoDiscussionParser::getInterestedUsers( $oldText,
$newText, $user ); // FIXME: getInterestedUsers() is undefined
+ // FIXME: getInterestedUsers() is undefined
+ EchoDiscussionParser::getInterestedUsers( $oldText,
$newText, $user );
}
}
}
diff --git a/maintenance/updateEchoSchemaForSuppression.php
b/maintenance/updateEchoSchemaForSuppression.php
index c6a6118..1b8bd93 100644
--- a/maintenance/updateEchoSchemaForSuppression.php
+++ b/maintenance/updateEchoSchemaForSuppression.php
@@ -39,12 +39,16 @@
public function doDBUpdates() {
global $wgEchoCluster;
- $reader = new BatchRowIterator( MWEchoDbFactory::getDB(
DB_SLAVE ), $this->table, $this->idField, $this->mBatchSize );
+ $reader = new BatchRowIterator(
+ MWEchoDbFactory::getDB( DB_SLAVE ), $this->table,
$this->idField, $this->mBatchSize
+ );
$reader->addConditions( [
"event_page_title IS NOT NULL",
"event_page_id" => null,
] );
- $reader->setFetchColumns( [ 'event_page_namespace',
'event_page_title', 'event_extra', 'event_type' ] );
+ $reader->setFetchColumns(
+ [ 'event_page_namespace', 'event_page_title',
'event_extra', 'event_type' ]
+ );
$updater = new BatchRowUpdate(
$reader,
diff --git a/phpcs.xml b/phpcs.xml
index 4b5d28c..a2cd95b 100644
--- a/phpcs.xml
+++ b/phpcs.xml
@@ -2,7 +2,6 @@
<ruleset name="MediaWiki">
<file>.</file>
<rule ref="./vendor/mediawiki/mediawiki-codesniffer/MediaWiki">
- <exclude name="Generic.Files.LineLength.TooLong" />
<exclude
name="MediaWiki.Commenting.FunctionComment.ExtraParamComment" />
<exclude
name="MediaWiki.Commenting.FunctionComment.MissingParamComment" />
<exclude
name="MediaWiki.Commenting.FunctionComment.MissingParamName" />
@@ -11,10 +10,14 @@
<exclude
name="MediaWiki.Commenting.FunctionComment.ParamNameNoMatch" />
<exclude
name="MediaWiki.Commenting.FunctionComment.MissingDocumentationProtected" />
<exclude
name="MediaWiki.Commenting.FunctionComment.MissingDocumentationPublic" />
+ <exclude name="MediaWiki.Commenting.FunctionComment.WrongStyle"
/>
<exclude
name="MediaWiki.NamingConventions.LowerCamelFunctionsName.FunctionName" />
<exclude
name="MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment" />
</rule>
- <arg name="encoding" value="utf8" />
+ <rule ref="Generic.Files.LineLength">
+
<exclude-pattern>tests/phpunit/DiscussionParserTest.php</exclude-pattern>
+ </rule>
+ <arg name="encoding" value="UTF-8" />
<arg name="extensions" value="php,php5,inc" />
<arg name="colors" />
<exclude-pattern>vendor</exclude-pattern>
diff --git a/tests/phpunit/AttributeManagerTest.php
b/tests/phpunit/AttributeManagerTest.php
index f9b0c93..d1888f6 100644
--- a/tests/phpunit/AttributeManagerTest.php
+++ b/tests/phpunit/AttributeManagerTest.php
@@ -3,7 +3,9 @@
class EchoAttributeManagerTest extends MediaWikiTestCase {
public function testNewFromGlobalVars() {
- $this->assertInstanceOf( 'EchoAttributeManager',
EchoAttributeManager::newFromGlobalVars() );
+ $this->assertInstanceOf(
+ 'EchoAttributeManager',
EchoAttributeManager::newFromGlobalVars()
+ );
}
public static function getUserLocatorsProvider() {
@@ -256,7 +258,10 @@
],
];
$manager = new EchoAttributeManager( $notif, $category, [], [],
[] );
- $this->assertEquals( $manager->getUserEnabledEvents(
$this->mockUser(), 'web' ), [ 'event_two', 'event_three' ] );
+ $this->assertEquals(
+ $manager->getUserEnabledEvents( $this->mockUser(),
'web' ),
+ [ 'event_two', 'event_three' ]
+ );
}
public function testGetUserEnabledEventsbySections() {
@@ -295,13 +300,17 @@
$this->assertEquals( $actual, $expected );
$expected = [ 'event_two' ];
- $actual = $manager->getUserEnabledEventsBySections(
$this->mockUser(), 'web', [ 'message' ] );
+ $actual = $manager->getUserEnabledEventsBySections(
+ $this->mockUser(), 'web', [ 'message' ]
+ );
sort( $expected );
sort( $actual );
$this->assertEquals( $actual, $expected );
$expected = [ 'event_one', 'event_two', 'event_three',
'event_four' ];
- $actual = $manager->getUserEnabledEventsBySections(
$this->mockUser(), 'web', [ 'message', 'alert' ] );
+ $actual = $manager->getUserEnabledEventsBySections(
+ $this->mockUser(), 'web', [ 'message', 'alert' ]
+ );
sort( $expected );
sort( $actual );
$this->assertEquals( $actual, $expected );
@@ -352,7 +361,9 @@
/**
* @dataProvider getEventsByCategoryProvider
*/
- public function testGetEventsByCategory( $message, $expectedMapping,
$categories, $notifications ) {
+ public function testGetEventsByCategory(
+ $message, $expectedMapping, $categories, $notifications
+ ) {
$am = new EchoAttributeManager( $notifications, $categories,
[], [], [] );
$actualMapping = $am->getEventsByCategory();
$this->assertEquals( $expectedMapping, $actualMapping, $message
);
@@ -398,8 +409,17 @@
/**
@dataProvider isNotifyTypeAvailableForCategoryProvider
*/
- public function testIsNotifyTypeAvailableForCategory( $message,
$expected, $categoryName, $notifyType, $defaultNotifyTypeAvailability,
$notifyTypeAvailabilityByCategory ) {
- $am = new EchoAttributeManager( [], [],
$defaultNotifyTypeAvailability, $notifyTypeAvailabilityByCategory, [] );
+ public function testIsNotifyTypeAvailableForCategory(
+ $message,
+ $expected,
+ $categoryName,
+ $notifyType,
+ $defaultNotifyTypeAvailability,
+ $notifyTypeAvailabilityByCategory
+ ) {
+ $am = new EchoAttributeManager(
+ [], [], $defaultNotifyTypeAvailability,
$notifyTypeAvailabilityByCategory, []
+ );
$actual = $am->isNotifyTypeAvailableForCategory( $categoryName,
$notifyType );
$this->assertEquals( $expected, $actual, $message );
}
@@ -445,7 +465,9 @@
/**
* @dataProvider isNotifyTypeDismissableForCategoryProvider
*/
- public function testIsNotifyTypeDismissableForCategory( $message,
$expected, $categories, $categoryName, $notifyType ) {
+ public function testIsNotifyTypeDismissableForCategory(
+ $message, $expected, $categories, $categoryName, $notifyType
+ ) {
$am = new EchoAttributeManager( [], $categories, [], [], [] );
$actual = $am->isNotifyTypeDismissableForCategory(
$categoryName, $notifyType );
$this->assertEquals( $expected, $actual, $message );
diff --git a/tests/phpunit/DiscussionParserTest.php
b/tests/phpunit/DiscussionParserTest.php
index aaf51db..f1aee00 100644
--- a/tests/phpunit/DiscussionParserTest.php
+++ b/tests/phpunit/DiscussionParserTest.php
@@ -1470,7 +1470,7 @@
''The Boston Post'' source that was used in the reception section has a couple
of problems. First, it's actually a repost of ''The Washington Post'', but
''The Washington Post'' doesn't allow the Internet Archive to preserve it.
Should it still be sourced to Boston or to Washington? Second, it seems to be a
lot of analysis that can't be summed up easily without trimming it out, and
doesn't really fit with the reception section and should probably moved next to
Wilson's testimony. Any suggestions? --[[User:RAN1|RAN1]] ([[User
talk:RAN1|talk]]) 01:44, 11 December 2014 (UTC)
TEXT
-,
+ ,
<<<TEXT
== Washington Post Reception Source ==
@@ -1633,7 +1633,8 @@
}
protected static function signedMessage( $name ) {
- return ": " . self::message() . " [[User:$name|$name]] ([[User
talk:$name|talk]]) 00:17, 7 May 2013 (UTC)";
+ return ": " . self::message() .
+ " [[User:$name|$name]] ([[User talk:$name|talk]])
00:17, 7 May 2013 (UTC)";
}
protected static function message() {
@@ -1745,7 +1746,10 @@
public function testGetUserMentions( $userLinks, $expectedUserMentions,
$agent ) {
$title = Title::newFromText( 'Test' );
$discussionParser = TestingAccessWrapper::newFromClass(
'EchoDiscussionParser' );
- $this->assertEquals( $expectedUserMentions,
$discussionParser->getUserMentions( $title, $agent, $userLinks ) );
+ $this->assertEquals(
+ $expectedUserMentions,
+ $discussionParser->getUserMentions( $title, $agent,
$userLinks )
+ );
}
public function testGetUserMentions_validMention() {
@@ -1790,7 +1794,9 @@
$title = Title::newFromText( 'Test' );
$discussionParser = TestingAccessWrapper::newFromClass(
'EchoDiscussionParser' );
- $this->assertEquals( 4,
$discussionParser->getOverallUserMentionsCount(
$discussionParser->getUserMentions( $title, 1, $userLinks ) ) );
+ $this->assertEquals( 4,
$discussionParser->getOverallUserMentionsCount(
+ $discussionParser->getUserMentions( $title, 1,
$userLinks )
+ ) );
}
protected function isParserFunctionsInstalled() {
diff --git a/tests/phpunit/TalkPageFunctionalTest.php
b/tests/phpunit/TalkPageFunctionalTest.php
index 4c80f2e..2822c4a 100644
--- a/tests/phpunit/TalkPageFunctionalTest.php
+++ b/tests/phpunit/TalkPageFunctionalTest.php
@@ -33,12 +33,17 @@
$this->assertCount( $messageCount, $this->fetchAllEvents() );
// Start a talkpage
- $content = "== Section 8 ==\n\n" . $this->signedMessage(
$editor, $messages[$messageCount] );
+ $content = "== Section 8 ==\n\n" .
+ $this->signedMessage( $editor, $messages[$messageCount]
);
$this->editPage( $talkPage, $content, '', NS_USER_TALK );
// Ensure the proper event was created
$events = $this->fetchAllEvents();
- $this->assertCount( 1 + $messageCount, $events, 'After initial
edit a single event must exist.' ); // +1 is due to 0 index
+ $this->assertCount(
+ 1 + $messageCount, // +1 is due to 0 index
+ $events,
+ 'After initial edit a single event must exist.'
+ );
$row = array_shift( $events );
$this->assertEquals( 'edit-user-talk', $row->event_type );
$this->assertEventSectionTitle( 'Section 8', $row );
@@ -71,21 +76,32 @@
protected function assertEventSectionTitle( $sectionTitle, $row ) {
$this->assertNotNull( $row->event_extra, 'Event must contain
extra data.' );
$extra = unserialize( $row->event_extra );
- $this->assertArrayHasKey( 'section-title', $extra, 'Extra data
must include a section-title key.' );
- $this->assertEquals( $sectionTitle, $extra['section-title'],
'Detected section title must match' );
+ $this->assertArrayHasKey(
+ 'section-title', $extra, 'Extra data must include a
section-title key.'
+ );
+ $this->assertEquals(
+ $sectionTitle, $extra['section-title'], 'Detected
section title must match'
+ );
}
/**
* @return array All events in db sorted from oldest to newest
*/
protected function fetchAllEvents() {
- $res = $this->dbr->select( 'echo_event', [ '*' ], [],
__METHOD__, [ 'ORDER BY' => 'event_id ASC' ] );
+ $res = $this->dbr->select(
+ 'echo_event',
+ [ '*' ],
+ [],
+ __METHOD__,
+ [ 'ORDER BY' => 'event_id ASC' ]
+ );
return iterator_to_array( $res );
}
protected function signedMessage( $name, $content = 'Moar cowbell',
$depth = 1 ) {
- return str_repeat( ':', $depth ) . " $content
[[User:$name|$name]] ([[User talk:$name|$name]]) 00:17, 7 May 2013 (UTC)\n";
+ return str_repeat( ':', $depth ) .
+ " $content [[User:$name|$name]] ([[User
talk:$name|$name]]) 00:17, 7 May 2013 (UTC)\n";
}
}
diff --git a/tests/phpunit/controller/NotificationControllerTest.php
b/tests/phpunit/controller/NotificationControllerTest.php
index 8a38a7e..0e1a70b 100644
--- a/tests/phpunit/controller/NotificationControllerTest.php
+++ b/tests/phpunit/controller/NotificationControllerTest.php
@@ -67,7 +67,9 @@
/**
* @dataProvider evaluateUserLocatorsProvider
*/
- public function testEvaluateUserLocators( $message, $expect,
$locatorConfigForEventType, $setup = null ) {
+ public function testEvaluateUserLocators(
+ $message, $expect, $locatorConfigForEventType, $setup = null
+ ) {
$this->setMwGlobals( [
'wgEchoNotifications' => [
'unit-test' => [
@@ -87,7 +89,9 @@
$setup( $this, $event );
}
- $result = EchoNotificationController::evaluateUserCallable(
$event, EchoAttributeManager::ATTR_LOCATORS );
+ $result = EchoNotificationController::evaluateUserCallable(
+ $event, EchoAttributeManager::ATTR_LOCATORS
+ );
$this->assertEquals( $expect, array_map( 'array_keys', $result
), $message );
}
@@ -240,7 +244,9 @@
/**
* @dataProvider getEventNotifyTypesProvider
*/
- public function testGetEventNotifyTypes( $message, $expect, $type,
array $defaultNotifyTypeAvailability, array $notifications ) {
+ public function testGetEventNotifyTypes(
+ $message, $expect, $type, array $defaultNotifyTypeAvailability,
array $notifications
+ ) {
$this->setMwGlobals( [
'wgDefaultNotifyTypeAvailability' =>
$defaultNotifyTypeAvailability,
'wgEchoNotifications' => $notifications,
diff --git a/tests/phpunit/gateway/UserNotificationGatewayTest.php
b/tests/phpunit/gateway/UserNotificationGatewayTest.php
index 7e656e1..5155a75 100644
--- a/tests/phpunit/gateway/UserNotificationGatewayTest.php
+++ b/tests/phpunit/gateway/UserNotificationGatewayTest.php
@@ -4,48 +4,71 @@
public function testMarkRead() {
// no event ids to mark
- $gateway = new EchoUserNotificationGateway( User::newFromId( 1
), $this->mockMWEchoDbFactory() );
+ $gateway = new EchoUserNotificationGateway(
+ User::newFromId( 1 ), $this->mockMWEchoDbFactory()
+ );
$this->assertNull( $gateway->markRead( [] ) );
// successful update
- $gateway = new EchoUserNotificationGateway( User::newFromId( 1
), $this->mockMWEchoDbFactory( [ 'update' => true ] ) );
+ $gateway = new EchoUserNotificationGateway(
+ User::newFromId( 1 ), $this->mockMWEchoDbFactory( [
'update' => true ] )
+ );
$this->assertTrue( $gateway->markRead( [ 2 ] ) );
// unsuccessful update
- $gateway = new EchoUserNotificationGateway( User::newFromId( 1
), $this->mockMWEchoDbFactory( [ 'update' => false ] ) );
+ $gateway = new EchoUserNotificationGateway(
+ User::newFromId( 1 ), $this->mockMWEchoDbFactory( [
'update' => false ] )
+ );
$this->assertFalse( $gateway->markRead( [ 2 ] ) );
}
public function testMarkAllRead() {
// successful update
- $gateway = new EchoUserNotificationGateway( User::newFromId( 1
), $this->mockMWEchoDbFactory( [ 'update' => true ] ) );
+ $gateway = new EchoUserNotificationGateway(
+ User::newFromId( 1 ), $this->mockMWEchoDbFactory( [
'update' => true ] )
+ );
$this->assertTrue( $gateway->markAllRead( [ 2 ] ) );
// unsuccessful update
- $gateway = new EchoUserNotificationGateway( User::newFromId( 1
), $this->mockMWEchoDbFactory( [ 'update' => false ] ) );
+ $gateway = new EchoUserNotificationGateway(
+ User::newFromId( 1 ), $this->mockMWEchoDbFactory( [
'update' => false ] )
+ );
$this->assertFalse( $gateway->markAllRead( [ 2 ] ) );
}
public function testGetNotificationCount() {
// unsuccessful select
- $gateway = new EchoUserNotificationGateway( $this->mockUser(),
$this->mockMWEchoDbFactory( [ 'selectRowCount' => 0 ] ) );
+ $gateway = new EchoUserNotificationGateway(
+ $this->mockUser(), $this->mockMWEchoDbFactory( [
'selectRowCount' => 0 ] )
+ );
$this->assertEquals( 0, $gateway->getCappedNotificationCount(
DB_SLAVE, [ 'event_one' ] ) );
// successful select of alert
- $gateway = new EchoUserNotificationGateway( $this->mockUser(),
$this->mockMWEchoDbFactory( [ 'selectRowCount' => 2 ] ) );
- $this->assertEquals( 2, $gateway->getCappedNotificationCount(
DB_SLAVE, [ 'event_one', 'event_two' ] ) );
+ $gateway = new EchoUserNotificationGateway(
+ $this->mockUser(), $this->mockMWEchoDbFactory( [
'selectRowCount' => 2 ] )
+ );
+ $this->assertEquals(
+ 2,
+ $gateway->getCappedNotificationCount( DB_SLAVE, [
'event_one', 'event_two' ] )
+ );
// there is event, should return 0
- $gateway = new EchoUserNotificationGateway( $this->mockUser(),
$this->mockMWEchoDbFactory( [ 'selectRowCount' => 2 ] ) );
+ $gateway = new EchoUserNotificationGateway(
+ $this->mockUser(), $this->mockMWEchoDbFactory( [
'selectRowCount' => 2 ] )
+ );
$this->assertEquals( 0, $gateway->getCappedNotificationCount(
DB_SLAVE, [] ) );
// successful select
- $gateway = new EchoUserNotificationGateway( $this->mockUser(),
$this->mockMWEchoDbFactory( [ 'selectRowCount' => 3 ] ) );
+ $gateway = new EchoUserNotificationGateway(
+ $this->mockUser(), $this->mockMWEchoDbFactory( [
'selectRowCount' => 3 ] )
+ );
$this->assertEquals( 3, $gateway->getCappedNotificationCount(
DB_SLAVE, [ 'event_one' ] ) );
}
public function testGetUnreadNotifications() {
- $gateway = new EchoUserNotificationGateway( $this->mockUser(),
$this->mockMWEchoDbFactory( [ 'select' => false ] ) );
+ $gateway = new EchoUserNotificationGateway(
+ $this->mockUser(), $this->mockMWEchoDbFactory( [
'select' => false ] )
+ );
$this->assertEmpty( $gateway->getUnreadNotifications(
'user_talk' ) );
$dbResult = [
@@ -53,7 +76,9 @@
(object)[ 'notification_event' => 2 ],
(object)[ 'notification_event' => 3 ],
];
- $gateway = new EchoUserNotificationGateway( $this->mockUser(),
$this->mockMWEchoDbFactory( [ 'select' => $dbResult ] ) );
+ $gateway = new EchoUserNotificationGateway(
+ $this->mockUser(), $this->mockMWEchoDbFactory( [
'select' => $dbResult ] )
+ );
$res = $gateway->getUnreadNotifications( 'user_talk' );
$this->assertEquals( $res, [ 1 => 1, 2 => 2, 3 => 3 ] );
}
diff --git a/tests/phpunit/mapper/NotificationMapperTest.php
b/tests/phpunit/mapper/NotificationMapperTest.php
index 420c093..d4950b7 100644
--- a/tests/phpunit/mapper/NotificationMapperTest.php
+++ b/tests/phpunit/mapper/NotificationMapperTest.php
@@ -11,7 +11,9 @@
public function fetchUnreadByUser( User $user, $limit, array
$eventTypes = [] ) {
// Unsuccessful select
- $notifMapper = new EchoNotificationMapper(
$this->mockMWEchoDbFactory( [ 'select' => false ] ) );
+ $notifMapper = new EchoNotificationMapper(
+ $this->mockMWEchoDbFactory( [ 'select' => false ] )
+ );
$res = $notifMapper->fetchUnreadByUser( $this->mockUser(), 10,
null, '' );
$this->assertEmpty( $res );
@@ -33,11 +35,15 @@
'notification_bundle_display_hash' =>
'testdisplayhash'
]
];
- $notifMapper = new EchoNotificationMapper(
$this->mockMWEchoDbFactory( [ 'select' => $dbResult ] ) );
+ $notifMapper = new EchoNotificationMapper(
+ $this->mockMWEchoDbFactory( [ 'select' => $dbResult ] )
+ );
$res = $notifMapper->fetchUnreadByUser( $this->mockUser(), 10,
null, '', [] );
$this->assertEmpty( $res );
- $notifMapper = new EchoNotificationMapper(
$this->mockMWEchoDbFactory( [ 'select' => $dbResult ] ) );
+ $notifMapper = new EchoNotificationMapper(
+ $this->mockMWEchoDbFactory( [ 'select' => $dbResult ] )
+ );
$res = $notifMapper->fetchUnreadByUser( $this->mockUser(), 10,
null, '', [ 'test_event' ] );
$this->assertTrue( is_array( $res ) );
$this->assertGreaterThan( 0, count( $res ) );
@@ -48,7 +54,9 @@
public function testFetchByUser() {
// Unsuccessful select
- $notifMapper = new EchoNotificationMapper(
$this->mockMWEchoDbFactory( [ 'select' => false ] ) );
+ $notifMapper = new EchoNotificationMapper(
+ $this->mockMWEchoDbFactory( [ 'select' => false ] )
+ );
$res = $notifMapper->fetchByUser( $this->mockUser(), 10, '' );
$this->assertEmpty( $res );
@@ -79,7 +87,9 @@
],
];
- $notifMapper = new EchoNotificationMapper(
$this->mockMWEchoDbFactory( [ 'select' => $notifDbResult ] ) );
+ $notifMapper = new EchoNotificationMapper(
+ $this->mockMWEchoDbFactory( [ 'select' =>
$notifDbResult ] )
+ );
$res = $notifMapper->fetchByUser( $this->mockUser(), 10, '', []
);
$this->assertEmpty( $res );
@@ -103,7 +113,9 @@
public function testFetchNewestByUserBundleHash() {
// Unsuccessful select
- $notifMapper = new EchoNotificationMapper(
$this->mockMWEchoDbFactory( [ 'selectRow' => false ] ) );
+ $notifMapper = new EchoNotificationMapper(
+ $this->mockMWEchoDbFactory( [ 'selectRow' => false ] )
+ );
$res = $notifMapper->fetchNewestByUserBundleHash(
User::newFromId( 1 ), 'testhash' );
$this->assertFalse( $res );
@@ -124,14 +136,18 @@
'notification_bundle_hash' => 'testhash',
'notification_bundle_display_hash' => 'testdisplayhash'
];
- $notifMapper = new EchoNotificationMapper(
$this->mockMWEchoDbFactory( [ 'selectRow' => $dbResult ] ) );
+ $notifMapper = new EchoNotificationMapper(
+ $this->mockMWEchoDbFactory( [ 'selectRow' => $dbResult
] )
+ );
$row = $notifMapper->fetchNewestByUserBundleHash(
User::newFromId( 1 ), 'testdisplayhash' );
$this->assertInstanceOf( 'EchoNotification', $row );
}
public function testFetchByUserOffset() {
// Unsuccessful select
- $notifMapper = new EchoNotificationMapper(
$this->mockMWEchoDbFactory( [ 'selectRow' => false ] ) );
+ $notifMapper = new EchoNotificationMapper(
+ $this->mockMWEchoDbFactory( [ 'selectRow' => false ] )
+ );
$res = $notifMapper->fetchByUserOffset( User::newFromId( 1 ),
500 );
$this->assertFalse( $res );
@@ -152,7 +168,9 @@
'notification_bundle_hash' => 'testhash',
'notification_bundle_display_hash' => 'testdisplayhash'
];
- $notifMapper = new EchoNotificationMapper(
$this->mockMWEchoDbFactory( [ 'selectRow' => $dbResult ] ) );
+ $notifMapper = new EchoNotificationMapper(
+ $this->mockMWEchoDbFactory( [ 'selectRow' => $dbResult
] )
+ );
$row = $notifMapper->fetchByUserOffset( User::newFromId( 1 ),
500 );
$this->assertInstanceOf( 'EchoNotification', $row );
}
--
To view, visit https://gerrit.wikimedia.org/r/364302
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9d87142796e99fcfac94a300b16e8d169bb1e8af
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Echo
Gerrit-Branch: master
Gerrit-Owner: Umherirrender <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits