r49530 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r49529‎ | r49530 | r49531 >
Date:21:19, 15 April 2009
Author:aaron
Status:ok
Tags:
Comment:
* Add autoreview checkbox
* Don't invalidate if page config didn't change
* Check 'review' and 'edit' rights for stabilization perm
* Code cleanups
Modified paths:
  • /trunk/extensions/FlaggedRevs/language/Stabilization.i18n.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/specialpages/Stabilization_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/language/Stabilization.i18n.php
@@ -46,6 +46,7 @@
4747 'stabilize_expiry_invalid' => 'Invalid expiration date.',
4848 'stabilize_expiry_old' => 'This expiration time has already passed.',
4949 'stabilize-expiring' => 'expires $1 (UTC)',
 50+ 'stabilization-review' => 'Review the current version',
5051 );
5152
5253 /** Message documentation (Message documentation)
Index: trunk/extensions/FlaggedRevs/specialpages/Stabilization_body.php
@@ -48,6 +48,10 @@
4949 return $wgOut->addHTML( wfMsgExt( 'stabilization-notcontent', array('parseinline'),
5050 $this->page->getPrefixedText() ) );
5151 }
 52+
 53+ # Users who cannot edit or review the page cannot set this
 54+ if( $this->isAllowed && !($this->page->userCan('edit') && $this->page->userCan('review')) )
 55+ $this->isAllowed = false;
5256
5357 # Watch checkbox
5458 $this->watchThis = $wgRequest->getCheck( 'wpWatchthis' );
@@ -60,6 +64,8 @@
6165 $this->config = FlaggedRevs::getPageVisibilitySettings( $this->page, true );
6266 $this->select = $this->config['select'];
6367 $this->override = $this->config['override'];
 68+ # Get auto-review option...
 69+ $this->reviewThis = $wgRequest->getBool( 'wpReviewthis', true );
6470 # Get autoreview restrictions...
6571 $this->autoreview = $this->config['autoreview'];
6672 # Make user readable date for GET requests
@@ -215,6 +221,7 @@
216222 $watchLabel = wfMsgExt( 'watchthis', array('parseinline') );
217223 $watchAttribs = array('accesskey' => wfMsg( 'accesskey-watch' ), 'id' => 'wpWatchthis');
218224 $watchChecked = ( $wgUser->getOption( 'watchdefault' ) || $this->page->userIsWatching() );
 225+ $reviewLabel = wfMsgExt( 'stabilization-review', array('parseinline') );
219226
220227 $form .= ' <tr>
221228 <td class="mw-label">' .
@@ -235,6 +242,9 @@
236243 <tr>
237244 <td></td>
238245 <td class="mw-input">' .
 246+ Xml::check( 'wpReviewthis', $this->reviewThis, array('id'=>'wpReviewthis') ) .
 247+ "<label for='wpReviewthis'>{$reviewLabel}</label>" .
 248+ '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' .
239249 Xml::check( 'wpWatchthis', $watchChecked, $watchAttribs ) .
240250 "<label for='wpWatchthis'" . $this->skin->tooltipAndAccesskey( 'watch' ) .
241251 ">{$watchLabel}</label>" .
@@ -311,7 +321,6 @@
312322
313323 protected function submit() {
314324 global $wgOut, $wgUser, $wgContLang;
315 -
316325 $changed = $reset = false;
317326 $defaultPrecedence = FlaggedRevs::getPrecedence();
318327 $defaultOverride = FlaggedRevs::showStableByDefault();
@@ -364,15 +373,18 @@
365374 'fpc_override' => $this->override,
366375 'fpc_level' => $this->autoreview,
367376 'fpc_expiry' => $expiry ),
368 - __METHOD__ );
 377+ __METHOD__
 378+ );
369379 }
370380 }
371 - # Log if changed
372 - # @FIXME: do this better
 381+ $query = '';
 382+ // Check if this actually changed anything...
373383 if( $changed ) {
374 - $log = new LogPage( 'stable' );
 384+ $id = $this->page->getArticleId();
 385+ $latest = $this->page->getLatestRevID( GAID_FOR_UPDATE );
375386 # ID, accuracy, depth, style
376387 $set = array();
 388+ # @FIXME: do this better
377389 $set[] = wfMsgForContent( "stabilization-sel-short" ) . wfMsgForContent( 'colon-separator' ) .
378390 wfMsgForContent("stabilization-sel-short-{$this->select}");
379391 $set[] = wfMsgForContent( "stabilization-def-short" ) . wfMsgForContent( 'colon-separator' ) .
@@ -381,12 +393,10 @@
382394 $set[] = "autoreview={$this->autoreview}";
383395 }
384396 $settings = '[' . implode(', ',$set). ']';
385 -
 397+ # Append comment with settings (other than for resets)
386398 $reason = '';
387 - # Append comment with settings (other than for resets)
388399 if( !$reset ) {
389400 $reason = $this->reason ? "{$this->reason} $settings" : "$settings";
390 -
391401 $encodedExpiry = Block::encodeExpiry($expiry, $dbw );
392402 if( $encodedExpiry != 'infinity' ) {
393403 $expiry_description = ' (' . wfMsgForContent( 'stabilize-expiring',
@@ -396,7 +406,8 @@
397407 $reason .= "$expiry_description";
398408 }
399409 }
400 -
 410+ # Add log entry...
 411+ $log = new LogPage( 'stable' );
401412 if( $reset ) {
402413 $log->addEntry( 'reset', $this->page, $reason );
403414 $type = "stable-logentry2";
@@ -404,13 +415,11 @@
405416 $log->addEntry( 'config', $this->page, $reason );
406417 $type = "stable-logentry";
407418 }
 419+ # Build null-edit comment
408420 $comment = $wgContLang->ucfirst( wfMsgForContent( $type, $this->page->getPrefixedText() ) );
409421 if( $reason ) {
410422 $comment .= ": $reason";
411423 }
412 -
413 - $id = $this->page->getArticleId();
414 - $latest = $this->page->getLatestRevID( GAID_FOR_UPDATE );
415424 # Insert a null revision
416425 $nullRevision = Revision::newNullRevision( $dbw, $id, $comment, true );
417426 $nullRevId = $nullRevision->insertOn( $dbw );
@@ -418,28 +427,40 @@
419428 $article = new Article( $this->page );
420429 $article->updateRevisionOn( $dbw, $nullRevision, $latest );
421430 wfRunHooks( 'NewRevisionFromEditComplete', array($article, $nullRevision, $latest) );
 431+
 432+ $invalidate = true;
 433+ # Take the user to the diff if an outdated version is being
 434+ # set as the default. This is really an issue with configs
 435+ # that only let certain pages be reviewed.
 436+ $frev = FlaggedRevision::newFromStable( $this->page, FR_MASTER );
 437+ $cfLevel = FlaggedRevs::getPrecedence( $this->select ); // desired level
 438+ // Is the page out of sync? Is there no stable version?
 439+ if( !$frev || $frev->getRevId() != $nullRevId || $frev->getQuality() != $cfLevel ) {
 440+ $flags = FlaggedRevs::quickTags( $cfLevel ); // desired flags
 441+ // Try to autoreview to this level...
 442+ if( $this->reviewThis && RevisionReview::userCanSetFlags($flags) ) {
 443+ $text = $nullRevision->getText();
 444+ FlaggedRevs::autoReviewEdit( $article, $wgUser, $text, $nullRevision, $flags, true );
 445+ $invalidate = false; // already done with auto-review
 446+ // ...otherwise, go to diff if possible
 447+ } else if( $frev ) {
 448+ $query = "oldid={$frev->getRevId()}&diff=cur&diffonly=0";
 449+ } else {
 450+ // can't autoreview and no diff to show...
 451+ }
 452+ }
 453+ # Update the links tables as the stable version may now be the default page...
 454+ if( $invalidate ) {
 455+ FlaggedRevs::titleLinksUpdate( $this->page );
 456+ }
422457 }
423 - # Update the links tables as the stable version may now be the default page...
424 - FlaggedRevs::titleLinksUpdate( $this->page );
425458 # Apply watchlist checkbox value
426459 if( $this->watchThis ) {
427460 $wgUser->addWatch( $this->page );
428461 } else {
429462 $wgUser->removeWatch( $this->page );
430463 }
431 -
432 - $query = '';
433 - # Take the user to the diff to make sure an outdated version isn't
434 - # being set at the default. This is really an issue with configs
435 - # that only let certain pages be reviewed.
436 - if( $changed && $this->select != FLAGGED_VIS_LATEST ) {
437 - $frev = FlaggedRevision::newFromStable( $this->page, FR_MASTER );
438 - if( $frev && $frev->getRevId() != $nullRevId ) {
439 - $query = "oldid={$frev->getRevId()}&diff=cur&diffonly=0"; // override diff-only
440 - }
441 - }
442464 $wgOut->redirect( $this->page->getFullUrl( $query ) );
443 -
444465 return true;
445466 }
446467 }

Status & tagging log