Umherirrender has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/364301 )
Change subject: Break long lines
......................................................................
Break long lines
Change-Id: I5592c39298be7d5a5f0eec2978d437d9860049e9
---
M includes/AttributeManager.php
M includes/ContainmentSet.php
M includes/DataOutputFormatter.php
M includes/DeferredMarkAsDeletedUpdate.php
M includes/DiffParser.php
M includes/DiscussionParser.php
M includes/EchoDbFactory.php
M includes/EmailBatch.php
M includes/ForeignNotifications.php
M includes/ForeignWikiRequest.php
M includes/NotifUser.php
M includes/Notifier.php
M includes/schemaUpdate.php
13 files changed, 299 insertions(+), 116 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Echo
refs/changes/01/364301/1
diff --git a/includes/AttributeManager.php b/includes/AttributeManager.php
index 8d30bda..0ef8ccc 100644
--- a/includes/AttributeManager.php
+++ b/includes/AttributeManager.php
@@ -77,7 +77,13 @@
* @param array $notifiers Associative array mapping notify types to
notifier
* that handles them
*/
- public function __construct( array $notifications, array $categories,
array $defaultNotifyTypeAvailability, array $notifyTypeAvailabilityByCategory,
array $notifiers ) {
+ public function __construct(
+ array $notifications,
+ array $categories,
+ array $defaultNotifyTypeAvailability,
+ array $notifyTypeAvailabilityByCategory,
+ array $notifiers
+ ) {
// Extensions can define their own notifications and categories
$this->notifications = $notifications;
$this->categories = $categories;
@@ -95,11 +101,18 @@
* @return EchoAttributeManager
*/
public static function newFromGlobalVars() {
- global $wgEchoNotifications, $wgEchoNotificationCategories,
$wgDefaultNotifyTypeAvailability, $wgNotifyTypeAvailabilityByCategory,
$wgEchoNotifiers;
+ global $wgEchoNotifications, $wgEchoNotificationCategories,
+ $wgDefaultNotifyTypeAvailability,
$wgNotifyTypeAvailabilityByCategory, $wgEchoNotifiers;
// Unit test may alter the global data for test purpose
if ( defined( 'MW_PHPUNIT_TEST' ) ) {
- return new self( $wgEchoNotifications,
$wgEchoNotificationCategories, $wgDefaultNotifyTypeAvailability,
$wgNotifyTypeAvailabilityByCategory, $wgEchoNotifiers );
+ return new self(
+ $wgEchoNotifications,
+ $wgEchoNotificationCategories,
+ $wgDefaultNotifyTypeAvailability,
+ $wgNotifyTypeAvailabilityByCategory,
+ $wgEchoNotifiers
+ );
}
if ( self::$globalVarInstance === null ) {
diff --git a/includes/ContainmentSet.php b/includes/ContainmentSet.php
index 6bde088..371b459 100644
--- a/includes/ContainmentSet.php
+++ b/includes/ContainmentSet.php
@@ -85,10 +85,12 @@
* from wiki pages is cached via the BagOStuff. Caching is disabled
when passing a null
* $cache object.
*
- * @param $namespace integer An NS_* constant representing the
mediawiki namespace of the page containing the list.
+ * @param $namespace integer An NS_* constant representing the
mediawiki namespace of
+ * the page containing the list.
* @param $title string The title of the page containing
the list.
* @param $cache BagOStuff An object to cache the page with or
null for no cache.
- * @param $cacheKeyPrefix string A prefix to be combined with the
pages latest revision id and used as a cache key.
+ * @param $cacheKeyPrefix string A prefix to be combined with the
pages latest revision id
+ * and used as a cache key.
*
* @throws MWException
*/
@@ -222,12 +224,20 @@
/**
* @param $cache BagOStuff Bag to stored cached
data in.
- * @param $partialCacheKey string Partial cache key,
$nestedList->getCacheKey() will be appended to this
- * to construct the cache
key used.
- * @param $nestedList EchoContainmentList The nested
EchoContainmentList to cache the result of.
- * @param $timeout integer How long in seconds to
cache the nested list, defaults to 1 week.
+ * @param $partialCacheKey string Partial cache key,
$nestedList->getCacheKey()
+ * will be appended to this
to construct the cache
+ * key used.
+ * @param $nestedList EchoContainmentList The nested
EchoContainmentList to cache the
+ * result of.
+ * @param $timeout integer How long in seconds to
cache the nested list,
+ * defaults to 1 week.
*/
- public function __construct( BagOStuff $cache, $partialCacheKey,
EchoContainmentList $nestedList, $timeout = self::ONE_WEEK ) {
+ public function __construct(
+ BagOStuff $cache,
+ $partialCacheKey,
+ EchoContainmentList $nestedList,
+ $timeout = self::ONE_WEEK
+ ) {
$this->cache = $cache;
$this->partialCacheKey = $partialCacheKey;
$this->nestedList = $nestedList;
diff --git a/includes/DataOutputFormatter.php b/includes/DataOutputFormatter.php
index 58eec3a..60af580 100644
--- a/includes/DataOutputFormatter.php
+++ b/includes/DataOutputFormatter.php
@@ -24,7 +24,9 @@
* @param Language $lang Language to format the notification in
* @return array|bool false if it could not be formatted
*/
- public static function formatOutput( EchoNotification $notification,
$format = false, User $user, Language $lang ) {
+ public static function formatOutput(
+ EchoNotification $notification, $format = false, User $user,
Language $lang
+ ) {
$event = $notification->getEvent();
$timestamp = $notification->getTimestamp();
$utcTimestampIso8601 = wfTimestamp( TS_ISO_8601, $timestamp );
@@ -141,15 +143,20 @@
}
$output['*'] = $formatted;
- if ( $notification->getBundledNotifications() &&
self::isBundleExpandable( $event->getType() ) ) {
- $output['bundledNotifications'] = array_values(
array_filter( array_map( function ( EchoNotification $notification ) use (
$format, $user, $lang ) {
- // remove nested notifications to
- // - ensure they are formatted as
single notifications (not bundled)
- // - prevent further re-entrance on the
current notification
- $notification->setBundledNotifications(
[] );
-
$notification->getEvent()->setBundledEvents( [] );
- return self::formatOutput(
$notification, $format, $user, $lang );
- }, array_merge( [ $notification ],
$notification->getBundledNotifications() ) ) ) );
+ if ( $notification->getBundledNotifications() &&
+ self::isBundleExpandable( $event->getType() )
+ ) {
+ $output['bundledNotifications'] = array_values(
array_filter( array_map(
+ function ( EchoNotification
$notification ) use ( $format, $user, $lang ) {
+ // remove nested notifications
to
+ // - ensure they are formatted
as single notifications (not bundled)
+ // - prevent further
re-entrance on the current notification
+
$notification->setBundledNotifications( [] );
+
$notification->getEvent()->setBundledEvents( [] );
+ return self::formatOutput(
$notification, $format, $user, $lang );
+ },
+ array_merge( [ $notification ],
$notification->getBundledNotifications() ) ) )
+ );
}
}
@@ -183,7 +190,9 @@
*/
protected static function getDateHeader( User $user, $timestampMw ) {
$lang = RequestContext::getMain()->getLanguage();
- $dateFormat = $lang->getDateFormatString( 'pretty',
$user->getDatePreference() ?: 'default' );
+ $dateFormat = $lang->getDateFormatString(
+ 'pretty', $user->getDatePreference() ?: 'default'
+ );
return $lang->sprintfDate( $dateFormat, $timestampMw );
}
@@ -210,7 +219,8 @@
*/
public static function isBundleExpandable( $type ) {
global $wgEchoNotifications;
- return isset(
$wgEchoNotifications[$type]['bundle']['expandable'] ) &&
$wgEchoNotifications[$type]['bundle']['expandable'];
+ return isset(
$wgEchoNotifications[$type]['bundle']['expandable'] ) &&
+ $wgEchoNotifications[$type]['bundle']['expandable'];
}
}
diff --git a/includes/DeferredMarkAsDeletedUpdate.php
b/includes/DeferredMarkAsDeletedUpdate.php
index 3a38446..b4dd94b 100644
--- a/includes/DeferredMarkAsDeletedUpdate.php
+++ b/includes/DeferredMarkAsDeletedUpdate.php
@@ -39,7 +39,8 @@
// unreaderable because of slave lag.
// Do not moderate it at this time.
LoggerFactory::getInstance( 'Echo'
)->debug(
-
'EchoDeferredMarkAsDeletedUpdate: Event {eventId} was found unrenderable but
its associated title exists on Master. Skipping.',
+
'EchoDeferredMarkAsDeletedUpdate: Event {eventId} was found unrenderable ' .
+ 'but its associated
title exists on Master. Skipping.',
[
'eventId' =>
$event->getId(),
'title' =>
$event->getTitle()->getPrefixedText(),
diff --git a/includes/DiffParser.php b/includes/DiffParser.php
index fc56608..7daa95a 100644
--- a/includes/DiffParser.php
+++ b/includes/DiffParser.php
@@ -62,12 +62,13 @@
protected $changeSet;
/**
- * Get the set of add, subtract, and change operations required to
transform leftText into rightText
+ * Get the set of add, subtract, and change operations required to
transform leftText into
+ * rightText
*
* @param string $leftText The left, or old, revision of the text
* @param string $rightText The right, or new, revision of the text
- * @return array[] Array of arrays containing changes to individual
groups of lines within the text
- * Each change consists of:
+ * @return array[] Array of arrays containing changes to individual
groups of lines within the
+ * text. Each change consists of:
* An 'action', one of:
* - add
* - subtract
diff --git a/includes/DiscussionParser.php b/includes/DiscussionParser.php
index a1b1ea8..8b17366 100644
--- a/includes/DiscussionParser.php
+++ b/includes/DiscussionParser.php
@@ -44,17 +44,23 @@
$fullSection = $action['full-section'];
$header = self::extractHeader( $fullSection );
$userLinks = self::getUserLinks(
$action['content'], $title );
- self::generateMentionEvents( $header,
$userLinks, $action['content'], $revision, $user );
+ self::generateMentionEvents(
+ $header, $userLinks,
$action['content'], $revision, $user
+ );
} elseif ( $action['type'] ==
'new-section-with-comment' ) {
$content = $action['content'];
$header = self::extractHeader( $content );
$userLinks = self::getUserLinks( $content,
$title );
self::generateMentionEvents( $header,
$userLinks, $content, $revision, $user );
- } elseif ( $action['type'] == 'add-section-multiple' &&
$wgEchoMentionsOnMultipleSectionEdits ) {
+ } elseif ( $action['type'] == 'add-section-multiple' &&
+ $wgEchoMentionsOnMultipleSectionEdits
+ ) {
$content = self::stripHeader(
$action['content'] );
$content = self::stripSignature( $content );
$userLinks = self::getUserLinks( $content,
$title );
- self::generateMentionEvents( $action['header'],
$userLinks, $content, $revision, $user );
+ self::generateMentionEvents(
+ $action['header'], $userLinks,
$content, $revision, $user
+ );
} elseif ( $action['type'] === 'unknown-signed-change'
) {
$userLinks = array_diff_key(
self::getUserLinks(
$action['new_content'], $title ) ?: [],
@@ -63,7 +69,9 @@
$header = self::extractHeader(
$action['full-section'] );
if ( $wgEchoMentionOnChanges ) {
- self::generateMentionEvents( $header,
$userLinks, $action['new_content'], $revision, $user );
+ self::generateMentionEvents(
+ $header, $userLinks,
$action['new_content'], $revision, $user
+ );
}
}
}
@@ -176,7 +184,9 @@
return;
}
- $userMentions = self::getUserMentions( $title,
$revision->getUser( Revision::RAW ), $userLinks );
+ $userMentions = self::getUserMentions(
+ $title, $revision->getUser( Revision::RAW ), $userLinks
+ );
$overallMentionsCount = self::getOverallUserMentionsCount(
$userMentions );
if ( $overallMentionsCount === 0 ) {
return;
@@ -404,7 +414,9 @@
* @return array see interpretDiff for details.
*/
static function getChangeInterpretationForRevision( Revision $revision
) {
- if ( $revision->getId() && isset(
self::$revisionInterpretationCache[$revision->getId()] ) ) {
+ if ( $revision->getId() &&
+ isset(
self::$revisionInterpretationCache[$revision->getId()] )
+ ) {
return
self::$revisionInterpretationCache[$revision->getId()];
}
@@ -493,15 +505,21 @@
in_array( $username, $signedUsers )
) {
if ( $sectionCount === 0 ) {
- $signedSections[] =
self::getSectionSpan( $change['right-pos'], $changes['_info']['rhs'] );
- $fullSection =
self::getFullSection( $changes['_info']['rhs'], $change['right-pos'] );
+ $signedSections[] =
self::getSectionSpan(
+ $change['right-pos'],
$changes['_info']['rhs']
+ );
+ $fullSection =
self::getFullSection(
+
$changes['_info']['rhs'], $change['right-pos']
+ );
$actions[] = [
'type' => 'add-comment',
'content' => $content,
'full-section' =>
$fullSection,
];
} elseif ( $startSection &&
$sectionCount === 1 ) {
- $signedSections[] =
self::getSectionSpan( $change['right-pos'], $changes['_info']['rhs'] );
+ $signedSections[] =
self::getSectionSpan(
+ $change['right-pos'],
$changes['_info']['rhs']
+ );
$actions[] = [
'type' =>
'new-section-with-comment',
'content' => $content,
@@ -510,13 +528,19 @@
$nextSectionStart =
$change['right-pos'];
$sectionData =
self::extractSections( $content );
foreach ( $sectionData as
$section ) {
- $sectionSpan =
self::getSectionSpan( $nextSectionStart, $changes['_info']['rhs'] );
+ $sectionSpan =
self::getSectionSpan(
+
$nextSectionStart, $changes['_info']['rhs']
+ );
$nextSectionStart =
$sectionSpan[1] + 1;
- $sectionSignedUsers =
self::extractSignatures( $section['content'], $title );
+ $sectionSignedUsers =
self::extractSignatures(
+
$section['content'], $title
+ );
if ( !empty(
$sectionSignedUsers ) ) {
$signedSections[] = $sectionSpan;
if (
!$section['header'] ) {
-
$fullSection = self::getFullSection( $changes['_info']['rhs'],
$change['right-pos'] );
+
$fullSection = self::getFullSection(
+
$changes['_info']['rhs'], $change['right-pos']
+ );
$section['header'] = self::extractHeader( $fullSection );
}
$actions[] = [
@@ -554,7 +578,9 @@
'old_content' => $change['old_content'],
'new_content' => $change['new_content'],
'right-pos' => $change['right-pos'],
- 'full-section' => self::getFullSection(
$changes['_info']['rhs'], $change['right-pos'] ),
+ 'full-section' => self::getFullSection(
+ $changes['_info']['rhs'],
$change['right-pos']
+ ),
];
if ( self::hasNewSignature(
@@ -563,7 +589,9 @@
$username,
$title
) ) {
- $signedSections[] =
self::getSectionSpan( $change['right-pos'], $changes['_info']['rhs'] );
+ $signedSections[] =
self::getSectionSpan(
+ $change['right-pos'],
$changes['_info']['rhs']
+ );
}
} else {
$actions[] = [
@@ -592,9 +620,11 @@
}
/**
- * Converts actions of type "unknown-change" to "unknown-signed-change"
if the change is in a signed section.
+ * Converts actions of type "unknown-change" to "unknown-signed-change"
if the change is in a
+ * signed section.
*
- * @param array $signedSections Array of arrays containing first and
last line number of signed sections
+ * @param array $signedSections Array of arrays containing first and
last line number of
+ * signed sections
* @param array $actions
* @return array converted actions
*/
@@ -642,8 +672,9 @@
}
/**
- * Given a line number and a text, find the first and last line of the
section the line number is in.
- * If there are subsections, the last line index will be the line
before the beginning of the first subsection.
+ * Given a line number and a text, find the first and last line of the
section the line number
+ * is in. If there are subsections, the last line index will be the
line before the beginning
+ * of the first subsection.
* @param $offset line number
* @param $lines
* @return array tuple [$firstLine, $lastLine]
@@ -727,13 +758,16 @@
* @param string $text The text to parse.
* @return array[]
* Array of arrays containing sections with header and content.
- * - [header]: The full header string of the section or false if there
is preceding text without header.
+ * - [header]: The full header string of the section or
+ * false if there is preceding text without header.
* - [content]: The content of the section including the header string.
*/
private static function extractSections( $text ) {
$matches = [];
- if ( !preg_match_all( '/' . self::HEADER_REGEX . '/um', $text,
$matches, PREG_OFFSET_CAPTURE ) ) {
+ if ( !preg_match_all( '/' . self::HEADER_REGEX . '/um',
+ $text, $matches, PREG_OFFSET_CAPTURE )
+ ) {
return [ [
'header' => false,
'content' => $text
@@ -751,7 +785,9 @@
}
for ( $i = 0; $i < $sectionNum; $i++ ) {
if ( $i + 1 < $sectionNum ) {
- $content = substr( $text, $matches[0][$i][1],
$matches[0][$i + 1][1] - $matches[0][$i][1] );
+ $content = substr(
+ $text, $matches[0][$i][1],
$matches[0][$i + 1][1] - $matches[0][$i][1]
+ );
} else {
$content = substr( $text, $matches[0][$i][1] );
}
@@ -817,7 +853,8 @@
list( , $foundUser ) = $userData;
- return User::getCanonicalName( $foundUser, false ) ===
User::getCanonicalName( $user, false );
+ return User::getCanonicalName( $foundUser, false ) ===
+ User::getCanonicalName( $user, false );
}
/**
@@ -1184,6 +1221,7 @@
public static function getEditExcerpt( Revision $revision, Language
$lang, $length = 150 ) {
$interpretation = self::getChangeInterpretationForRevision(
$revision );
$section = self::detectSectionTitleAndText( $interpretation );
- return $lang->truncate( $section['section-title'] . ' ' .
$section['section-text'], $length );
+ return $lang->truncate( $section['section-title'] . ' ' .
+ $section['section-text'], $length );
}
}
diff --git a/includes/EchoDbFactory.php b/includes/EchoDbFactory.php
index 1201263..bcb0705 100644
--- a/includes/EchoDbFactory.php
+++ b/includes/EchoDbFactory.php
@@ -48,7 +48,8 @@
protected function getLB() {
// Use the external db defined for Echo
if ( $this->cluster ) {
- $lb =
MediaWikiServices::getInstance()->getDBLoadBalancerFactory()->getExternalLB(
$this->cluster );
+ $lb = MediaWikiServices::getInstance()
+ ->getDBLoadBalancerFactory()->getExternalLB(
$this->cluster );
} else {
$lb =
MediaWikiServices::getInstance()->getDBLoadBalancer();
}
@@ -61,7 +62,8 @@
*/
protected function getSharedLB() {
if ( $this->sharedCluster ) {
- $lb =
MediaWikiServices::getInstance()->getDBLoadBalancerFactory()->getExternalLB(
$this->sharedCluster );
+ $lb = MediaWikiServices::getInstance()
+ ->getDBLoadBalancerFactory()->getExternalLB(
$this->sharedCluster );
} else {
$lb =
MediaWikiServices::getInstance()->getDBLoadBalancer();
}
@@ -174,9 +176,11 @@
/**
* Check whether it makes sense to retry a failed lookup on the master.
- * @return bool True if there are multiple servers and changes were
made in this request; false otherwise
+ * @return bool True if there are multiple servers and changes were
made in this request;
+ * false otherwise
*/
public function canRetryMaster() {
- return $this->getLB()->getServerCount() > 1 &&
$this->getLB()->hasOrMadeRecentMasterChanges();
+ return $this->getLB()->getServerCount() > 1 &&
+ $this->getLB()->hasOrMadeRecentMasterChanges();
}
}
diff --git a/includes/EmailBatch.php b/includes/EmailBatch.php
index c50daaa..5e8d92f 100644
--- a/includes/EmailBatch.php
+++ b/includes/EmailBatch.php
@@ -225,7 +225,8 @@
}
/**
- * Clear "processed" events in the queue, processed could be: email
sent, invalid, users do not want to receive emails
+ * Clear "processed" events in the queue, processed could be: email
sent, invalid,
+ * users do not want to receive emails
*/
public function clearProcessedEvent() {
$conds = [ 'eeb_user_id' => $this->mUser->getId() ];
@@ -249,7 +250,9 @@
public function sendEmail() {
global $wgNotificationSender, $wgNotificationReplyName;
- if ( $this->mUser->getOption( 'echo-email-frequency' ) ==
EchoEmailFrequency::WEEKLY_DIGEST ) {
+ if ( $this->mUser->getOption( 'echo-email-frequency' ) ==
+ EchoEmailFrequency::WEEKLY_DIGEST
+ ) {
$frequency = 'weekly';
$emailDeliveryMode = 'weekly_digest';
} else {
@@ -257,7 +260,9 @@
$emailDeliveryMode = 'daily_digest';
}
- $textEmailDigestFormatter = new
EchoPlainTextDigestEmailFormatter( $this->mUser, $this->language, $frequency );
+ $textEmailDigestFormatter = new
EchoPlainTextDigestEmailFormatter(
+ $this->mUser, $this->language, $frequency
+ );
$content = $textEmailDigestFormatter->format( $this->events,
'email' );
if ( !$content ) {
@@ -267,7 +272,9 @@
$format = MWEchoNotifUser::newFromUser( $this->mUser
)->getEmailFormat();
if ( $format == EchoEmailFormat::HTML ) {
- $htmlEmailDigestFormatter = new
EchoHtmlDigestEmailFormatter( $this->mUser, $this->language, $frequency );
+ $htmlEmailDigestFormatter = new
EchoHtmlDigestEmailFormatter(
+ $this->mUser, $this->language, $frequency
+ );
$htmlContent = $htmlEmailDigestFormatter->format(
$this->events, 'email' );
$content = [
@@ -280,11 +287,19 @@
}
$toAddress = MailAddress::newFromUser( $this->mUser );
- $fromAddress = new MailAddress( $wgNotificationSender,
EchoHooks::getNotificationSenderName() );
+ $fromAddress = new MailAddress(
+ $wgNotificationSender,
EchoHooks::getNotificationSenderName()
+ );
$replyTo = new MailAddress( $wgNotificationSender,
$wgNotificationReplyName );
// @Todo Push the email to job queue or just send it out
directly?
- UserMailer::send( $toAddress, $fromAddress,
$content['subject'], $content['body'], [ 'replyTo' => $replyTo ] );
+ UserMailer::send(
+ $toAddress,
+ $fromAddress,
+ $content['subject'],
+ $content['body'],
+ [ 'replyTo' => $replyTo ]
+ );
MWEchoEventLogging::logSchemaEchoMail( $this->mUser,
$emailDeliveryMode );
}
diff --git a/includes/ForeignNotifications.php
b/includes/ForeignNotifications.php
index 9b3846a..0321a2f 100644
--- a/includes/ForeignNotifications.php
+++ b/includes/ForeignNotifications.php
@@ -1,12 +1,13 @@
<?php
/**
- * Caches the result of EchoUnreadWikis::getUnreadCounts() and interprets the
results in various useful ways.
+ * Caches the result of EchoUnreadWikis::getUnreadCounts() and interprets the
results in various
+ * useful ways.
*
- * If the user has disabled cross-wiki notifications in their preferences (see
isEnabledByUser()), this class
- * won't do anything and will behave as if the user has no foreign
notifications. For example, getCount() will
- * return 0. If you need to get foreign notification information for a user
even though they may not have
- * enabled the preference, set $forceEnable=true in the constructor.
+ * If the user has disabled cross-wiki notifications in their preferences (see
isEnabledByUser()),
+ * this class won't do anything and will behave as if the user has no foreign
notifications. For
+ * example, getCount() will return 0. If you need to get foreign notification
information for a user
+ * even though they may not have enabled the preference, set $forceEnable=true
in the constructor.
*/
class EchoForeignNotifications {
/**
@@ -32,7 +33,9 @@
/**
* @var array [(str) section => (MWTimestamp) timestamp, ...]
*/
- protected $timestamps = [ EchoAttributeManager::ALERT => false,
EchoAttributeManager::MESSAGE => false ];
+ protected $timestamps = [
+ EchoAttributeManager::ALERT => false,
EchoAttributeManager::MESSAGE => false
+ ];
/**
* @var array [(str) wiki => [ (str) section => (MWTimestamp)
timestamp, ...], ...]
@@ -46,7 +49,8 @@
/**
* @param User $user
- * @param bool $forceEnable Ignore the user's preferences and act as if
they've enabled cross-wiki notifications
+ * @param bool $forceEnable Ignore the user's preferences and act as if
they've enabled
+ * cross-wiki notifications
*/
public function __construct( User $user, $forceEnable = false ) {
$this->user = $user;
@@ -90,7 +94,9 @@
foreach ( $this->timestamps as $timestamp ) {
// $timestamp < $max = invert 0
// $timestamp > $max = invert 1
- if ( $timestamp !== false && ( $max === false
|| $timestamp->diff( $max )->invert === 1 ) ) {
+ if ( $timestamp !== false && ( $max === false ||
+ $timestamp->diff( $max )->invert === 1 )
+ ) {
$max = $timestamp;
}
}
@@ -136,7 +142,9 @@
}
return $max;
}
- return isset( $this->wikiTimestamps[$wiki][$section] ) ?
$this->wikiTimestamps[$wiki][$section] : false;
+ return isset( $this->wikiTimestamps[$wiki][$section] )
+ ? $this->wikiTimestamps[$wiki][$section]
+ : false;
}
protected function populate() {
@@ -201,9 +209,15 @@
foreach ( $wikis as $wiki ) {
$siteFromDB = $wgConf->siteFromDB( $wiki );
list( $major, $minor ) = $siteFromDB;
- $server = $wgConf->get( 'wgServer', $wiki, $major, [
'lang' => $minor, 'site' => $major ] );
- $scriptPath = $wgConf->get( 'wgScriptPath', $wiki,
$major, [ 'lang' => $minor, 'site' => $major ] );
- $articlePath = $wgConf->get( 'wgArticlePath', $wiki,
$major, [ 'lang' => $minor, 'site' => $major ] );
+ $server = $wgConf->get(
+ 'wgServer', $wiki, $major, [ 'lang' => $minor,
'site' => $major ]
+ );
+ $scriptPath = $wgConf->get(
+ 'wgScriptPath', $wiki, $major, [ 'lang' =>
$minor, 'site' => $major ]
+ );
+ $articlePath = $wgConf->get(
+ 'wgArticlePath', $wiki, $major, [ 'lang' =>
$minor, 'site' => $major ]
+ );
$data[$wiki] = [
'title' => static::getWikiTitle( $wiki,
$siteFromDB ),
diff --git a/includes/ForeignWikiRequest.php b/includes/ForeignWikiRequest.php
index c79ccdd..711e42e 100644
--- a/includes/ForeignWikiRequest.php
+++ b/includes/ForeignWikiRequest.php
@@ -66,7 +66,8 @@
return $api->getResult()->getResultData( [
'centralauthtoken', 'centralauthtoken' ] );
} catch ( Exception $ex ) {
LoggerFactory::getInstance( 'Echo' )->debug(
- 'Exception when fetching CentralAuth token:
wiki: {wiki}, userName: {userName}, userId: {userId}, centralId: {centralId},
exception: {exception}',
+ 'Exception when fetching CentralAuth token:
wiki: {wiki}, userName: {userName}, ' .
+ 'userId: {userId}, centralId:
{centralId}, exception: {exception}',
[
'wiki' => wfWikiID(),
'userName' => $user->getName(),
diff --git a/includes/NotifUser.php b/includes/NotifUser.php
index 751263f..a07bbfd 100644
--- a/includes/NotifUser.php
+++ b/includes/NotifUser.php
@@ -149,7 +149,9 @@
*/
public function getTalkNotificationCacheKey() {
global $wgEchoCacheVersion;
- return wfMemcKey( 'echo-new-talk-notification',
$this->mUser->getId(), $wgEchoCacheVersion );
+ return wfMemcKey(
+ 'echo-new-talk-notification', $this->mUser->getId(),
$wgEchoCacheVersion
+ );
}
/**
@@ -186,7 +188,9 @@
return $this->getNotificationCount( $cached, $dbSource,
EchoAttributeManager::ALERT );
}
- public function getLocalNotificationCount( $cached = true, $dbSource =
DB_SLAVE, $section = EchoAttributeManager::ALL ) {
+ public function getLocalNotificationCount(
+ $cached = true, $dbSource = DB_SLAVE, $section =
EchoAttributeManager::ALL
+ ) {
return $this->getNotificationCount( $cached, $dbSource,
$section, false );
}
@@ -199,10 +203,16 @@
* @param boolean $cached Set to false to bypass the cache. (Optional.
Defaults to true)
* @param int $dbSource Use master or slave database to pull count
(Optional. Defaults to DB_SLAVE)
* @param string $section Notification section
- * @param bool|string $global Whether to include foreign notifications.
If set to 'preference', uses the user's preference.
+ * @param bool|string $global Whether to include foreign notifications.
If set to 'preference',
+ * uses the user's preference.
* @return int
*/
- public function getNotificationCount( $cached = true, $dbSource =
DB_SLAVE, $section = EchoAttributeManager::ALL, $global = 'preference' ) {
+ public function getNotificationCount(
+ $cached = true,
+ $dbSource = DB_SLAVE,
+ $section = EchoAttributeManager::ALL,
+ $global = 'preference'
+ ) {
if ( $this->mUser->isAnon() ) {
return 0;
}
@@ -217,7 +227,12 @@
$global =
$this->getForeignNotifications()->isEnabledByUser();
}
- $memcKey = $this->getMemcKey( 'echo-notification-count' . (
$section === EchoAttributeManager::ALL ? '' : ( '-' . $section ) ), $global );
+ $memcKey = $this->getMemcKey(
+ 'echo-notification-count' . ( $section ===
EchoAttributeManager::ALL
+ ? ''
+ : ( '-' . $section )
+ ), $global
+ );
if ( $cached ) {
$data = $this->getFromCache( $memcKey );
if ( $data !== false && $data !== null ) {
@@ -229,10 +244,14 @@
if ( $section === EchoAttributeManager::ALL ) {
$eventTypesToLoad =
$attributeManager->getUserEnabledEvents( $this->mUser, 'web' );
} else {
- $eventTypesToLoad =
$attributeManager->getUserEnabledEventsbySections( $this->mUser, 'web', [
$section ] );
+ $eventTypesToLoad =
$attributeManager->getUserEnabledEventsbySections(
+ $this->mUser, 'web', [ $section ]
+ );
}
- $count =
(int)$this->userNotifGateway->getCappedNotificationCount( $dbSource,
$eventTypesToLoad, MWEchoNotifUser::MAX_BADGE_COUNT + 1 );
+ $count =
(int)$this->userNotifGateway->getCappedNotificationCount(
+ $dbSource, $eventTypesToLoad,
MWEchoNotifUser::MAX_BADGE_COUNT + 1
+ );
if ( $global ) {
$count = self::capNotificationCount( $count +
$this->getForeignCount( $section ) );
@@ -246,22 +265,29 @@
* Get the timestamp of the latest unread alert
*
* @param boolean $cached Set to false to bypass the cache. (Optional.
Defaults to true)
- * @param int $dbSource Use master or slave database to pull count
(Optional. Defaults to DB_SLAVE)
- * @return bool|MWTimestamp Timestamp of latest unread alert, or false
if there are no unread alerts.
+ * @param int $dbSource Use master or slave database to pull count
+ * (Optional. Defaults to DB_SLAVE)
+ * @return bool|MWTimestamp Timestamp of latest unread alert,
+ * or false if there are no unread alerts.
*/
public function getLastUnreadAlertTime( $cached = true, $dbSource =
DB_SLAVE ) {
- return $this->getLastUnreadNotificationTime( $cached,
$dbSource, EchoAttributeManager::ALERT );
+ return $this->getLastUnreadNotificationTime(
+ $cached, $dbSource, EchoAttributeManager::ALERT
+ );
}
/**
* Get the timestamp of the latest unread message
*
* @param boolean $cached Set to false to bypass the cache. (Optional.
Defaults to true)
- * @param int $dbSource Use master or slave database to pull count
(Optional. Defaults to DB_SLAVE)
+ * @param int $dbSource Use master or slave database to pull count
+ * (Optional. Defaults to DB_SLAVE)
* @return bool|MWTimestamp
*/
public function getLastUnreadMessageTime( $cached = true, $dbSource =
DB_SLAVE ) {
- return $this->getLastUnreadNotificationTime( $cached,
$dbSource, EchoAttributeManager::MESSAGE );
+ return $this->getLastUnreadNotificationTime(
+ $cached, $dbSource, EchoAttributeManager::MESSAGE
+ );
}
/**
@@ -270,12 +296,20 @@
* If $wgEchoCrossWikiNotifications is disabled, the $global parameter
is ignored.
*
* @param boolean $cached Set to false to bypass the cache. (Optional.
Defaults to true)
- * @param int $dbSource Use master or slave database to pull count
(Optional. Defaults to DB_SLAVE)
+ * @param int $dbSource Use master or slave database to pull count
+ * (Optional. Defaults to DB_SLAVE)
* @param string $section Notification section
- * @param bool|string $global Whether to include foreign notifications.
If set to 'preference', uses the user's preference.
- * @return bool|MWTimestamp Timestamp of latest unread message, or
false if there are no unread messages.
+ * @param bool|string $global Whether to include foreign notifications.
If set to 'preference',
+ * uses the user's preference.
+ * @return bool|MWTimestamp Timestamp of latest unread message,
+ * or false if there are no unread messages.
*/
- public function getLastUnreadNotificationTime( $cached = true,
$dbSource = DB_SLAVE, $section = EchoAttributeManager::ALL, $global =
'preference' ) {
+ public function getLastUnreadNotificationTime(
+ $cached = true,
+ $dbSource = DB_SLAVE,
+ $section = EchoAttributeManager::ALL,
+ $global = 'preference'
+ ) {
if ( $this->mUser->isAnon() ) {
return false;
}
@@ -290,7 +324,12 @@
$global =
$this->getForeignNotifications()->isEnabledByUser();
}
- $memcKey = $this->getMemcKey( 'echo-notification-timestamp' . (
$section === EchoAttributeManager::ALL ? '' : ( '-' . $section ) ), $global );
+ $memcKey = $this->getMemcKey( 'echo-notification-timestamp' .
+ ( $section === EchoAttributeManager::ALL
+ ? ''
+ : ( '-' . $section )
+ ), $global
+ );
// read from cache, if allowed
if ( $cached ) {
@@ -311,9 +350,13 @@
if ( $section === EchoAttributeManager::ALL ) {
$eventTypesToLoad =
$attributeManager->getUserEnabledEvents( $this->mUser, 'web' );
} else {
- $eventTypesToLoad =
$attributeManager->getUserEnabledEventsbySections( $this->mUser, 'web', [
$section ] );
+ $eventTypesToLoad =
$attributeManager->getUserEnabledEventsbySections(
+ $this->mUser, 'web', [ $section ]
+ );
}
- $notifications = $this->notifMapper->fetchUnreadByUser(
$this->mUser, 1, null, $eventTypesToLoad, null, $dbSource );
+ $notifications = $this->notifMapper->fetchUnreadByUser(
+ $this->mUser, 1, null, $eventTypesToLoad, null,
$dbSource
+ );
if ( $notifications ) {
$notification = reset( $notifications );
$timestamp = new MWTimestamp(
$notification->getTimestamp() );
@@ -368,7 +411,9 @@
$attributeManager =
EchoAttributeManager::newFromGlobalVars();
$categoryMap =
$attributeManager->getEventsByCategory();
$usertalkTypes = $categoryMap['edit-user-talk'];
- $unreadEditUserTalk =
$this->notifMapper->fetchUnreadByUser( $this->mUser, 1, null, $usertalkTypes,
null, DB_MASTER );
+ $unreadEditUserTalk =
$this->notifMapper->fetchUnreadByUser(
+ $this->mUser, 1, null, $usertalkTypes,
null, DB_MASTER
+ );
if ( count( $unreadEditUserTalk ) === 0 ) {
$this->mUser->setNewtalk( false );
}
@@ -400,7 +445,9 @@
$attributeManager =
EchoAttributeManager::newFromGlobalVars();
$categoryMap =
$attributeManager->getEventsByCategory();
$usertalkTypes = $categoryMap['edit-user-talk'];
- $unreadEditUserTalk =
$this->notifMapper->fetchUnreadByUser( $this->mUser, 1, null, $usertalkTypes,
null, DB_MASTER );
+ $unreadEditUserTalk =
$this->notifMapper->fetchUnreadByUser(
+ $this->mUser, 1, null, $usertalkTypes,
null, DB_MASTER
+ );
if ( count( $unreadEditUserTalk ) > 0 ) {
$this->mUser->setNewtalk( true );
}
@@ -433,9 +480,13 @@
}
$attributeManager = EchoAttributeManager::newFromGlobalVars();
- $eventTypes =
$attributeManager->getUserEnabledEventsbySections( $this->mUser, 'web',
$sections );
+ $eventTypes = $attributeManager->getUserEnabledEventsbySections(
+ $this->mUser, 'web', $sections
+ );
- $notifs = $this->notifMapper->fetchUnreadByUser( $this->mUser,
$wgEchoMaxUpdateCount, null, $eventTypes );
+ $notifs = $this->notifMapper->fetchUnreadByUser(
+ $this->mUser, $wgEchoMaxUpdateCount, null, $eventTypes
+ );
$eventIds = array_filter(
array_map( function ( EchoNotification $notif ) {
@@ -476,10 +527,18 @@
// Schedule an update to the echo_unread_wikis table
$uw = EchoUnreadWikis::newFromUser( $this->mUser );
if ( $uw ) {
- $alertCount = $this->getNotificationCount(
false, $dbSource, EchoAttributeManager::ALERT, false );
- $msgCount = $this->getNotificationCount( false,
$dbSource, EchoAttributeManager::MESSAGE, false );
- $alertUnread =
$this->getLastUnreadNotificationTime( false, $dbSource,
EchoAttributeManager::ALERT, false );
- $msgUnread =
$this->getLastUnreadNotificationTime( false, $dbSource,
EchoAttributeManager::MESSAGE, false );
+ $alertCount = $this->getNotificationCount(
+ false, $dbSource,
EchoAttributeManager::ALERT, false
+ );
+ $msgCount = $this->getNotificationCount(
+ false, $dbSource,
EchoAttributeManager::MESSAGE, false
+ );
+ $alertUnread =
$this->getLastUnreadNotificationTime(
+ false, $dbSource,
EchoAttributeManager::ALERT, false
+ );
+ $msgUnread =
$this->getLastUnreadNotificationTime(
+ false, $dbSource,
EchoAttributeManager::MESSAGE, false
+ );
$uw->updateCount( wfWikiID(), $alertCount,
$alertUnread, $msgCount, $msgUnread );
}
}
@@ -488,7 +547,8 @@
}
/**
- * Get the timestamp of the last time the global notification
counts/timestamps were updated, if available.
+ * Get the timestamp of the last time the global notification
counts/timestamps were updated,
+ * if available.
*
* If the timestamp of the last update is not known, this will return
the current timestamp.
* If the user is not attached, this will return false.
@@ -506,7 +566,8 @@
/**
* Invalidate user caches related to notification counts/timestamps.
*
- * This bumps the local user's touched timestamp as well as the
timestamp returned by getGlobalUpdateTime().
+ * This bumps the local user's touched timestamp as well as the
timestamp returned by
+ * getGlobalUpdateTime().
*/
protected function invalidateCache() {
// Update the user touched timestamp for the local user
@@ -674,7 +735,8 @@
* queries their APIs to find the per-section counts and timestamps for
those wikis.
*
* The results of this function are cached in the NotifUser object.
- * @return array [ (str) wiki => [ (str) section => [ 'count' => (int)
count, 'timestamp' => (str) ts ] ] ]
+ * @return array [ (str) wiki => [ (str) section =>
+ * [ 'count' => (int) count, 'timestamp' => (str) ts ] ] ]
*/
protected function getForeignData() {
if ( $this->mForeignData ) {
@@ -707,7 +769,8 @@
$this->mForeignData[$wiki][$section]['count'] = $data[$section]['rawcount'];
}
if ( isset( $data[$section]['list'][0] ) ) {
-
$this->mForeignData[$wiki][$section]['timestamp'] =
$data[$section]['list'][0]['timestamp']['mw'];
+
$this->mForeignData[$wiki][$section]['timestamp'] =
+
$data[$section]['list'][0]['timestamp']['mw'];
}
}
}
@@ -720,8 +783,8 @@
if (
// In section transition mode, we don't trust the
individual echo_unread_wikis rows
// but we do trust that alert+message=all. In bundle
transition mode, we don't trust
- // that either, but we do trust that wikis with rows in
the table have unread notifications
- // and wikis without rows in the table don't.
+ // that either, but we do trust that wikis with rows in
the table have unread
+ // notifications and wikis without rows in the table
don't.
( $wgEchoSectionTransition && $section !==
EchoAttributeManager::ALL ) ||
$wgEchoBundleTransition
) {
@@ -749,8 +812,8 @@
if (
// In section transition mode, we don't trust the
individual echo_unread_wikis rows
// but we do trust that alert+message=all. In bundle
transition mode, we don't trust
- // that either, but we do trust that wikis with rows in
the table have unread notifications
- // and wikis without rows in the table don't.
+ // that either, but we do trust that wikis with rows in
the table have unread
+ // notifications and wikis without rows in the table
don't.
( $wgEchoSectionTransition && $section !==
EchoAttributeManager::ALL ) ||
$wgEchoBundleTransition
) {
@@ -762,7 +825,9 @@
if ( isset(
$subData['timestamp'] ) ) {
$wikiTime = new
MWTimestamp( $data[$section]['timestamp'] );
// $wikiTime >
$foreignTime = invert 1
- if ( $foreignTime ===
false || $wikiTime->diff( $foreignTime )->invert === 1 ) {
+ if ( $foreignTime ===
false ||
+
$wikiTime->diff( $foreignTime )->invert === 1
+ ) {
$foreignTime =
$wikiTime;
}
}
diff --git a/includes/Notifier.php b/includes/Notifier.php
index 8a49efc..5e0f031 100644
--- a/includes/Notifier.php
+++ b/includes/Notifier.php
@@ -48,17 +48,22 @@
$attributeManager = EchoAttributeManager::newFromGlobalVars();
$userEmailNotifications =
$attributeManager->getUserEnabledEvents( $user, 'email' );
- // See if the user wants to receive emails for this category or
the user is eligible to receive this email
+ // See if the user wants to receive emails for this category or
the user is eligible
+ // to receive this email
if ( in_array( $event->getType(), $userEmailNotifications ) ) {
- global $wgEchoEnableEmailBatch, $wgEchoNotifications,
$wgNotificationSender, $wgNotificationReplyName;
+ global $wgEchoEnableEmailBatch, $wgEchoNotifications,
$wgNotificationSender,
+ $wgNotificationReplyName;
$priority = $attributeManager->getNotificationPriority(
$event->getType() );
$bundleString = $bundleHash = '';
- // We should have bundling for email digest as long as
either web or email bundling is on, for example, talk page
- // email bundling is off, but if a user decides to
receive email digest, we should bundle those messages
- if ( !empty(
$wgEchoNotifications[$event->getType()]['bundle']['web'] ) || !empty(
$wgEchoNotifications[$event->getType()]['bundle']['email'] ) ) {
+ // We should have bundling for email digest as long as
either web or email bundling is
+ // on, for example, talk page email bundling is off,
but if a user decides to receive
+ // email digest, we should bundle those messages
+ if ( !empty(
$wgEchoNotifications[$event->getType()]['bundle']['web'] ) ||
+ !empty(
$wgEchoNotifications[$event->getType()]['bundle']['email'] )
+ ) {
Hooks::run( 'EchoGetBundleRules', [ $event,
&$bundleString ] );
}
if ( $bundleString ) {
@@ -74,14 +79,18 @@
if ( !$bundleHash ) {
$bundleHash = md5( $event->getType() .
'-' . $event->getId() );
}
- MWEchoEmailBatch::addToQueue( $user->getId(),
$event->getId(), $priority, $bundleHash );
+ MWEchoEmailBatch::addToQueue(
+ $user->getId(), $event->getId(),
$priority, $bundleHash
+ );
return true;
}
// instant email notification
$toAddress = MailAddress::newFromUser( $user );
- $fromAddress = new MailAddress( $wgNotificationSender,
EchoHooks::getNotificationSenderName() );
+ $fromAddress = new MailAddress(
+ $wgNotificationSender,
EchoHooks::getNotificationSenderName()
+ );
$replyAddress = new MailAddress( $wgNotificationSender,
$wgNotificationReplyName );
// Since we are sending a single email, should set the
bundle hash to null
// if it is set with a value from somewhere else
diff --git a/includes/schemaUpdate.php b/includes/schemaUpdate.php
index 592c222..e74a487 100644
--- a/includes/schemaUpdate.php
+++ b/includes/schemaUpdate.php
@@ -86,7 +86,9 @@
$extra = $this->extra( $row, $update );
if ( isset( $extra['link-from-title'],
$extra['link-from-namespace'] ) ) {
- $title = $this->newTitleFromNsAndText(
$extra['link-from-namespace'], $extra['link-from-title'] );
+ $title = $this->newTitleFromNsAndText(
+ $extra['link-from-namespace'],
$extra['link-from-title']
+ );
unset( $extra['link-from-title'],
$extra['link-from-namespace'] );
// Link from page is always from a content page, if
null or no article id it was
// somehow invalid
--
To view, visit https://gerrit.wikimedia.org/r/364301
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5592c39298be7d5a5f0eec2978d437d9860049e9
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