Index: trunk/extensions/ArticleAssessmentPilot/api/ApiArticleAssessment.php |
— | — | @@ -124,7 +124,7 @@ |
125 | 125 | |
126 | 126 | $timestamp = $dbw->timestamp(); |
127 | 127 | |
128 | | - $res = $dbw->insert( |
| 128 | + $dbw->insert( |
129 | 129 | 'article_assessment', |
130 | 130 | array_merge( |
131 | 131 | array( |
— | — | @@ -142,24 +142,25 @@ |
143 | 143 | array( 'IGNORE' ) |
144 | 144 | ); |
145 | 145 | |
146 | | - //TODO: Don't do this if the insert was successful |
147 | | - $dbw->update( |
148 | | - 'article_assessment', |
149 | | - array( |
150 | | - 'aa_timestamp' => $timestamp, |
151 | | - 'aa_rating_value' => $ratingValue, |
152 | | - ), |
153 | | - array_merge( |
| 146 | + if ( !$dbw->affectedRows() ) { |
| 147 | + $dbw->update( |
| 148 | + 'article_assessment', |
154 | 149 | array( |
155 | | - 'aa_page_id' => $pageId, |
156 | | - 'aa_user_text' => $user->getName(), |
157 | | - 'aa_revision' => $revisionId, |
158 | | - 'aa_rating_id' => $ratingId, |
| 150 | + 'aa_timestamp' => $timestamp, |
| 151 | + 'aa_rating_value' => $ratingValue, |
159 | 152 | ), |
160 | | - $token |
161 | | - ), |
162 | | - __METHOD__ |
163 | | - ); |
| 153 | + array_merge( |
| 154 | + array( |
| 155 | + 'aa_page_id' => $pageId, |
| 156 | + 'aa_user_text' => $user->getName(), |
| 157 | + 'aa_revision' => $revisionId, |
| 158 | + 'aa_rating_id' => $ratingId, |
| 159 | + ), |
| 160 | + $token |
| 161 | + ), |
| 162 | + __METHOD__ |
| 163 | + ); |
| 164 | + } |
164 | 165 | } |
165 | 166 | |
166 | 167 | public function getAllowedParams() { |