diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2011-12-03 13:29:22 +0100 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2011-12-03 13:29:22 +0100 |
commit | ca32f08966f1b51fcb19460f0996bb0c4048e6fe (patch) | |
tree | ec04cc15b867bc21eedca904cea9af0254531a11 /maintenance/storage | |
parent | a22fbfc60f36f5f7ee10d5ae6fe347340c2ee67c (diff) |
Update to MediaWiki 1.18.0
* also update ArchLinux skin to chagnes in MonoBook
* Use only css to hide our menu bar when printing
Diffstat (limited to 'maintenance/storage')
-rw-r--r-- | maintenance/storage/checkStorage.php | 16 | ||||
-rw-r--r-- | maintenance/storage/compressOld.inc | 300 | ||||
-rw-r--r-- | maintenance/storage/compressOld.php | 398 | ||||
-rw-r--r-- | maintenance/storage/fixBug20757.php | 23 | ||||
-rw-r--r-- | maintenance/storage/moveToExternal.php | 17 | ||||
-rw-r--r-- | maintenance/storage/recompressTracked.php | 22 | ||||
-rw-r--r-- | maintenance/storage/resolveStubs.php | 20 | ||||
-rw-r--r-- | maintenance/storage/storageTypeStats.php | 19 | ||||
-rw-r--r-- | maintenance/storage/testCompression.php | 20 | ||||
-rw-r--r-- | maintenance/storage/trackBlobs.php | 26 |
10 files changed, 518 insertions, 343 deletions
diff --git a/maintenance/storage/checkStorage.php b/maintenance/storage/checkStorage.php index c288d682..c372b9c4 100644 --- a/maintenance/storage/checkStorage.php +++ b/maintenance/storage/checkStorage.php @@ -2,6 +2,21 @@ /** * Fsck for MediaWiki * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * http://www.gnu.org/copyleft/gpl.html + * * @file * @ingroup Maintenance ExternalStorage */ @@ -115,6 +130,7 @@ class CheckStorage { // It's safe to just erase the old_flags field if ( $fix ) { $this->error( 'fixed', "Warning: old_flags set to 0", $id ); + $dbw = wfGetDB( DB_MASTER ); $dbw->ping(); $dbw->update( 'text', array( 'old_flags' => '' ), array( 'old_id' => $id ), $fname ); diff --git a/maintenance/storage/compressOld.inc b/maintenance/storage/compressOld.inc deleted file mode 100644 index 93be5f75..00000000 --- a/maintenance/storage/compressOld.inc +++ /dev/null @@ -1,300 +0,0 @@ -<?php -/** - * @file - * @ingroup Maintenance ExternalStorage - */ - -/** @todo document */ -function compressOldPages( $start = 0, $extdb = '' ) { - $fname = 'compressOldPages'; - - $chunksize = 50; - print "Starting from old_id $start...\n"; - $dbw = wfGetDB( DB_MASTER ); - do { - $res = $dbw->select( 'text', array( 'old_id','old_flags','old_text' ), - "old_id>=$start", $fname, array( 'ORDER BY' => 'old_id', 'LIMIT' => $chunksize, 'FOR UPDATE' ) ); - if( $dbw->numRows( $res ) == 0 ) { - break; - } - $last = $start; - foreach ( $res as $row ) { - # print " {$row->old_id} - {$row->old_namespace}:{$row->old_title}\n"; - compressPage( $row, $extdb ); - $last = $row->old_id; - } - $start = $last + 1; # Deletion may leave long empty stretches - print "$start...\n"; - } while( true ); -} - -/** @todo document */ -function compressPage( $row, $extdb ) { - $fname = 'compressPage'; - if ( false !== strpos( $row->old_flags, 'gzip' ) || false !== strpos( $row->old_flags, 'object' ) ) { - #print "Already compressed row {$row->old_id}\n"; - return false; - } - $dbw = wfGetDB( DB_MASTER ); - $flags = $row->old_flags ? "{$row->old_flags},gzip" : "gzip"; - $compress = gzdeflate( $row->old_text ); - - # Store in external storage if required - if ( $extdb !== '' ) { - $storeObj = new ExternalStoreDB; - $compress = $storeObj->store( $extdb, $compress ); - if ( $compress === false ) { - print "Unable to store object\n"; - return false; - } - } - - # Update text row - $dbw->update( 'text', - array( /* SET */ - 'old_flags' => $flags, - 'old_text' => $compress - ), array( /* WHERE */ - 'old_id' => $row->old_id - ), $fname, - array( 'LIMIT' => 1 ) - ); - return true; -} - -define( 'LS_INDIVIDUAL', 0 ); -define( 'LS_CHUNKED', 1 ); - -/** @todo document */ -function compressWithConcat( $startId, $maxChunkSize, $beginDate, - $endDate, $extdb="", $maxPageId = false ) -{ - $fname = 'compressWithConcat'; - $loadStyle = LS_CHUNKED; - - $dbr = wfGetDB( DB_SLAVE ); - $dbw = wfGetDB( DB_MASTER ); - - # Set up external storage - if ( $extdb != '' ) { - $storeObj = new ExternalStoreDB; - } - - # Get all articles by page_id - if ( !$maxPageId ) { - $maxPageId = $dbr->selectField( 'page', 'max(page_id)', '', $fname ); - } - print "Starting from $startId of $maxPageId\n"; - $pageConds = array(); - - /* - if ( $exclude_ns0 ) { - print "Excluding main namespace\n"; - $pageConds[] = 'page_namespace<>0'; - } - if ( $queryExtra ) { - $pageConds[] = $queryExtra; - } - */ - - # For each article, get a list of revisions which fit the criteria - - # No recompression, use a condition on old_flags - # Don't compress object type entities, because that might produce data loss when - # overwriting bulk storage concat rows. Don't compress external references, because - # the script doesn't yet delete rows from external storage. - $conds = array( - 'old_flags NOT ' . $dbr->buildLike( $dbr->anyString(), 'object', $dbr->anyString() ) . ' AND old_flags NOT ' - . $dbr->buildLike( $dbr->anyString(), 'external', $dbr->anyString() ) ); - - if ( $beginDate ) { - if ( !preg_match( '/^\d{14}$/', $beginDate ) ) { - print "Invalid begin date \"$beginDate\"\n"; - return false; - } - $conds[] = "rev_timestamp>'" . $beginDate . "'"; - } - if ( $endDate ) { - if ( !preg_match( '/^\d{14}$/', $endDate ) ) { - print "Invalid end date \"$endDate\"\n"; - return false; - } - $conds[] = "rev_timestamp<'" . $endDate . "'"; - } - if ( $loadStyle == LS_CHUNKED ) { - $tables = array( 'revision', 'text' ); - $fields = array( 'rev_id', 'rev_text_id', 'old_flags', 'old_text' ); - $conds[] = 'rev_text_id=old_id'; - $revLoadOptions = 'FOR UPDATE'; - } else { - $tables = array( 'revision' ); - $fields = array( 'rev_id', 'rev_text_id' ); - $revLoadOptions = array(); - } - - # Don't work with current revisions - # Don't lock the page table for update either -- TS 2006-04-04 - #$tables[] = 'page'; - #$conds[] = 'page_id=rev_page AND rev_id != page_latest'; - - for ( $pageId = $startId; $pageId <= $maxPageId; $pageId++ ) { - wfWaitForSlaves( 5 ); - - # Wake up - $dbr->ping(); - - # Get the page row - $pageRes = $dbr->select( 'page', - array('page_id', 'page_namespace', 'page_title','page_latest'), - $pageConds + array('page_id' => $pageId), $fname ); - if ( $dbr->numRows( $pageRes ) == 0 ) { - continue; - } - $pageRow = $dbr->fetchObject( $pageRes ); - - # Display progress - $titleObj = Title::makeTitle( $pageRow->page_namespace, $pageRow->page_title ); - print "$pageId\t" . $titleObj->getPrefixedDBkey() . " "; - - # Load revisions - $revRes = $dbw->select( $tables, $fields, - array_merge( array( - 'rev_page' => $pageRow->page_id, - # Don't operate on the current revision - # Use < instead of <> in case the current revision has changed - # since the page select, which wasn't locking - 'rev_id < ' . $pageRow->page_latest - ), $conds ), - $fname, - $revLoadOptions - ); - $revs = array(); - foreach ( $revRes as $revRow ) { - $revs[] = $revRow; - } - - if ( count( $revs ) < 2) { - # No revisions matching, no further processing - print "\n"; - continue; - } - - # For each chunk - $i = 0; - while ( $i < count( $revs ) ) { - if ( $i < count( $revs ) - $maxChunkSize ) { - $thisChunkSize = $maxChunkSize; - } else { - $thisChunkSize = count( $revs ) - $i; - } - - $chunk = new ConcatenatedGzipHistoryBlob(); - $stubs = array(); - $dbw->begin(); - $usedChunk = false; - $primaryOldid = $revs[$i]->rev_text_id; - - # Get the text of each revision and add it to the object - for ( $j = 0; $j < $thisChunkSize && $chunk->isHappy(); $j++ ) { - $oldid = $revs[$i + $j]->rev_text_id; - - # Get text - if ( $loadStyle == LS_INDIVIDUAL ) { - $textRow = $dbw->selectRow( 'text', - array( 'old_flags', 'old_text' ), - array( 'old_id' => $oldid ), - $fname, - 'FOR UPDATE' - ); - $text = Revision::getRevisionText( $textRow ); - } else { - $text = Revision::getRevisionText( $revs[$i + $j] ); - } - - if ( $text === false ) { - print "\nError, unable to get text in old_id $oldid\n"; - #$dbw->delete( 'old', array( 'old_id' => $oldid ) ); - } - - if ( $extdb == "" && $j == 0 ) { - $chunk->setText( $text ); - print '.'; - } else { - # Don't make a stub if it's going to be longer than the article - # Stubs are typically about 100 bytes - if ( strlen( $text ) < 120 ) { - $stub = false; - print 'x'; - } else { - $stub = new HistoryBlobStub( $chunk->addItem( $text ) ); - $stub->setLocation( $primaryOldid ); - $stub->setReferrer( $oldid ); - print '.'; - $usedChunk = true; - } - $stubs[$j] = $stub; - } - } - $thisChunkSize = $j; - - # If we couldn't actually use any stubs because the pages were too small, do nothing - if ( $usedChunk ) { - if ( $extdb != "" ) { - # Move blob objects to External Storage - $stored = $storeObj->store( $extdb, serialize( $chunk )); - if ($stored === false) { - print "Unable to store object\n"; - return false; - } - # Store External Storage URLs instead of Stub placeholders - foreach ($stubs as $stub) { - if ($stub===false) - continue; - # $stored should provide base path to a BLOB - $url = $stored."/".$stub->getHash(); - $dbw->update( 'text', - array( /* SET */ - 'old_text' => $url, - 'old_flags' => 'external,utf-8', - ), array ( /* WHERE */ - 'old_id' => $stub->getReferrer(), - ) - ); - } - } else { - # Store the main object locally - $dbw->update( 'text', - array( /* SET */ - 'old_text' => serialize( $chunk ), - 'old_flags' => 'object,utf-8', - ), array( /* WHERE */ - 'old_id' => $primaryOldid - ) - ); - - # Store the stub objects - for ( $j = 1; $j < $thisChunkSize; $j++ ) { - # Skip if not compressing and don't overwrite the first revision - if ( $stubs[$j] !== false && $revs[$i + $j]->rev_text_id != $primaryOldid ) { - $dbw->update( 'text', - array( /* SET */ - 'old_text' => serialize($stubs[$j]), - 'old_flags' => 'object,utf-8', - ), array( /* WHERE */ - 'old_id' => $revs[$i + $j]->rev_text_id - ) - ); - } - } - } - } - # Done, next - print "/"; - $dbw->commit(); - $i += $thisChunkSize; - wfWaitForSlaves( 5 ); - } - print "\n"; - } - return true; -} diff --git a/maintenance/storage/compressOld.php b/maintenance/storage/compressOld.php index bc05b340..da82d93b 100644 --- a/maintenance/storage/compressOld.php +++ b/maintenance/storage/compressOld.php @@ -17,57 +17,379 @@ * -c <chunk-size> maximum number of revisions in a concat chunk * -b <begin-date> earliest date to check for uncompressed revisions * -e <end-date> latest revision date to compress - * -s <start-id> the old_id to start from + * -s <startid> the old_id to start from + * -n <endid> the old_id to stop at * --extdb <cluster> store specified revisions in an external cluster (untested) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * http://www.gnu.org/copyleft/gpl.html + * * @file * @ingroup Maintenance ExternalStorage */ -$optionsWithArgs = array( 't', 'c', 's', 'f', 'h', 'extdb', 'endid', 'e' ); -require_once( dirname( __FILE__ ) . '/../commandLine.inc' ); -require_once( "compressOld.inc" ); +require_once( dirname( __FILE__ ) . '/../Maintenance.php' ); -if ( !function_exists( "gzdeflate" ) ) { - print "You must enable zlib support in PHP to compress old revisions!\n"; - print "Please see http://www.php.net/manual/en/ref.zlib.php\n\n"; - wfDie(); -} +class CompressOld extends Maintenance { + /** + * @todo document + */ + const LS_INDIVIDUAL = 0; + const LS_CHUNKED = 1; -$defaults = array( - 't' => 'concat', - 'c' => 20, - 's' => 0, - 'b' => '', - 'e' => '', - 'extdb' => '', - 'endid' => false, -); + public function __construct() { + parent::__construct(); + $this->mDescription = 'Compress the text of a wiki'; + $this->addOption( 'type', 'Set compression type to either: gzip|concat', false, true, 't' ); + $this->addOption( 'chunksize', 'Maximum number of revisions in a concat chunk', false, true, 'c' ); + $this->addOption( 'begin-date', 'Earliest date to check for uncompressed revisions', false, true, 'b' ); + $this->addOption( 'end-date', 'Latest revision date to compress', false, true, 'e' ); + $this->addOption( 'startid', 'The old_id to start from', false, true, 's' ); + $this->addOption( 'extdb', 'Store specified revisions in an external cluster (untested)', false, true ); + $this->addOption( 'endid', 'Stop at this old_id', false, true, 'n' ); + } -$options = $options + $defaults; + public function execute() { + global $wgDBname; + if ( !function_exists( "gzdeflate" ) ) { + $this->error( "You must enable zlib support in PHP to compress old revisions!\n" . + "Please see http://www.php.net/manual/en/ref.zlib.php\n", true ); + } -if ( $options['t'] != 'concat' && $options['t'] != 'gzip' ) { - print "Type \"{$options['t']}\" not supported\n"; -} + $type = $this->getOption( 'type', 'concat' ); + $chunkSize = $this->getOption( 'chunksize', 20 ); + $startId = $this->getOption( 'start-id', 0 ); + $beginDate = $this->getOption( 'begin-date', '' ); + $endDate = $this->getOption( 'end-date', '' ); + $extDB = $this->getOption( 'extdb', '' ); + $endId = $this->getOption( 'endid', false ); -if ( $options['extdb'] != '' ) { - print "Compressing database $wgDBname to external cluster {$options['extdb']}\n" . str_repeat( '-', 76 ) . "\n\n"; -} else { - print "Compressing database $wgDBname\n" . str_repeat( '-', 76 ) . "\n\n"; -} + if ( $type != 'concat' && $type != 'gzip' ) { + $this->error( "Type \"{$type}\" not supported" ); + } -$success = true; -if ( $options['t'] == 'concat' ) { - $success = compressWithConcat( $options['s'], $options['c'], $options['b'], - $options['e'], $options['extdb'], $options['endid'] ); -} else { - compressOldPages( $options['s'], $options['extdb'] ); -} + if ( $extDB != '' ) { + $this->output( "Compressing database {$wgDBname} to external cluster {$extDB}\n" + . str_repeat( '-', 76 ) . "\n\n" ); + } else { + $this->output( "Compressing database {$wgDBname}\n" + . str_repeat( '-', 76 ) . "\n\n" ); + } -if ( $success ) { - print "Done.\n"; -} + $success = true; + if ( $type == 'concat' ) { + $success = $this->compressWithConcat( $startId, $chunkSize, $beginDate, + $endDate, $extDB, $endId ); + } else { + $this->compressOldPages( $startId, $extDB ); + } + + if ( $success ) { + $this->output( "Done.\n" ); + } + } + + /** @todo document */ + private function compressOldPages( $start = 0, $extdb = '' ) { + $chunksize = 50; + $this->output( "Starting from old_id $start...\n" ); + $dbw = wfGetDB( DB_MASTER ); + do { + $res = $dbw->select( 'text', array( 'old_id','old_flags','old_text' ), + "old_id>=$start", __METHOD__, array( 'ORDER BY' => 'old_id', 'LIMIT' => $chunksize, 'FOR UPDATE' ) ); + if( $dbw->numRows( $res ) == 0 ) { + break; + } + $last = $start; + foreach ( $res as $row ) { + # print " {$row->old_id} - {$row->old_namespace}:{$row->old_title}\n"; + $this->compressPage( $row, $extdb ); + $last = $row->old_id; + } + $start = $last + 1; # Deletion may leave long empty stretches + $this->output( "$start...\n" ); + } while( true ); + } + + /** @todo document */ + private function compressPage( $row, $extdb ) { + if ( false !== strpos( $row->old_flags, 'gzip' ) || false !== strpos( $row->old_flags, 'object' ) ) { + #print "Already compressed row {$row->old_id}\n"; + return false; + } + $dbw = wfGetDB( DB_MASTER ); + $flags = $row->old_flags ? "{$row->old_flags},gzip" : "gzip"; + $compress = gzdeflate( $row->old_text ); + + # Store in external storage if required + if ( $extdb !== '' ) { + $storeObj = new ExternalStoreDB; + $compress = $storeObj->store( $extdb, $compress ); + if ( $compress === false ) { + $this->error( "Unable to store object" ); + return false; + } + } + + # Update text row + $dbw->update( 'text', + array( /* SET */ + 'old_flags' => $flags, + 'old_text' => $compress + ), array( /* WHERE */ + 'old_id' => $row->old_id + ), __METHOD__, + array( 'LIMIT' => 1 ) + ); + return true; + } + + /** @todo document */ + private function compressWithConcat( $startId, $maxChunkSize, $beginDate, + $endDate, $extdb = "", $maxPageId = false ) + { + $loadStyle = self::LS_CHUNKED; + + $dbr = wfGetDB( DB_SLAVE ); + $dbw = wfGetDB( DB_MASTER ); + + # Set up external storage + if ( $extdb != '' ) { + $storeObj = new ExternalStoreDB; + } + + # Get all articles by page_id + if ( !$maxPageId ) { + $maxPageId = $dbr->selectField( 'page', 'max(page_id)', '', __METHOD__ ); + } + $this->output( "Starting from $startId of $maxPageId\n" ); + $pageConds = array(); + + /* + if ( $exclude_ns0 ) { + print "Excluding main namespace\n"; + $pageConds[] = 'page_namespace<>0'; + } + if ( $queryExtra ) { + $pageConds[] = $queryExtra; + } + */ -exit( 0 ); + # For each article, get a list of revisions which fit the criteria + # No recompression, use a condition on old_flags + # Don't compress object type entities, because that might produce data loss when + # overwriting bulk storage concat rows. Don't compress external references, because + # the script doesn't yet delete rows from external storage. + $conds = array( + 'old_flags NOT ' . $dbr->buildLike( $dbr->anyString(), 'object', $dbr->anyString() ) . ' AND old_flags NOT ' + . $dbr->buildLike( $dbr->anyString(), 'external', $dbr->anyString() ) ); + + if ( $beginDate ) { + if ( !preg_match( '/^\d{14}$/', $beginDate ) ) { + $this->error( "Invalid begin date \"$beginDate\"\n" ); + return false; + } + $conds[] = "rev_timestamp>'" . $beginDate . "'"; + } + if ( $endDate ) { + if ( !preg_match( '/^\d{14}$/', $endDate ) ) { + $this->error( "Invalid end date \"$endDate\"\n" ); + return false; + } + $conds[] = "rev_timestamp<'" . $endDate . "'"; + } + if ( $loadStyle == self::LS_CHUNKED ) { + $tables = array( 'revision', 'text' ); + $fields = array( 'rev_id', 'rev_text_id', 'old_flags', 'old_text' ); + $conds[] = 'rev_text_id=old_id'; + $revLoadOptions = 'FOR UPDATE'; + } else { + $tables = array( 'revision' ); + $fields = array( 'rev_id', 'rev_text_id' ); + $revLoadOptions = array(); + } + + # Don't work with current revisions + # Don't lock the page table for update either -- TS 2006-04-04 + #$tables[] = 'page'; + #$conds[] = 'page_id=rev_page AND rev_id != page_latest'; + + for ( $pageId = $startId; $pageId <= $maxPageId; $pageId++ ) { + wfWaitForSlaves(); + + # Wake up + $dbr->ping(); + + # Get the page row + $pageRes = $dbr->select( 'page', + array('page_id', 'page_namespace', 'page_title','page_latest'), + $pageConds + array('page_id' => $pageId), __METHOD__ ); + if ( $dbr->numRows( $pageRes ) == 0 ) { + continue; + } + $pageRow = $dbr->fetchObject( $pageRes ); + + # Display progress + $titleObj = Title::makeTitle( $pageRow->page_namespace, $pageRow->page_title ); + $this->output( "$pageId\t" . $titleObj->getPrefixedDBkey() . " " ); + + # Load revisions + $revRes = $dbw->select( $tables, $fields, + array_merge( array( + 'rev_page' => $pageRow->page_id, + # Don't operate on the current revision + # Use < instead of <> in case the current revision has changed + # since the page select, which wasn't locking + 'rev_id < ' . $pageRow->page_latest + ), $conds ), + __METHOD__, + $revLoadOptions + ); + $revs = array(); + foreach ( $revRes as $revRow ) { + $revs[] = $revRow; + } + + if ( count( $revs ) < 2) { + # No revisions matching, no further processing + $this->output( "\n" ); + continue; + } + + # For each chunk + $i = 0; + while ( $i < count( $revs ) ) { + if ( $i < count( $revs ) - $maxChunkSize ) { + $thisChunkSize = $maxChunkSize; + } else { + $thisChunkSize = count( $revs ) - $i; + } + + $chunk = new ConcatenatedGzipHistoryBlob(); + $stubs = array(); + $dbw->begin(); + $usedChunk = false; + $primaryOldid = $revs[$i]->rev_text_id; + + # Get the text of each revision and add it to the object + for ( $j = 0; $j < $thisChunkSize && $chunk->isHappy(); $j++ ) { + $oldid = $revs[$i + $j]->rev_text_id; + + # Get text + if ( $loadStyle == self::LS_INDIVIDUAL ) { + $textRow = $dbw->selectRow( 'text', + array( 'old_flags', 'old_text' ), + array( 'old_id' => $oldid ), + __METHOD__, + 'FOR UPDATE' + ); + $text = Revision::getRevisionText( $textRow ); + } else { + $text = Revision::getRevisionText( $revs[$i + $j] ); + } + + if ( $text === false ) { + $this->error( "\nError, unable to get text in old_id $oldid" ); + #$dbw->delete( 'old', array( 'old_id' => $oldid ) ); + } + + if ( $extdb == "" && $j == 0 ) { + $chunk->setText( $text ); + $this->output( '.' ); + } else { + # Don't make a stub if it's going to be longer than the article + # Stubs are typically about 100 bytes + if ( strlen( $text ) < 120 ) { + $stub = false; + $this->output( 'x' ); + } else { + $stub = new HistoryBlobStub( $chunk->addItem( $text ) ); + $stub->setLocation( $primaryOldid ); + $stub->setReferrer( $oldid ); + $this->output( '.' ); + $usedChunk = true; + } + $stubs[$j] = $stub; + } + } + $thisChunkSize = $j; + + # If we couldn't actually use any stubs because the pages were too small, do nothing + if ( $usedChunk ) { + if ( $extdb != "" ) { + # Move blob objects to External Storage + $stored = $storeObj->store( $extdb, serialize( $chunk )); + if ($stored === false) { + $this->error( "Unable to store object" ); + return false; + } + # Store External Storage URLs instead of Stub placeholders + foreach ($stubs as $stub) { + if ($stub===false) + continue; + # $stored should provide base path to a BLOB + $url = $stored."/".$stub->getHash(); + $dbw->update( 'text', + array( /* SET */ + 'old_text' => $url, + 'old_flags' => 'external,utf-8', + ), array ( /* WHERE */ + 'old_id' => $stub->getReferrer(), + ) + ); + } + } else { + # Store the main object locally + $dbw->update( 'text', + array( /* SET */ + 'old_text' => serialize( $chunk ), + 'old_flags' => 'object,utf-8', + ), array( /* WHERE */ + 'old_id' => $primaryOldid + ) + ); + + # Store the stub objects + for ( $j = 1; $j < $thisChunkSize; $j++ ) { + # Skip if not compressing and don't overwrite the first revision + if ( $stubs[$j] !== false && $revs[$i + $j]->rev_text_id != $primaryOldid ) { + $dbw->update( 'text', + array( /* SET */ + 'old_text' => serialize($stubs[$j]), + 'old_flags' => 'object,utf-8', + ), array( /* WHERE */ + 'old_id' => $revs[$i + $j]->rev_text_id + ) + ); + } + } + } + } + # Done, next + $this->output( "/" ); + $dbw->commit(); + $i += $thisChunkSize; + wfWaitForSlaves(); + } + $this->output( "\n" ); + } + return true; + } + +} +$maintClass = 'CompressOld'; +require_once( RUN_MAINTENANCE_IF_MAIN ); diff --git a/maintenance/storage/fixBug20757.php b/maintenance/storage/fixBug20757.php index 4aac1202..b6def2da 100644 --- a/maintenance/storage/fixBug20757.php +++ b/maintenance/storage/fixBug20757.php @@ -1,4 +1,25 @@ <?php +/** + * Script to fix bug 20757. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * http://www.gnu.org/copyleft/gpl.html + * + * @file + * @ingroup Maintenance ExternalStorage + */ require_once( dirname( __FILE__ ) . '/../Maintenance.php' ); @@ -239,7 +260,7 @@ class FixBug20757 extends Maintenance { static $iteration = 0; ++$iteration; if ( ++$iteration > 50 == 0 ) { - wfWaitForSlaves( 5 ); + wfWaitForSlaves(); $iteration = 0; } } diff --git a/maintenance/storage/moveToExternal.php b/maintenance/storage/moveToExternal.php index 928cbf97..64f3adaa 100644 --- a/maintenance/storage/moveToExternal.php +++ b/maintenance/storage/moveToExternal.php @@ -2,6 +2,21 @@ /** * Move revision's text to external storage * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * http://www.gnu.org/copyleft/gpl.html + * * @file * @ingroup Maintenance ExternalStorage */ @@ -51,7 +66,7 @@ function moveToExternal( $cluster, $maxID, $minID = 1 ) { if ( !( $block % REPORTING_INTERVAL ) ) { print "oldid=$blockStart, moved=$numMoved\n"; - wfWaitForSlaves( 2 ); + wfWaitForSlaves(); } $res = $dbr->select( 'text', array( 'old_id', 'old_flags', 'old_text' ), diff --git a/maintenance/storage/recompressTracked.php b/maintenance/storage/recompressTracked.php index 8974a74d..09ab3e57 100644 --- a/maintenance/storage/recompressTracked.php +++ b/maintenance/storage/recompressTracked.php @@ -1,4 +1,26 @@ <?php +/** + * Moves blobs indexed by trackBlobs.php to a specified list of destination + * clusters, and recompresses them in the process. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * http://www.gnu.org/copyleft/gpl.html + * + * @file + * @ingroup Maintenance ExternalStorage + */ $optionsWithArgs = RecompressTracked::getOptionsWithArgs(); require( dirname( __FILE__ ) . '/../commandLine.inc' ); diff --git a/maintenance/storage/resolveStubs.php b/maintenance/storage/resolveStubs.php index 2269e37f..08d0ee04 100644 --- a/maintenance/storage/resolveStubs.php +++ b/maintenance/storage/resolveStubs.php @@ -1,5 +1,23 @@ <?php /** + * Script to convert history stubs that point to an external row to direct + * external pointers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * http://www.gnu.org/copyleft/gpl.html + * * @file * @ingroup Maintenance ExternalStorage */ @@ -27,7 +45,7 @@ function resolveStubs() { $numBlocks = intval( $maxID / $blockSize ) + 1; for ( $b = 0; $b < $numBlocks; $b++ ) { - wfWaitForSlaves( 2 ); + wfWaitForSlaves(); printf( "%5.2f%%\n", $b / $numBlocks * 100 ); $start = intval( $maxID / $numBlocks ) * $b + 1; diff --git a/maintenance/storage/storageTypeStats.php b/maintenance/storage/storageTypeStats.php index be86c531..817659fc 100644 --- a/maintenance/storage/storageTypeStats.php +++ b/maintenance/storage/storageTypeStats.php @@ -1,4 +1,23 @@ <?php +/** + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * http://www.gnu.org/copyleft/gpl.html + * + * @file + * @ingroup Maintenance ExternalStorage + */ require_once( dirname( __FILE__ ) . '/../Maintenance.php' ); diff --git a/maintenance/storage/testCompression.php b/maintenance/storage/testCompression.php index e2718325..9ae26335 100644 --- a/maintenance/storage/testCompression.php +++ b/maintenance/storage/testCompression.php @@ -1,4 +1,24 @@ <?php +/** + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * http://www.gnu.org/copyleft/gpl.html + * + * @file + * @ingroup Maintenance + * @see wfWaitForSlaves() + */ $optionsWithArgs = array( 'start', 'limit', 'type' ); require( dirname( __FILE__ ) . '/../commandLine.inc' ); diff --git a/maintenance/storage/trackBlobs.php b/maintenance/storage/trackBlobs.php index 15aeec3b..b5f80047 100644 --- a/maintenance/storage/trackBlobs.php +++ b/maintenance/storage/trackBlobs.php @@ -1,4 +1,26 @@ <?php +/** + * Adds blobs from a given external storage cluster to the blob_tracking table. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * http://www.gnu.org/copyleft/gpl.html + * + * @file + * @ingroup Maintenance + * @see wfWaitForSlaves() + */ require( dirname( __FILE__ ) . '/../commandLine.inc' ); @@ -184,7 +206,7 @@ class TrackBlobs { if ( $batchesDone >= $this->reportingInterval ) { $batchesDone = 0; echo "$startId / $endId\n"; - wfWaitForSlaves( 5 ); + wfWaitForSlaves(); } } echo "Found $rowsInserted revisions\n"; @@ -268,7 +290,7 @@ class TrackBlobs { if ( $batchesDone >= $this->reportingInterval ) { $batchesDone = 0; echo "$startId / $endId\n"; - wfWaitForSlaves( 5 ); + wfWaitForSlaves(); } } echo "Found $rowsInserted orphan text rows\n"; |