r40303 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r40302‎ | r40303 | r40304 >
Date:14:14, 1 September 2008
Author:aaron
Status:old
Tags:
Comment:
* No need to load these messages now
* Tweak userAlreadyVoted()
* Fix an image sync bug
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedArticle.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.class.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/specialpages/RatingHistory_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php
@@ -693,7 +693,7 @@
694694 if( $wgUser->isAllowed( 'feedback' ) ) {
695695 # If the user already voted, then don't show the form.
696696 # Always show for IPs however, due to squid caching...
697 - if( !$wgUser->getId() || !FlaggedRevs::userAlreadyVoted( $this->parent->getTitle() ) ) {
 697+ if( !$wgUser->getId() || !FlaggedRevs::userAlreadyVoted( $wgUser, $this->parent->getTitle() ) ) {
698698 $this->addQuickFeedback( $data );
699699 }
700700 }
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php
@@ -953,18 +953,18 @@
954954 return ( $dbw->affectedRows() > 0 );
955955 }
956956
957 - public static function userAlreadyVoted( $title ) {
958 - global $wgUser;
 957+ public static function userAlreadyVoted( $user, $title ) {
959958 $dbw = wfGetDB( DB_MASTER );
960 - # Check if user already voted before...
961 - if( $wgUser->getId() ) {
 959+ $userVoted = false;
 960+ if( $user->getId() ) {
962961 $userVoted = $dbw->selectField( array('reader_feedback','page'), '1',
963962 array( 'page_namespace' => $title->getNamespace(),
964963 'page_title' => $title->getDBKey(),
965964 'rfb_rev_id = page_latest',
966 - 'rfb_user' => $wgUser->getId() ),
 965+ 'rfb_user' => $user->getId() ),
967966 __METHOD__ );
968 - } else {
 967+ }
 968+ if( !$userVoted ) {
969969 $userVoted = $dbw->selectField( array('reader_feedback','page'), '1',
970970 array( 'page_namespace' => $title->getNamespace(),
971971 'page_title' => $title->getDBKey(),
Index: trunk/extensions/FlaggedRevs/specialpages/RatingHistory_body.php
@@ -54,8 +54,8 @@
5555 }
5656
5757 protected function showHeader() {
58 - global $wgOut;
59 - if( FlaggedRevs::userAlreadyVoted( $this->page ) ) {
 58+ global $wgOut, $wgUser;
 59+ if( FlaggedRevs::userAlreadyVoted( $wgUser, $this->page ) ) {
6060 $wgOut->addWikiText( wfMsg('ratinghistory-thanks') . '<hr/>' );
6161 }
6262 $wgOut->addWikiText( wfMsg('ratinghistory-text',$this->page->getPrefixedText()) );
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php
@@ -388,8 +388,7 @@
389389 $sha1 = "";
390390 global $wgUseStableImages;
391391 if( $wgUseStableImages && FlaggedRevs::isPageReviewable( $title ) ) {
392 - $srev = FlaggedRevision::newFromStable( $title );
393 - if( $srev ) {
 392+ if( $srev = FlaggedRevision::newFromStable( $title ) ) {
394393 $time = $srev->getFileTimestamp();
395394 $sha1 = $srev->getFileSha1();
396395 }
@@ -405,7 +404,7 @@
406405 }
407406 # If there is no stable version (or that feature is not enabled), use
408407 # the image revision during review time. If both, use the newest one.
409 - if( !FlaggedRevs::useProcessCache( $parser->getRevisionId() ) && $time === false ) {
 408+ if( !FlaggedRevs::useProcessCache( $parser->getRevisionId() ) ) {
410409 $row = $dbr->selectRow( 'flaggedimages',
411410 array( 'fi_img_timestamp', 'fi_img_sha1' ),
412411 array( 'fi_rev_id' => $parser->getRevisionId(),
@@ -457,8 +456,7 @@
458457 $sha1 = "";
459458 global $wgUseStableImages;
460459 if( $wgUseStableImages && FlaggedRevs::isPageReviewable( $nt ) ) {
461 - $srev = FlaggedRevision::newFromStable( $nt );
462 - if( $srev ) {
 460+ if( $srev = FlaggedRevision::newFromStable( $nt ) ) {
463461 $time = $srev->getFileTimestamp();
464462 $sha1 = $srev->getFileSha1();
465463 }
@@ -474,7 +472,7 @@
475473 }
476474 # If there is no stable version (or that feature is not enabled), use
477475 # the image revision during review time. If both, use the newest one.
478 - if( !FlaggedRevs::useProcessCache( $ig->mRevisionId ) && $time === false ) {
 476+ if( !FlaggedRevs::useProcessCache( $ig->mRevisionId ) ) {
479477 $row = $dbr->selectRow( 'flaggedimages',
480478 array( 'fi_img_timestamp', 'fi_img_sha1' ),
481479 array('fi_rev_id' => $ig->mRevisionId,
@@ -1092,7 +1090,6 @@
10931091 $fa = FlaggedArticle::getTitleInstance( $skintemplate->mTitle );
10941092 # Add rating tab
10951093 if( $fa->isRateable() ) {
1096 - wfLoadExtensionMessages( 'FlaggedRevs' );
10971094 wfLoadExtensionMessages( 'RatingHistory' );
10981095 $nav_urls['ratinghist'] = array(
10991096 'text' => wfMsg( 'ratinghistory-link' ),