r67292 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r67291‎ | r67292 | r67293 >
Date:18:49, 3 June 2010
Author:aaron
Status:ok
Tags:
Comment:
Added script to clear squid/file cache (useful for removal/uninstallation)
Modified paths:
  • /trunk/extensions/FlaggedRevs/maintenance/purgeReviewablePages.inc (added) (history)
  • /trunk/extensions/FlaggedRevs/maintenance/purgeReviewablePages.php (added) (history)

Diff [purge]

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
147 + 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
129 + native

Follow-up revisions

RevisionCommit summaryAuthorDate
r67301* Split purgeReviewablePages.php into two phases. Nice for uninstallation and...aaron22:08, 3 June 2010

Status & tagging log