r45236 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r45235‎ | r45236 | r45237 >
Date:18:21, 31 December 2008
Author:aaron
Status:deferred
Tags:
Comment:
* Removed one profile call
* Various minor tweaks. Shouldn't change function.
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedArticle.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.class.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php
@@ -138,7 +138,8 @@
139139 * @returns bool
140140 */
141141 public function lowProfileUI() {
142 - return FlaggedRevs::lowProfileUI() && FlaggedRevs::showStableByDefault() == $this->showStableByDefault();
 142+ return FlaggedRevs::lowProfileUI() &&
 143+ FlaggedRevs::showStableByDefault() == $this->showStableByDefault();
143144 }
144145
145146 /**
@@ -193,26 +194,27 @@
194195 */
195196 public function addStableLink() {
196197 global $wgRequest, $wgOut, $wgLang;
197 - if( $wgRequest->getVal('oldid') ) {
198 - # We may have nav links like "direction=prev&oldid=x"
199 - $revID = $this->parent->getOldIDFromRequest();
200 - $frev = FlaggedRevision::newFromTitle( $this->parent->getTitle(), $revID );
201 - # Give a notice if this rev ID corresponds to a reviewed version...
202 - if( !is_null($frev) ) {
203 - wfLoadExtensionMessages( 'FlaggedRevs' );
204 - $time = $wgLang->date( $frev->getTimestamp(), true );
205 - $flags = $frev->getTags();
206 - $quality = FlaggedRevs::isQuality( $flags );
207 - $msg = $quality ? 'revreview-quality-source' : 'revreview-basic-source';
208 - $tag = wfMsgExt( $msg, array('parseinline'), $frev->getRevId(), $time );
209 - # Hide clutter
210 - if( !FlaggedRevs::useSimpleUI() && !empty($flags) ) {
211 - $tag .= " " . FlaggedRevsXML::ratingToggle() . "<span id='mw-revisionratings' style='display:block;'>" .
212 - "<br/>" . wfMsgHtml('revreview-oldrating') . FlaggedRevsXML::addTagRatings( $flags ) . '</span>';
213 - }
214 - $tag = "<div id='mw-revisiontag-old' class='flaggedrevs_notice plainlinks noprint'>$tag</div>";
215 - $wgOut->addHTML( $tag );
 198+ if( !$wgRequest->getVal('oldid') )
 199+ return true; # Only for viewing old versions
 200+ # We may have nav links like "direction=prev&oldid=x"
 201+ $revID = $this->parent->getOldIDFromRequest();
 202+ $frev = FlaggedRevision::newFromTitle( $this->parent->getTitle(), $revID );
 203+ # Give a notice if this rev ID corresponds to a reviewed version...
 204+ if( !is_null($frev) ) {
 205+ wfLoadExtensionMessages( 'FlaggedRevs' );
 206+ $time = $wgLang->date( $frev->getTimestamp(), true );
 207+ $flags = $frev->getTags();
 208+ $quality = FlaggedRevs::isQuality( $flags );
 209+ $msg = $quality ? 'revreview-quality-source' : 'revreview-basic-source';
 210+ $tag = wfMsgExt( $msg, array('parseinline'), $frev->getRevId(), $time );
 211+ # Hide clutter
 212+ if( !FlaggedRevs::useSimpleUI() && !empty($flags) ) {
 213+ $tag .= " " . FlaggedRevsXML::ratingToggle() .
 214+ "<span id='mw-revisionratings' style='display:block;'><br/>" .
 215+ wfMsgHtml('revreview-oldrating') . FlaggedRevsXML::addTagRatings( $flags ) . '</span>';
216216 }
 217+ $tag = "<div id='mw-revisiontag-old' class='flaggedrevs_notice plainlinks noprint'>$tag</div>";
 218+ $wgOut->addHTML( $tag );
217219 }
218220 return true;
219221 }
@@ -414,7 +416,6 @@
415417 $msg = $synced ? "{$msg}-same" : $msg;
416418 $html = "{$prot}<span class='{$class}' title=\"{$tooltip}\"></span>" .
417419 wfMsgExt( $msg, array('parseinline'), $frev->getRevId(), $revsSince );
418 -
419420 $tag = FlaggedRevsXML::prettyRatingBox( $frev, $html, $revsSince, true, $synced );
420421 // Standard UI
421422 } else {
@@ -521,8 +522,7 @@
522523 }
523524
524525 if( !$time ) {
525 - // Use the default behaviour
526 - return;
 526+ return; // Use the default behaviour
527527 }
528528
529529 $title = $this->parent->getTitle();
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php
@@ -212,10 +212,11 @@
213213 1 => 'quality',
214214 2 => 'pristine'
215215 );
216 - if ( isset( $levelText[$level] ) )
 216+ if( isset( $levelText[$level] ) ) {
217217 return $levelText[$level];
218 - else
219 - return '';
 218+ } else {
 219+ return '';
 220+ }
220221 }
221222
222223 ################# Parsing functions #################
@@ -236,7 +237,8 @@
237238 $options = self::makeParserOptions();
238239 $outputText = $wgParser->preprocess( $text, $title, $options, $id );
239240 $out =& $wgParser->mOutput;
240 - $data = array( $outputText, $out->mTemplates, $out->mTemplateIds, $out->fr_includeErrors, $out->fr_newestTemplateID );
 241+ $data = array( $outputText, $out->mTemplates, $out->mTemplateIds,
 242+ $out->fr_includeErrors, $out->fr_newestTemplateID );
