Index: trunk/extensions/FlaggedRevs/maintenance/purgeReviewablePages.inc |
— | — | @@ -0,0 +1,45 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +function purge_reviewable_pages( $db ) { |
| 5 | + global $wgFlaggedRevsNamespaces, $wgUseSquid, $wgUseFileCache; |
| 6 | + echo "Purging squid cache for all reviewable pages...\n"; |
| 7 | + if ( !$wgUseSquid || !$wgUseFileCache ) { |
| 8 | + echo "Squid/file cache not enabled...nothing to purge.\n"; |
| 9 | + } |
| 10 | + $BATCH_SIZE = 500; |
| 11 | + $start = $db->selectField( 'page', 'MIN(page_id)', false, __FUNCTION__ ); |
| 12 | + $end = $db->selectField( 'page', 'MAX(page_id)', false, __FUNCTION__ ); |
| 13 | + if ( is_null( $start ) || is_null( $end ) ){ |
| 14 | + echo "...page table seems to be empty.\n"; |
| 15 | + return; |
| 16 | + } |
| 17 | + # Do remaining chunk |
| 18 | + $end += $BATCH_SIZE - 1; |
| 19 | + $blockStart = $start; |
| 20 | + $blockEnd = $start + $BATCH_SIZE - 1; |
| 21 | + $count = 0; |
| 22 | + while ( $blockEnd <= $end ) { |
| 23 | + echo "...doing page_id from $blockStart to $blockEnd\n"; |
| 24 | + $res = $db->select( 'page', '*', |
| 25 | + array( |
| 26 | + "page_id BETWEEN $blockStart AND $blockEnd", |
| 27 | + 'page_namespace' => $wgFlaggedRevsNamespaces ), |
| 28 | + __FUNCTION__ |
| 29 | + ); |
| 30 | + # Go through and protect each page... |
| 31 | + foreach ( $res as $row ) { |
| 32 | + $title = Title::newFromRow( $row ); |
| 33 | + $fa = FlaggedArticle::getTitleInstance( $title ); |
| 34 | + if ( $fa->isReviewable( FR_MASTER ) ) { |
| 35 | + $title->purgeSquid(); // send PURGE |
| 36 | + HTMLFileCache::clearFileCache( $title ); // purge poor-mans's squid |
| 37 | + $count++; |
| 38 | + } |
| 39 | + } |
| 40 | + $db->freeResult( $res ); |
| 41 | + $blockStart += $BATCH_SIZE - 1; |
| 42 | + $blockEnd += $BATCH_SIZE - 1; |
| 43 | + wfWaitForSlaves( 5 ); |
| 44 | + } |
| 45 | + echo "Squid/file cache purge of all reviewable pages complete ... {$count} pages\n"; |
| 46 | +} |
Property changes on: trunk/extensions/FlaggedRevs/maintenance/purgeReviewablePages.inc |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 47 | + native |
Index: trunk/extensions/FlaggedRevs/maintenance/purgeReviewablePages.php |
— | — | @@ -0,0 +1,27 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +if ( getenv( 'MW_INSTALL_PATH' ) ) { |
| 5 | + $IP = getenv( 'MW_INSTALL_PATH' ); |
| 6 | +} else { |
| 7 | + $IP = dirname(__FILE__).'/../../..'; |
| 8 | +} |
| 9 | +require "$IP/maintenance/commandLine.inc"; |
| 10 | +require dirname(__FILE__) . '/purgeReviewablePages.inc'; |
| 11 | + |
| 12 | +if( isset( $options['help'] ) ) { |
| 13 | + echo <<<TEXT |
| 14 | +Purpose: |
| 15 | + Purge squid/file cache for all reviewable pages |
| 16 | +Usage: |
| 17 | + php purgeReviewablePages.php --help |
| 18 | + |
| 19 | + --help : This help message |
| 20 | + |
| 21 | +TEXT; |
| 22 | + exit(0); |
| 23 | +} |
| 24 | + |
| 25 | +error_reporting( E_ALL ); |
| 26 | + |
| 27 | +$db = wfGetDB( DB_MASTER ); |
| 28 | +purge_reviewable_pages( $db ); |
Property changes on: trunk/extensions/FlaggedRevs/maintenance/purgeReviewablePages.php |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 29 | + native |