r60951 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r60950‎ | r60951 | r60952 >
Date:23:19, 11 January 2010
Author:aaron
Status:ok
Tags:
Comment:
* Fixed tracking problems with page config expiration
* Make sure getPrecedence() returns an integer
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedRevision.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.class.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php
@@ -429,7 +429,7 @@
430430 public static function getPrecedence( $config = null ) {
431431 global $wgFlaggedRevsPrecedence;
432432 if( is_null($config) ) {
433 - $config = $wgFlaggedRevsPrecedence;
 433+ $config = (int)$wgFlaggedRevsPrecedence;
434434 }
435435 switch( $config )
436436 {
@@ -928,7 +928,7 @@
929929 * @param Article $article
930930 * @param Revision $rev, the new stable version
931931 * @param mixed $latest, the latest rev ID (optional)
932 - * Updates the flaggedpages fields. Called on edit.
 932+ * Updates the tracking tables and pending edit count cache. Called on edit.
933933 */
934934 public static function updateStableVersion( $article, $rev, $latest = null ) {
935935 if( !$article->getId() )
@@ -1231,14 +1231,43 @@
12321232 }
12331233
12341234 /**
1235 - * Purge expired restrictions from the flaggedpage_config table
 1235+ * Purge expired restrictions from the flaggedpage_config table.
 1236+ * The stable version of pages may change and invalidation may be required.
12361237 */
12371238 public static function purgeExpiredConfigurations() {
12381239 $dbw = wfGetDB( DB_MASTER );
1239 - $dbw->delete( 'flaggedpage_config',
 1240+ $ret = $dbw->select( 'flaggedpage_config',
 1241+ array( 'fpc_page_id', 'fpc_select' ),
12401242 array( 'fpc_expiry < ' . $dbw->addQuotes( $dbw->timestamp() ) ),
12411243 __METHOD__
12421244 );
 1245+ $pageIds = array();
 1246+ $config = self::getDefaultVisibilitySettings(); // config is to be reset
 1247+ while( $row = $dbw->fetchObject( $ret ) ) {
 1248+ // If FlaggedRevs got "turned off" for this page (due to not
 1249+ // having the stable version as the default), then clear it
 1250+ // from the tracking tables...
 1251+ if( !$config['override'] && FlaggedRevs::forDefaultVersionOnly() ) {
 1252+ self::clearTrackingRows( $row->fpc_page_id );
 1253+ // Check if the new (default) config has a different way
 1254+ // of selecting the stable version of this page...
 1255+ } else if( $config['select'] !== intval($row->fpc_select) ) {
 1256+ $title = Title::newFromId( $row->fpc_page_id, GAID_FOR_UPDATE );
 1257+ // Determine the new stable version and update the tracking tables...
 1258+ $srev = FlaggedRevision::newFromStable( $title, FR_MASTER, $config );
 1259+ if( $srev ) {
 1260+ $article = new Article( $title );
 1261+ self::updateStableVersion( $article, $srev, $title->getArticleID() );
 1262+ } else {
 1263+ self::clearTrackingRows( $row->fpc_page_id ); // no stable version
 1264+ }
 1265+ }
 1266+ $pageIds[] = $row->fpc_page_id;
 1267+ }
 1268+ // Clear the expired config for this pages
 1269+ if( count($pageIds) ) {
 1270+ $dbw->delete( 'flaggedpage_config', array( 'fpc_page_id' => $pageIds ), __METHOD__ );
 1271+ }
12431272 }
12441273
12451274 ################# Other utility functions #################
Index: trunk/extensions/FlaggedRevs/FlaggedRevision.php
@@ -119,9 +119,10 @@
120120 * Get latest quality rev, if not, the latest reviewed one.
121121 * @param Title $title, page title
122122 * @param int $flags
 123+ * @param array $config, optional page config (use to skip queries)
123124 * @returns mixed FlaggedRevision (null on failure)
124125 */
125 - public static function newFromStable( Title $title, $flags = 0 ) {
 126+ public static function newFromStable( Title $title, $flags = 0, $config = array() ) {
126127 $columns = self::selectFields();
127128 # If we want the text, then get the text flags too
128129 if( $flags & FR_TEXT ) {
@@ -150,7 +151,9 @@
151152 } else {
152153 $row = null;
153154 # Get visiblity settings...
154 - $config = FlaggedRevs::getPageVisibilitySettings( $title, true );
 155+ if( empty($config) ) {
 156+ $config = FlaggedRevs::getPageVisibilitySettings( $title, true );
 157+ }
155158 if( !$config['override'] && FlaggedRevs::forDefaultVersionOnly() ) {
156159 return $row; // page is not reviewable; no stable version
157160 }

Status & tagging log