241243 # Done!
242244 $wgParser->fr_isStable = false;
243245 # Return data array
@@ -258,7 +260,6 @@
259261 $wgParser->fr_isStable = true;
260262 # Don't show section-edit links, they can be old and misleading
261263 $options = self::makeParserOptions();
262 - #$options->setEditSection( $id == $title->getLatestRevID(GAID_FOR_UPDATE) );
263264 # Parse the new body, wikitext -> html
264265 $parserOut = $wgParser->parse( $text, $title, $options, true, true, $id );
265266 # Done with parser!
@@ -286,7 +287,6 @@
287288 */
288289 public static function getPageCache( $article ) {
289290 global $wgUser, $parserMemc, $wgCacheEpoch;
290 -
291291 wfProfileIn( __METHOD__ );
292292 # Make sure it is valid
293293 if( !$article->getId() )
@@ -326,7 +326,6 @@
327327 }
328328
329329 wfProfileOut( __METHOD__ );
330 -
331330 return $value;
332331 }
333332
@@ -471,6 +470,7 @@
472471 * This function is pretty expensive...
473472 */
474473 public static function stableVersionIsSynced( $srev, $article, $stableOutput=null, $currentOutput=null ) {
 474+ global $wgMemc, $wgEnableParserCache;
475475 # Must be the same revision
476476 if( $srev->getRevId() != $article->getTitle()->getLatestRevID(GAID_FOR_UPDATE) ) {
477477 return false;
@@ -481,7 +481,6 @@
482482 return false;
483483 }
484484 }
485 - global $wgMemc, $wgEnableParserCache;
486485 # Try the cache...
487486 $key = wfMemcKey( 'flaggedrevs', 'includesSynced', $article->getId() );
488487 $value = self::getMemcValue( $wgMemc->get($key), $article );
@@ -606,11 +605,9 @@
607606 if( !$article->getId() )
608607 return true; // no bogus entries
609608
610 - wfProfileIn( __METHOD__ );
611609 $lastID = $latest ? $latest : $article->getTitle()->getLatestRevID(GAID_FOR_UPDATE);
612 -
 610+ # Get the highest quality revision (not necessarily this one)
613611 $dbw = wfGetDB( DB_MASTER );
614 - # Get the highest quality revision (not necessarily this one).
615612 $maxQuality = $dbw->selectField( array('flaggedrevs','revision'),
616613 'fr_quality',
617614 array( 'fr_page_id' => $article->getId(),
@@ -641,7 +638,6 @@
642639 # Updates the count cache
643640 $count = self::getRevCountSince( $article, $revId, true );
644641
645 - wfProfileOut( __METHOD__ );
646642 return true;
647643 }
648644
@@ -754,8 +750,8 @@
755751 $row = $db->selectRow( 'flaggedpage_config',
756752 array( 'fpc_select', 'fpc_override', 'fpc_expiry' ),
757753 array( 'fpc_page_id' => $title->getArticleID() ),
758 - __METHOD__ );
759 -
 754+ __METHOD__
 755+ );
760756 if( $row ) {
761757 $now = wfTimestampNow();
762758 # This code should be refactored, now that it's being used more generally.
@@ -775,8 +771,8 @@
776772 $select = $wgFlaggedRevsPrecedence ? FLAGGED_VIS_NORMAL : FLAGGED_VIS_LATEST;
777773 return array('select' => $select, 'override' => $override, 'expiry' => 'infinity');
778774 }
779 -
780 - return array('select' => $row->fpc_select, 'override' => $row->fpc_override, 'expiry' => $row->fpc_expiry);
 775+ return array('select' => $row->fpc_select, 'override' => $row->fpc_override,
 776+ 'expiry' => $row->fpc_expiry );
781777 }
782778
783779 /**
@@ -786,7 +782,8 @@
787783 $dbw = wfGetDB( DB_MASTER );
788784 $dbw->delete( 'flaggedpage_config',
789785 array( 'fpc_expiry < ' . $dbw->addQuotes( $dbw->timestamp() ) ),
790 - __METHOD__ );
 786+ __METHOD__
 787+ );
791788 }
792789
793790 ################# Other utility functions #################
@@ -797,15 +794,11 @@
798795 */
799796 public static function isQuality( $flags ) {
800797 global $wgFlaggedRevTags;
801 -
802 - if( empty($flags) )
803 - return false;
804 -
 798+ if( empty($flags) ) return false;
805799 foreach( $wgFlaggedRevTags as $f => $v ) {
806800 if( !isset($flags[$f]) || $v > $flags[$f] )
807801 return false;
808802 }
809 -
810803 return true;
811804 }
812805
@@ -815,15 +808,11 @@
816809 */
817810 public static function isPristine( $flags ) {
818811 global $wgFlaggedRevTags, $wgFlaggedRevPristine;
819 -
820 - if( empty($flags) )
821 - return false;
822 -
 812+ if( empty($flags) ) return false;
823813 foreach( $wgFlaggedRevTags as $f => $v ) {
824814 if( !isset($flags[$f]) || $flags[$f] < $wgFlaggedRevPristine )
825815 return false;
826816 }
827 -
828817 return true;
829818 }
830819

Status & tagging log