r62269 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62268‎ | r62269 | r62270 >
Date:22:04, 10 February 2010
Author:aaron
Status:ok
Tags:
Comment:
* removed getFlagsForRevision(); unused
* made getVisibilitySettings() use FR_MASTER rather than boolean
* use master DB in some key places
* doc fixes
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedArticle.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevision.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.class.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevision.php
@@ -25,7 +25,7 @@
2626 private $mRevId;
2727
2828 /**
29 - * @param Row $row (from database)
 29+ * @param mixed $row (DB row or array)
3030 */
3131 public function __construct( $row ) {
3232 if ( is_object( $row ) ) {
@@ -69,11 +69,12 @@
7070 }
7171
7272 /**
 73+ * Get a FlaggedRevision for a title and rev ID.
 74+ * Note: will return NULL if the revision is deleted.
7375 * @param Title $title
7476 * @param int $revId
7577 * @param int $flags
7678 * @returns mixed FlaggedRevision (null on failure)
77 - * Will not return a revision if deleted
7879 */
7980 public static function newFromTitle( Title $title, $revId, $flags = 0 ) {
8081 $columns = self::selectFields();
@@ -116,7 +117,7 @@
117118 }
118119
119120 /**
120 - * Get latest quality rev, if not, the latest reviewed one.
 121+ * Get a FlaggedRevision of the stable version of a title.
121122 * @param Title $title, page title
122123 * @param int $flags
123124 * @param array $config, optional page config (use to skip queries)
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php
@@ -233,7 +233,7 @@
234234 public static function onTitleMoveComplete( &$otitle, &$ntitle, $user, $pageId ) {
235235 $fa = FlaggedArticle::getTitleInstance( $ntitle );
236236 // Re-validate NS/config (new title may not be reviewable)
237 - if ( $fa->isReviewable() ) {
 237+ if ( $fa->isReviewable( FR_MASTER ) ) {
238238 // Moved from non-reviewable to reviewable NS?
239239 if ( FlaggedRevs::autoReviewNewPages() && $user->isAllowed( 'autoreview' )
240240 && !FlaggedRevs::inReviewNamespace( $otitle ) )
@@ -261,8 +261,8 @@
262262 $sv = $u->fr_stableRev; // Try the process cache...
263263 } else {
264264 $fa = FlaggedArticle::getTitleInstance( $linksUpdate->mTitle );
265 - if ( $fa->isReviewable() ) { // re-validate NS/config
266 - $sv = $fa->getStableRev( FR_MASTER );
 265+ if ( FlaggedRevs::inReviewNamespace( $linksUpdate->mTitle ) ) {
 266+ $sv = $fa->getStableRev( FR_MASTER ); // re-validate NS/config
267267 } else {
268268 $sv = null;
269269 }
@@ -863,7 +863,7 @@
864864 global $wgRequest;
865865 # Edit must be non-null, and to a reviewable page
866866 $fa = FlaggedArticle::getArticleInstance( $article );
867 - if ( !$rev || !$fa->isReviewable() ) {
 867+ if ( !$rev || !$fa->isReviewable( FR_MASTER ) ) {
868868 return true;
869869 }
870870 if ( !$user ) {
@@ -1036,7 +1036,7 @@
10371037 }
10381038 $fa = FlaggedArticle::getTitleInstance( $rc->getTitle() );
10391039 // Is the page reviewable?
1040 - if ( $fa->isReviewable() ) {
 1040+ if ( $fa->isReviewable( FR_MASTER ) ) {
10411041 $revId = $rc->mAttribs['rc_this_oldid'];
10421042 $quality = FlaggedRevs::getRevQuality( $rc->mAttribs['rc_cur_id'], $revId, FR_MASTER );
10431043 if ( $quality !== false && $quality >= FlaggedRevs::getPatrolLevel() ) {
@@ -1996,7 +1996,7 @@
19971997 return false; // final
19981998 }
19991999
2000 - // Add radio of review "protection" options
 2000+ // Add selector of review "protection" options
20012001 // Code stolen from Stabilization (which was stolen from ProtectionForm)
20022002 public static function onProtectionForm( $article, &$output ) {
20032003 global $wgUser, $wgRequest, $wgOut, $wgLang;
Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php
@@ -33,11 +33,12 @@
3434
3535 /**
3636 * Is the stable version shown by default for this page?
 37+ * @param int $flags, FR_MASTER
3738 * @returns bool
3839 */
39 - public function isStableShownByDefault() {
 40+ public function isStableShownByDefault( $flags = 0 ) {
4041 # Get page configuration
41 - $config = $this->getVisibilitySettings();
 42+ $config = $this->getVisibilitySettings( $flags );
4243 return (bool)$config['override'];
4344 }
4445
@@ -68,24 +69,27 @@
6970
7071 /**
7172 * Is this article reviewable?
 73+ * @param int $flags, FR_MASTER
7274 * @returns bool
7375 */
74 - public function isReviewable() {
 76+ public function isReviewable( $flags = 0 ) {
7577 if ( !FlaggedRevs::inReviewNamespace( $this->getTitle() ) ) {
7678 return false;
7779 }
78 - return !( FlaggedRevs::forDefaultVersionOnly() && !$this->isStableShownByDefault() );
 80+ return !( FlaggedRevs::forDefaultVersionOnly()
 81+ && !$this->isStableShownByDefault( $flags ) );
7982 }
8083
8184 /**
8285 * Is this page in patrolable?
 86+ * @param int $flags, FR_MASTER
8387 * @return bool
8488 */
85 - public function isPatrollable() {
 89+ public function isPatrollable( $flags = 0 ) {
8690 if ( !FlaggedRevs::inPatrolNamespace( $this->getTitle() ) ) {
8791 return false;
8892 }
89 - return !$this->isReviewable(); // pages that are reviewable are not patrollable
 93+ return !$this->isReviewable( $flags ); // pages that are reviewable are not patrollable
9094 }
9195
9296 /**
@@ -115,38 +119,18 @@
116120
117121 /**
118122 * Get visiblity restrictions on page
119 - * @param Bool $forUpdate, use DB master?
 123+ * @param int $flags, FR_MASTER
120124 * @returns Array (select,override)
121 - */
122 - public function getVisibilitySettings( $forUpdate = false ) {
 125+ */
 126+ public function getVisibilitySettings( $flags = 0 ) {
123127 # Cached results available?
124128 if ( !is_null( $this->pageConfig ) ) {
125129 return $this->pageConfig;
126130 }
127131 # Get the content page, skip talk
128132 $title = $this->getTitle()->getSubjectPage();
129 - $config = FlaggedRevs::getPageVisibilitySettings( $title, $forUpdate );
 133+ $config = FlaggedRevs::getPageVisibilitySettings( $title, $flags );
130134 $this->pageConfig = $config;
131135 return $config;
132136 }
133 -
134 - /**
135 - * @param int $revId
136 - * @returns Array, output of the flags for a given revision
137 - */
138 - public function getFlagsForRevision( $revId ) {
139 - # Cached results?
140 - if ( isset( $this->flags[$revId] ) ) {
141 - return $this->flags[$revId];
142 - }
143 - # Get the flags
144 - $flags = FlaggedRevs::getRevisionTags( $this->getTitle(), $revId );
145 - # Don't let cache get too big
146 - if ( count( $this->flags ) >= self::CACHE_MAX ) {
147 - $this->flags = array();
148 - }
149 - # Try to cache results
150 - $this->flags[$revId] = $flags;
151 - return $flags;
152 - }
153137 }
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php
@@ -1181,11 +1181,12 @@
11821182 /**
11831183 * Get visibility restrictions on page
11841184 * @param Title $title, page title
1185 - * @param bool $forUpdate, use master DB?
 1185+ * @param int $flags, FR_MASTER
11861186 * @returns Array (select,override)
11871187 */
1188 - public static function getPageVisibilitySettings( $title, $forUpdate = false ) {
1189 - $db = wfGetDB( $forUpdate ? DB_MASTER : DB_SLAVE );
 1188+ public static function getPageVisibilitySettings( $title, $flags = 0 ) {
 1189+ $db = ($flags & FR_MASTER) ?
 1190+ wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE );
11901191 $row = $db->selectRow( 'flaggedpage_config',
11911192 array( 'fpc_select', 'fpc_override', 'fpc_level', 'fpc_expiry' ),
11921193 array( 'fpc_page_id' => $title->getArticleID() ),

Follow-up revisions

RevisionCommit summaryAuthorDate
r62284Follow up r62269: MAX_CACHE now unusedaaron02:01, 11 February 2010

Status & tagging log