r49088 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r49087‎ | r49088 | r49089 >
Date:16:22, 31 March 2009
Author:aaron
Status:ok (Comments)
Tags:
Comment:
(bug 18211) E-mail notify when a followup rev is made
Modified paths:
  • /trunk/extensions/CodeReview/CodeReview.i18n.php (modified) (history)
  • /trunk/extensions/CodeReview/CodeRevision.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/CodeReview.i18n.php
@@ -104,6 +104,15 @@
105105
106106 $4',
107107
 108+ 'codereview-email-subj2' => '[$1] [r$2]: Follow-up changes',
 109+ 'codereview-email-body2' => 'User "$1" made follow-up changes to r$2.
 110+
 111+Full URL: $3
 112+
 113+Commit summary:
 114+
 115+$4',
 116+
108117 'repoadmin' => 'Repository Administration',
109118 'repoadmin-new-legend' => 'Create a new repository',
110119 'repoadmin-new-label' => 'Repository name:',
Index: trunk/extensions/CodeReview/CodeRevision.php
@@ -156,9 +156,11 @@
157157 'cr_status' => $this->mStatus,
158158 'cr_path' => $this->mCommonPath ),
159159 __METHOD__,
160 - array( 'IGNORE' ) );
 160+ array( 'IGNORE' )
 161+ );
161162 // Already exists? Update the row!
162 - if ( !$dbw->affectedRows() ) {
 163+ $newRevision = $dbw->affectedRows() > 0;
 164+ if ( !$newRevision ) {
163165 $dbw->update( 'code_rev',
164166 array(
165167 'cr_author' => $this->mAuthor,
@@ -168,7 +170,8 @@
169171 array(
170172 'cr_repo_id' => $this->mRepoId,
171173 'cr_id' => $this->mId ),
172 - __METHOD__ );
 174+ __METHOD__
 175+ );
173176 }
174177 // Update path tracking used for output and searching
175178 if ( $this->mPaths ) {
@@ -183,6 +186,7 @@
184187 $dbw->insert( 'code_paths', $data, __METHOD__, array( 'IGNORE' ) );
185188 }
186189 // Update code relations (One-digit revs skipped due to some false-positives)
 190+ $affectedRevs = array();
187191 if ( preg_match_all( '/\br(\d{2,})\b/', $this->mMessage, $m ) ) {
188192 $data = array();
189193 foreach( $m[1] as $rev ) {
@@ -191,10 +195,42 @@
192196 'cf_from' => $this->mId,
193197 'cf_to' => intval($rev)
194198 );
 199+ $affectedRevs[] = intval($rev);
195200 }
196201 $dbw->insert( 'code_relations', $data, __METHOD__, array( 'IGNORE' ) );
197202 }
198 -
 203+ // Email the authors of revisions that this follows up on
 204+ if( $newRevision && count($affectedRevs) > 0 ) {
 205+ // Get committer wiki user name, or repo name at least
 206+ $user = $this->mRepo->authorWikiUser( $this->mAuthor );
 207+ $committer = $user ? $user->getName() : htmlspecialchars($this->mAuthor);
 208+ // Get the authors of these revisions
 209+ $res = $dbw->select( 'code_rev',
 210+ array( 'cr_author', 'cr_id' ),
 211+ array(
 212+ 'cr_repo_id' => $this->mRepoId,
 213+ 'cr_id' => $affectedRevs,
 214+ // No sense in notifying if it's the same person
 215+ 'cr_author != '.$dbw->addQuotes($this->mAuthor)
 216+ ),
 217+ __METHOD__,
 218+ array( 'USE INDEX' => 'PRIMARY' )
 219+ );
 220+ // Get repo and build comment title (for url)
 221+ $title = SpecialPage::getTitleFor( 'Code', $this->mRepo->getName() . '/' . $this->mId );
 222+ $url = $title->getFullUrl();
 223+ foreach( $res as $row ) {
 224+ $user = $this->mRepo->authorWikiUser( $row->cr_author );
 225+ // User must exist on wiki and have a valid email addy
 226+ if( !$user || !$user->canReceiveEmail() ) continue;
 227+ // Send message in receiver's language
 228+ $lang = array( 'language' => $user->getOption( 'language' ) );
 229+ $user->sendMail(
 230+ wfMsgExt( 'codereview-email-subj2', $lang, $this->mRepo->getName(), $row->cr_id ),
 231+ wfMsgExt( 'codereview-email-body2', $lang, $committer, $row->cr_id, $url, $this->mMessage )
 232+ );
 233+ }
 234+ }
199235 $dbw->commit();
200236 }
201237

Comments

#Comment by Siebrand (talk | contribs)   10:04, 15 June 2009

Just got a mail containing "<codereview-email-subj2>" as subject, and <codereview-email-body2> as content. Could that originate from here?

Status & tagging log