Index: trunk/extensions/CodeReview/CodeReview.i18n.php |
— | — | @@ -104,6 +104,15 @@ |
105 | 105 | |
106 | 106 | $4', |
107 | 107 | |
| 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 | + |
108 | 117 | 'repoadmin' => 'Repository Administration', |
109 | 118 | 'repoadmin-new-legend' => 'Create a new repository', |
110 | 119 | 'repoadmin-new-label' => 'Repository name:', |
Index: trunk/extensions/CodeReview/CodeRevision.php |
— | — | @@ -156,9 +156,11 @@ |
157 | 157 | 'cr_status' => $this->mStatus, |
158 | 158 | 'cr_path' => $this->mCommonPath ), |
159 | 159 | __METHOD__, |
160 | | - array( 'IGNORE' ) ); |
| 160 | + array( 'IGNORE' ) |
| 161 | + ); |
161 | 162 | // Already exists? Update the row! |
162 | | - if ( !$dbw->affectedRows() ) { |
| 163 | + $newRevision = $dbw->affectedRows() > 0; |
| 164 | + if ( !$newRevision ) { |
163 | 165 | $dbw->update( 'code_rev', |
164 | 166 | array( |
165 | 167 | 'cr_author' => $this->mAuthor, |
— | — | @@ -168,7 +170,8 @@ |
169 | 171 | array( |
170 | 172 | 'cr_repo_id' => $this->mRepoId, |
171 | 173 | 'cr_id' => $this->mId ), |
172 | | - __METHOD__ ); |
| 174 | + __METHOD__ |
| 175 | + ); |
173 | 176 | } |
174 | 177 | // Update path tracking used for output and searching |
175 | 178 | if ( $this->mPaths ) { |
— | — | @@ -183,6 +186,7 @@ |
184 | 187 | $dbw->insert( 'code_paths', $data, __METHOD__, array( 'IGNORE' ) ); |
185 | 188 | } |
186 | 189 | // Update code relations (One-digit revs skipped due to some false-positives) |
| 190 | + $affectedRevs = array(); |
187 | 191 | if ( preg_match_all( '/\br(\d{2,})\b/', $this->mMessage, $m ) ) { |
188 | 192 | $data = array(); |
189 | 193 | foreach( $m[1] as $rev ) { |
— | — | @@ -191,10 +195,42 @@ |
192 | 196 | 'cf_from' => $this->mId, |
193 | 197 | 'cf_to' => intval($rev) |
194 | 198 | ); |
| 199 | + $affectedRevs[] = intval($rev); |
195 | 200 | } |
196 | 201 | $dbw->insert( 'code_relations', $data, __METHOD__, array( 'IGNORE' ) ); |
197 | 202 | } |
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 | + } |
199 | 235 | $dbw->commit(); |
200 | 236 | } |
201 | 237 | |