r38713 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r38712‎ | r38713 | r38714 >
Date:14:05, 6 August 2008
Author:aaron
Status:old
Tags:
Comment:
* Add null edit for changes
* Bug fix if $row not present
Modified paths:
  • /trunk/extensions/FlaggedRevs/specialpages/Stabilization_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/specialpages/Stabilization_body.php
@@ -200,6 +200,7 @@
201201 }
202202
203203 $dbw = wfGetDB( DB_MASTER );
 204+ $dbw->begin();
204205 # Get current config
205206 $row = $dbw->selectRow( 'flaggedpage_config',
206207 array( 'fpc_select', 'fpc_override', 'fpc_expiry' ),
@@ -213,8 +214,8 @@
214215 __METHOD__ );
215216 $changed = ($dbw->affectedRows() != 0); // did this do anything?
216217 # 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 ) {
219220 $changed = true;
220221 $dbw->replace( 'flaggedpage_config',
221222 array( 'PRIMARY' ),
@@ -225,7 +226,6 @@
226227 __METHOD__ );
227228 }
228229 }
229 -
230230 # Log if changed
231231 # @FIXME: do this better
232232 if( $changed ) {
@@ -240,26 +240,41 @@
241241 wfMsgForContent("stabilization-def-short-{$this->override}");
242242 $settings = '[' . implode(', ',$set). ']';
243243
244 - $comment = '';
 244+ $reason = '';
245245 # Append comment with settings (other than for resets)
246246 if( !$reset ) {
247 - $comment = $this->comment ? "{$this->comment} $settings" : "$settings";
 247+ $reason = $this->comment ? "{$this->comment} $settings" : "$settings";
248248
249249 $encodedExpiry = Block::encodeExpiry($expiry, $dbw );
250250 if( $encodedExpiry != 'infinity' ) {
251251 $expiry_description = ' (' . wfMsgForContent( 'stabilize-expiring',
252252 $wgContLang->timeanddate($expiry, false, false) ) . ')';
253 - $comment .= "$expiry_description";
 253+ $reason .= "$expiry_description";
254254 }
255255 }
256256
257257 if( $reset ) {
258 - $log->addEntry( 'reset', $this->page, $comment );
 258+ $log->addEntry( 'reset', $this->page, $reason );
 259+ $type = "stable-logentry2";
259260 } else {
260 - $log->addEntry( 'config', $this->page, $comment );
 261+ $log->addEntry( 'config', $this->page, $reason );
 262+ $type = "stable-logentry";
261263 }
 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) );
262278 }
263 -
264279 # Update the links tables as the stable version may now be the default page...
265280 FlaggedRevs::titleLinksUpdate( $this->page );
266281
@@ -268,6 +283,7 @@
269284 } else {
270285 $wgUser->removeWatch( $this->page );
271286 }
 287+ $dbw->commit();
272288
273289 $wgOut->redirect( $this->page->getFullUrl() );
274290

Status & tagging log