r70588 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70587‎ | r70588 | r70589 >
Date:19:34, 6 August 2010
Author:reedy
Status:resolved
Tags:
Comment:
*(bug 24689) Email all commenters when a followup rev is being committed
Modified paths:
  • /trunk/extensions/CodeReview/backend/CodeRevision.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/backend/CodeRevision.php
@@ -301,15 +301,23 @@
302302 $dbw->insert( 'code_relations', $data, __METHOD__, array( 'IGNORE' ) );
303303 }
304304
305 - global $wgEnableEmail;
 305+ global $wgEnableEmail, $wgUser;
306306 // Email the authors of revisions that this follows up on
307307 if ( $wgEnableEmail && $newRevision && count( $affectedRevs ) > 0 ) {
308308 // Get committer wiki user name, or repo name at least
309 - $user = $this->mRepo->authorWikiUser( $this->mAuthor );
 309+ $user = $this->getWikiUser();
310310 $committer = $user ? $user->getName() : htmlspecialchars( $this->mAuthor );
311311 // Get the authors of these revisions
312312 $res = $dbw->select( 'code_rev',
313 - array( 'cr_author', 'cr_id' ),
 313+ array(
 314+ 'cr_repo_id',
 315+ 'cr_id',
 316+ 'cr_author',
 317+ 'cr_timestamp',
 318+ 'cr_message',
 319+ 'cr_status',
 320+ 'cr_path',
 321+ ),
314322 array(
315323 'cr_repo_id' => $this->mRepoId,
316324 'cr_id' => $affectedRevs,
@@ -326,18 +334,30 @@
327335 $url = $title->getFullUrl();
328336
329337 foreach ( $res as $row ) {
330 - $user = $this->mRepo->authorWikiUser( $row->cr_author );
331 - // User must exist on wiki and have a valid email addy
332 - if ( !$user || !$user->canReceiveEmail() ) {
333 - continue;
 338+ $revision = CodeRevision::newFromRow( $row );
 339+ $users = $revision->getCommentingUsers();
 340+
 341+ //Add the revision author if they have not already been added as a commentor (they won't want dupe emails!)
 342+ if ( !array_key_exists( $user->getId(), $users ) {
 343+ $users[$user->getId()] = $user;
334344 }
335345
336 - // Send message in receiver's language
337 - $lang = array( 'language' => $user->getOption( 'language' ) );
338 - $user->sendMail(
339 - wfMsgExt( 'codereview-email-subj2', $lang, $this->mRepo->getName(), $this->getIdString( $row->cr_id ) ),
340 - wfMsgExt( 'codereview-email-body2', $lang, $committer, $this->getIdStringUnique( $row->cr_id ), $url, $this->mMessage )
341 - );
 346+ //Notify commenters and revision author of followup revision
 347+ foreach ( $users as $userId => $user ) {
 348+ // No sense in notifying the author if they are a commenter on the target rev
 349+ if ( $wgUser->getId() == $user->getId() ) {
 350+ continue;
 351+ }
 352+
 353+ if ( $user->canReceiveEmail() ) {
 354+ // Send message in receiver's language
 355+ $lang = array( 'language' => $user->getOption( 'language' ) );
 356+ $user->sendMail(
 357+ wfMsgExt( 'codereview-email-subj2', $lang, $this->mRepo->getName(), $this->getIdString( $row->cr_id ) ),
 358+ wfMsgExt( 'codereview-email-body2', $lang, $committer, $this->getIdStringUnique( $row->cr_id ), $url, $this->mMessage )
 359+ );
 360+ }
 361+ }
342362 }
343363 }
344364 $dbw->commit();

Follow-up revisions

RevisionCommit summaryAuthorDate
r70589Minor followup to r70588...reedy19:52, 6 August 2010
r71827Followup r70588, add missing CodeRepository parameterreedy23:51, 27 August 2010

Status & tagging log