Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php |
— | — | @@ -429,7 +429,7 @@ |
430 | 430 | public static function getPrecedence( $config = null ) { |
431 | 431 | global $wgFlaggedRevsPrecedence; |
432 | 432 | if( is_null($config) ) { |
433 | | - $config = $wgFlaggedRevsPrecedence; |
| 433 | + $config = (int)$wgFlaggedRevsPrecedence; |
434 | 434 | } |
435 | 435 | switch( $config ) |
436 | 436 | { |
— | — | @@ -928,7 +928,7 @@ |
929 | 929 | * @param Article $article |
930 | 930 | * @param Revision $rev, the new stable version |
931 | 931 | * @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. |
933 | 933 | */ |
934 | 934 | public static function updateStableVersion( $article, $rev, $latest = null ) { |
935 | 935 | if( !$article->getId() ) |
— | — | @@ -1231,14 +1231,43 @@ |
1232 | 1232 | } |
1233 | 1233 | |
1234 | 1234 | /** |
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. |
1236 | 1237 | */ |
1237 | 1238 | public static function purgeExpiredConfigurations() { |
1238 | 1239 | $dbw = wfGetDB( DB_MASTER ); |
1239 | | - $dbw->delete( 'flaggedpage_config', |
| 1240 | + $ret = $dbw->select( 'flaggedpage_config', |
| 1241 | + array( 'fpc_page_id', 'fpc_select' ), |
1240 | 1242 | array( 'fpc_expiry < ' . $dbw->addQuotes( $dbw->timestamp() ) ), |
1241 | 1243 | __METHOD__ |
1242 | 1244 | ); |
| 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 | + } |
1243 | 1272 | } |
1244 | 1273 | |
1245 | 1274 | ################# Other utility functions ################# |
Index: trunk/extensions/FlaggedRevs/FlaggedRevision.php |
— | — | @@ -119,9 +119,10 @@ |
120 | 120 | * Get latest quality rev, if not, the latest reviewed one. |
121 | 121 | * @param Title $title, page title |
122 | 122 | * @param int $flags |
| 123 | + * @param array $config, optional page config (use to skip queries) |
123 | 124 | * @returns mixed FlaggedRevision (null on failure) |
124 | 125 | */ |
125 | | - public static function newFromStable( Title $title, $flags = 0 ) { |
| 126 | + public static function newFromStable( Title $title, $flags = 0, $config = array() ) { |
126 | 127 | $columns = self::selectFields(); |
127 | 128 | # If we want the text, then get the text flags too |
128 | 129 | if( $flags & FR_TEXT ) { |
— | — | @@ -150,7 +151,9 @@ |
151 | 152 | } else { |
152 | 153 | $row = null; |
153 | 154 | # Get visiblity settings... |
154 | | - $config = FlaggedRevs::getPageVisibilitySettings( $title, true ); |
| 155 | + if( empty($config) ) { |
| 156 | + $config = FlaggedRevs::getPageVisibilitySettings( $title, true ); |
| 157 | + } |
155 | 158 | if( !$config['override'] && FlaggedRevs::forDefaultVersionOnly() ) { |
156 | 159 | return $row; // page is not reviewable; no stable version |
157 | 160 | } |