Index: trunk/extensions/CodeReview/api/ApiRevisionUpdate.php |
— | — | @@ -45,7 +45,7 @@ |
46 | 46 | |
47 | 47 | $revisionCommitter = new CodeRevisionCommitterApi( $repo, $rev ); |
48 | 48 | |
49 | | - $revisionCommitter->doRevisionUpdate( |
| 49 | + $revisionCommitter->revisionUpdate( |
50 | 50 | $params['status'], |
51 | 51 | $params['addtags'], |
52 | 52 | $params['removetags'], |
Index: trunk/extensions/CodeReview/ui/CodeRevisionCommitter.php |
— | — | @@ -14,11 +14,18 @@ |
15 | 15 | return; |
16 | 16 | } |
17 | 17 | |
18 | | - $redirTarget = $this->doRevisionUpdate( $this->mStatus, $this->mAddTags, $this->mRemoveTags, |
| 18 | + $commentId = $this->revisionUpdate( $this->mStatus, $this->mAddTags, $this->mRemoveTags, |
19 | 19 | $this->mSignoffFlags, $this->text, $wgRequest->getIntOrNull( 'wpParent' ), |
20 | 20 | $wgRequest->getInt( 'wpReview' ) |
21 | 21 | ); |
22 | 22 | |
| 23 | + $redirTarget = null; |
| 24 | + |
| 25 | + // For comments, take us back to the rev page focused on the new comment |
| 26 | + if ( $commentId !== 0 && !$this->jumpToNext ) { |
| 27 | + $redirTarget = $this->commentLink( $commentId ); |
| 28 | + } |
| 29 | + |
23 | 30 | // Return to rev page |
24 | 31 | if ( !$redirTarget ) { |
25 | 32 | // Was "next & unresolved" clicked? |
— | — | @@ -47,9 +54,9 @@ |
48 | 55 | * @param string $commentText Comment to add to the revision |
49 | 56 | * @param null|int $parent What the parent comment is (if a subcomment) |
50 | 57 | * @param int $review (unused) |
51 | | - * @return null|bool|Title False if not a valid rev. Title for redirect target, else null |
| 58 | + * @return int Comment ID if added, else 0 |
52 | 59 | */ |
53 | | - public function doRevisionUpdate( $status, $addTags, $removeTags, $signoffFlags, $commentText, $parent = null, |
| 60 | + public function revisionUpdate( $status, $addTags, $removeTags, $signoffFlags, $commentText, $parent = null, |
54 | 61 | $review = 0 ) { |
55 | 62 | |
56 | 63 | if ( !$this->mRev ) { |
— | — | @@ -58,8 +65,6 @@ |
59 | 66 | |
60 | 67 | global $wgUser; |
61 | 68 | |
62 | | - $redirTarget = null; |
63 | | - |
64 | 69 | $dbw = wfGetDB( DB_MASTER ); |
65 | 70 | |
66 | 71 | $dbw->begin(); |
— | — | @@ -85,16 +90,12 @@ |
86 | 91 | } |
87 | 92 | // Add any comments |
88 | 93 | $commentAdded = false; |
| 94 | + $commentId = 0; |
89 | 95 | if ( strlen( $commentText ) && $this->validPost( 'codereview-post-comment' ) ) { |
90 | 96 | // $isPreview = $wgRequest->getCheck( 'wpPreview' ); |
91 | 97 | $commentId = $this->mRev->saveComment( $commentText, $review, $parent ); |
92 | 98 | |
93 | 99 | $commentAdded = ($commentId !== 0); |
94 | | - |
95 | | - // For comments, take us back to the rev page focused on the new comment |
96 | | - if ( !$this->jumpToNext ) { |
97 | | - $redirTarget = $this->commentLink( $commentId ); |
98 | | - } |
99 | 100 | } |
100 | 101 | $dbw->commit(); |
101 | 102 | |
— | — | @@ -117,6 +118,6 @@ |
118 | 119 | } |
119 | 120 | } |
120 | 121 | |
121 | | - return $redirTarget; |
| 122 | + return $commentId; |
122 | 123 | } |
123 | 124 | } |