Index: trunk/extensions/FlaggedRevs/specialpages/Stabilization_body.php |
— | — | @@ -200,6 +200,7 @@ |
201 | 201 | } |
202 | 202 | |
203 | 203 | $dbw = wfGetDB( DB_MASTER ); |
| 204 | + $dbw->begin(); |
204 | 205 | # Get current config |
205 | 206 | $row = $dbw->selectRow( 'flaggedpage_config', |
206 | 207 | array( 'fpc_select', 'fpc_override', 'fpc_expiry' ), |
— | — | @@ -213,8 +214,8 @@ |
214 | 215 | __METHOD__ ); |
215 | 216 | $changed = ($dbw->affectedRows() != 0); // did this do anything? |
216 | 217 | # Otherwise, add a row unless we are just setting it as the site default, or it is the same the current one... |
217 | | - } else if( $this->select !=0 || $this->override !=$wgFlaggedRevsOverride ) { |
218 | | - if( $row->fpc_select != $this->select || $row->fpc_override != $this->override || $row->fpc_expiry !== $expiry ) { |
| 218 | + } else if( $this->select !=0 || $this->override != $wgFlaggedRevsOverride ) { |
| 219 | + if( !$row || $row->fpc_select != $this->select || $row->fpc_override != $this->override || $row->fpc_expiry != $expiry ) { |
219 | 220 | $changed = true; |
220 | 221 | $dbw->replace( 'flaggedpage_config', |
221 | 222 | array( 'PRIMARY' ), |
— | — | @@ -225,7 +226,6 @@ |
226 | 227 | __METHOD__ ); |
227 | 228 | } |
228 | 229 | } |
229 | | - |
230 | 230 | # Log if changed |
231 | 231 | # @FIXME: do this better |
232 | 232 | if( $changed ) { |
— | — | @@ -240,26 +240,41 @@ |
241 | 241 | wfMsgForContent("stabilization-def-short-{$this->override}"); |
242 | 242 | $settings = '[' . implode(', ',$set). ']'; |
243 | 243 | |
244 | | - $comment = ''; |
| 244 | + $reason = ''; |
245 | 245 | # Append comment with settings (other than for resets) |
246 | 246 | if( !$reset ) { |
247 | | - $comment = $this->comment ? "{$this->comment} $settings" : "$settings"; |
| 247 | + $reason = $this->comment ? "{$this->comment} $settings" : "$settings"; |
248 | 248 | |
249 | 249 | $encodedExpiry = Block::encodeExpiry($expiry, $dbw ); |
250 | 250 | if( $encodedExpiry != 'infinity' ) { |
251 | 251 | $expiry_description = ' (' . wfMsgForContent( 'stabilize-expiring', |
252 | 252 | $wgContLang->timeanddate($expiry, false, false) ) . ')'; |
253 | | - $comment .= "$expiry_description"; |
| 253 | + $reason .= "$expiry_description"; |
254 | 254 | } |
255 | 255 | } |
256 | 256 | |
257 | 257 | if( $reset ) { |
258 | | - $log->addEntry( 'reset', $this->page, $comment ); |
| 258 | + $log->addEntry( 'reset', $this->page, $reason ); |
| 259 | + $type = "stable-logentry2"; |
259 | 260 | } else { |
260 | | - $log->addEntry( 'config', $this->page, $comment ); |
| 261 | + $log->addEntry( 'config', $this->page, $reason ); |
| 262 | + $type = "stable-logentry"; |
261 | 263 | } |
| 264 | + $comment = $wgContLang->ucfirst( wfMsgForContent( $type, $this->page->getPrefixedText() ) ); |
| 265 | + if( $reason ) { |
| 266 | + $comment .= ": $reason"; |
| 267 | + } |
| 268 | + |
| 269 | + $id = $this->page->getArticleId(); |
| 270 | + $latest = $this->page->getLatestRevID( GAID_FOR_UPDATE ); |
| 271 | + # Insert a null revision |
| 272 | + $nullRevision = Revision::newNullRevision( $dbw, $id, $comment, true ); |
| 273 | + $nullRevId = $nullRevision->insertOn( $dbw ); |
| 274 | + # Update page record |
| 275 | + $article = new Article( $this->page ); |
| 276 | + $article->updateRevisionOn( $dbw, $nullRevision, $latest ); |
| 277 | + wfRunHooks( 'NewRevisionFromEditComplete', array($article, $nullRevision, $latest) ); |
262 | 278 | } |
263 | | - |
264 | 279 | # Update the links tables as the stable version may now be the default page... |
265 | 280 | FlaggedRevs::titleLinksUpdate( $this->page ); |
266 | 281 | |
— | — | @@ -268,6 +283,7 @@ |
269 | 284 | } else { |
270 | 285 | $wgUser->removeWatch( $this->page ); |
271 | 286 | } |
| 287 | + $dbw->commit(); |
272 | 288 | |
273 | 289 | $wgOut->redirect( $this->page->getFullUrl() ); |
274 | 290 | |