Set method visibility on maintenance scripts
Change-Id: I44c82fbe65e1d002803ce065df6563f06dd39cd4
This commit is contained in:
parent
52d9ddc4f2
commit
b4fe9c4bcc
26 changed files with 168 additions and 169 deletions
|
|
@ -22,7 +22,6 @@
|
|||
<!-- TODO Still to be done -->
|
||||
<rule ref="Squiz.Scope.MethodScope.Missing">
|
||||
<exclude-pattern>includes/</exclude-pattern>
|
||||
<exclude-pattern>maintenance/</exclude-pattern>
|
||||
<exclude-pattern>languages/</exclude-pattern>
|
||||
</rule>
|
||||
<!-- TODO Still to be done -->
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ EOT;
|
|||
* @param string $srcTable
|
||||
* @param string $dstTable
|
||||
*/
|
||||
function sync( $srcTable, $dstTable ) {
|
||||
private function sync( $srcTable, $dstTable ) {
|
||||
$batchSize = 1000;
|
||||
$minTs = $this->dbw->selectField( $srcTable, 'MIN(log_timestamp)', '', __METHOD__ );
|
||||
$minTsUnix = wfTimestamp( TS_UNIX, $minTs );
|
||||
|
|
@ -180,7 +180,7 @@ EOT;
|
|||
echo "Copied $numRowsCopied rows\n";
|
||||
}
|
||||
|
||||
function copyExactMatch( $srcTable, $dstTable, $copyPos ) {
|
||||
private function copyExactMatch( $srcTable, $dstTable, $copyPos ) {
|
||||
$numRowsCopied = 0;
|
||||
$srcRes = $this->dbw->select( $srcTable, '*', [ 'log_timestamp' => $copyPos ], __METHOD__ );
|
||||
$dstRes = $this->dbw->select( $dstTable, '*', [ 'log_timestamp' => $copyPos ], __METHOD__ );
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ class BenchmarkParse extends Maintenance {
|
|||
* @param string $timestamp
|
||||
* @return bool|string Revision ID, or false if not found or error
|
||||
*/
|
||||
function getRevIdForTime( Title $title, $timestamp ) {
|
||||
private function getRevIdForTime( Title $title, $timestamp ) {
|
||||
$dbr = $this->getDB( DB_REPLICA );
|
||||
|
||||
$id = $dbr->selectField(
|
||||
|
|
@ -156,7 +156,7 @@ class BenchmarkParse extends Maintenance {
|
|||
*
|
||||
* @param Revision $revision
|
||||
*/
|
||||
function runParser( Revision $revision ) {
|
||||
private function runParser( Revision $revision ) {
|
||||
$content = $revision->getContent();
|
||||
$content->getParserOutput( $revision->getTitle(), $revision->getId() );
|
||||
if ( $this->clearLinkCache ) {
|
||||
|
|
@ -174,7 +174,7 @@ class BenchmarkParse extends Maintenance {
|
|||
* @param string|bool &$id
|
||||
* @return bool
|
||||
*/
|
||||
function onFetchTemplate( Parser $parser, Title $title, &$skip, &$id ) {
|
||||
private function onFetchTemplate( Parser $parser, Title $title, &$skip, &$id ) {
|
||||
$pdbk = $title->getPrefixedDBkey();
|
||||
if ( !isset( $this->idCache[$pdbk] ) ) {
|
||||
$proposedId = $this->getRevIdForTime( $title, $this->templateTimestamp );
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ class CompareParsers extends DumpIterator {
|
|||
}
|
||||
}
|
||||
|
||||
function stripParameters( $text ) {
|
||||
private function stripParameters( $text ) {
|
||||
if ( !$this->stripParametersEnabled ) {
|
||||
return $text;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ class ConvertUserOptions extends Maintenance {
|
|||
* @param IDatabase $dbw
|
||||
* @return null|int
|
||||
*/
|
||||
function convertOptionBatch( $res, $dbw ) {
|
||||
private function convertOptionBatch( $res, $dbw ) {
|
||||
$id = null;
|
||||
foreach ( $res as $row ) {
|
||||
$this->mConversionCount++;
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ class DeleteOldRevisions extends Maintenance {
|
|||
$this->doDelete( $this->hasOption( 'delete' ), $this->mArgs );
|
||||
}
|
||||
|
||||
function doDelete( $delete = false, $args = [] ) {
|
||||
private function doDelete( $delete = false, $args = [] ) {
|
||||
# Data should come off the master, wrapped in a transaction
|
||||
$dbw = $this->getDB( DB_MASTER );
|
||||
$this->beginTransaction( $dbw, __METHOD__ );
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ TEXT
|
|||
}
|
||||
}
|
||||
|
||||
function processOptions() {
|
||||
protected function processOptions() {
|
||||
parent::processOptions();
|
||||
|
||||
// Evaluate options specific to this class
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ abstract class DumpIterator extends Maintenance {
|
|||
}
|
||||
}
|
||||
|
||||
static function disableInterwikis( $prefix, &$data ) {
|
||||
public static function disableInterwikis( $prefix, &$data ) {
|
||||
# Title::newFromText will check on each namespaced article if it's an interwiki.
|
||||
# We always answer that it is not.
|
||||
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ By default, outputs relative paths against the parent directory of $wgUploadDire
|
|||
*
|
||||
* @param bool $shared True to pass shared-dir settings to hash func
|
||||
*/
|
||||
function fetchUsed( $shared ) {
|
||||
private function fetchUsed( $shared ) {
|
||||
$dbr = $this->getDB( DB_REPLICA );
|
||||
$image = $dbr->tableName( 'image' );
|
||||
$imagelinks = $dbr->tableName( 'imagelinks' );
|
||||
|
|
@ -100,7 +100,7 @@ By default, outputs relative paths against the parent directory of $wgUploadDire
|
|||
*
|
||||
* @param bool $shared True to pass shared-dir settings to hash func
|
||||
*/
|
||||
function fetchLocal( $shared ) {
|
||||
private function fetchLocal( $shared ) {
|
||||
$dbr = $this->getDB( DB_REPLICA );
|
||||
$result = $dbr->select( 'image',
|
||||
[ 'img_name' ],
|
||||
|
|
@ -112,7 +112,7 @@ By default, outputs relative paths against the parent directory of $wgUploadDire
|
|||
}
|
||||
}
|
||||
|
||||
function outputItem( $name, $shared ) {
|
||||
private function outputItem( $name, $shared ) {
|
||||
$file = MediaWikiServices::getInstance()->getRepoGroup()->findFile( $name );
|
||||
if ( $file && $this->filterItem( $file, $shared ) ) {
|
||||
$filename = $file->getLocalRefPath();
|
||||
|
|
@ -123,7 +123,7 @@ By default, outputs relative paths against the parent directory of $wgUploadDire
|
|||
}
|
||||
}
|
||||
|
||||
function filterItem( $file, $shared ) {
|
||||
private function filterItem( $file, $shared ) {
|
||||
return $shared || $file->isLocal();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -250,7 +250,7 @@ class GenerateSitemap extends Maintenance {
|
|||
/**
|
||||
* Generate a one-dimensional array of existing namespaces
|
||||
*/
|
||||
function generateNamespaces() {
|
||||
private function generateNamespaces() {
|
||||
// Only generate for specific namespaces if $wgSitemapNamespaces is an array.
|
||||
global $wgSitemapNamespaces;
|
||||
if ( is_array( $wgSitemapNamespaces ) ) {
|
||||
|
|
@ -280,7 +280,7 @@ class GenerateSitemap extends Maintenance {
|
|||
* @param int $namespace The namespace to get the priority for
|
||||
* @return string
|
||||
*/
|
||||
function priority( $namespace ) {
|
||||
private function priority( $namespace ) {
|
||||
return $this->priorities[$namespace] ?? $this->guessPriority( $namespace );
|
||||
}
|
||||
|
||||
|
|
@ -292,7 +292,7 @@ class GenerateSitemap extends Maintenance {
|
|||
* @param int $namespace The namespace to get the priority for
|
||||
* @return string
|
||||
*/
|
||||
function guessPriority( $namespace ) {
|
||||
private function guessPriority( $namespace ) {
|
||||
return MediaWikiServices::getInstance()->getNamespaceInfo()->isSubject( $namespace )
|
||||
? $this->priorities[self::GS_MAIN]
|
||||
: $this->priorities[self::GS_TALK];
|
||||
|
|
@ -304,7 +304,7 @@ class GenerateSitemap extends Maintenance {
|
|||
* @param int $namespace Limit the query to this namespace
|
||||
* @return IResultWrapper
|
||||
*/
|
||||
function getPageRes( $namespace ) {
|
||||
private function getPageRes( $namespace ) {
|
||||
return $this->dbr->select( 'page',
|
||||
[
|
||||
'page_namespace',
|
||||
|
|
@ -400,7 +400,7 @@ class GenerateSitemap extends Maintenance {
|
|||
* @param string $flags
|
||||
* @return resource
|
||||
*/
|
||||
function open( $file, $flags ) {
|
||||
private function open( $file, $flags ) {
|
||||
$resource = $this->compress ? gzopen( $file, $flags ) : fopen( $file, $flags );
|
||||
if ( $resource === false ) {
|
||||
throw new MWException( __METHOD__
|
||||
|
|
@ -416,7 +416,7 @@ class GenerateSitemap extends Maintenance {
|
|||
* @param resource &$handle
|
||||
* @param string $str
|
||||
*/
|
||||
function write( &$handle, $str ) {
|
||||
private function write( &$handle, $str ) {
|
||||
if ( $handle === true || $handle === false ) {
|
||||
throw new MWException( __METHOD__ . " was passed a boolean as a file handle.\n" );
|
||||
}
|
||||
|
|
@ -432,7 +432,7 @@ class GenerateSitemap extends Maintenance {
|
|||
*
|
||||
* @param resource &$handle
|
||||
*/
|
||||
function close( &$handle ) {
|
||||
private function close( &$handle ) {
|
||||
if ( $this->compress ) {
|
||||
gzclose( $handle );
|
||||
} else {
|
||||
|
|
@ -447,7 +447,7 @@ class GenerateSitemap extends Maintenance {
|
|||
* @param int $count
|
||||
* @return string
|
||||
*/
|
||||
function sitemapFilename( $namespace, $count ) {
|
||||
private function sitemapFilename( $namespace, $count ) {
|
||||
$ext = $this->compress ? '.gz' : '';
|
||||
|
||||
return "sitemap-{$this->identifier}-NS_$namespace-$count.xml$ext";
|
||||
|
|
@ -458,7 +458,7 @@ class GenerateSitemap extends Maintenance {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
function xmlHead() {
|
||||
private function xmlHead() {
|
||||
return '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
|
||||
}
|
||||
|
||||
|
|
@ -467,7 +467,7 @@ class GenerateSitemap extends Maintenance {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
function xmlSchema() {
|
||||
private function xmlSchema() {
|
||||
return 'http://www.sitemaps.org/schemas/sitemap/0.9';
|
||||
}
|
||||
|
||||
|
|
@ -476,7 +476,7 @@ class GenerateSitemap extends Maintenance {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
function openIndex() {
|
||||
private function openIndex() {
|
||||
return $this->xmlHead() . '<sitemapindex xmlns="' . $this->xmlSchema() . '">' . "\n";
|
||||
}
|
||||
|
||||
|
|
@ -486,7 +486,7 @@ class GenerateSitemap extends Maintenance {
|
|||
* @param string $filename The filename of the sitemap file
|
||||
* @return string
|
||||
*/
|
||||
function indexEntry( $filename ) {
|
||||
private function indexEntry( $filename ) {
|
||||
return "\t<sitemap>\n" .
|
||||
"\t\t<loc>" . wfGetServerUrl( PROTO_CANONICAL ) .
|
||||
( substr( $this->urlpath, 0, 1 ) === "/" ? "" : "/" ) .
|
||||
|
|
@ -500,7 +500,7 @@ class GenerateSitemap extends Maintenance {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
function closeIndex() {
|
||||
private function closeIndex() {
|
||||
return "</sitemapindex>\n";
|
||||
}
|
||||
|
||||
|
|
@ -509,7 +509,7 @@ class GenerateSitemap extends Maintenance {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
function openFile() {
|
||||
private function openFile() {
|
||||
return $this->xmlHead() . '<urlset xmlns="' . $this->xmlSchema() . '">' . "\n";
|
||||
}
|
||||
|
||||
|
|
@ -521,7 +521,7 @@ class GenerateSitemap extends Maintenance {
|
|||
* @param string $priority A priority indicator, 0.0 - 1.0 inclusive with a 0.1 stepsize
|
||||
* @return string
|
||||
*/
|
||||
function fileEntry( $url, $date, $priority ) {
|
||||
private function fileEntry( $url, $date, $priority ) {
|
||||
return "\t<url>\n" .
|
||||
// T36666: $url may contain bad characters such as ampersands.
|
||||
"\t\t<loc>" . htmlspecialchars( $url ) . "</loc>\n" .
|
||||
|
|
@ -535,7 +535,7 @@ class GenerateSitemap extends Maintenance {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
function closeFile() {
|
||||
private function closeFile() {
|
||||
return "</urlset>\n";
|
||||
}
|
||||
|
||||
|
|
@ -544,7 +544,7 @@ class GenerateSitemap extends Maintenance {
|
|||
*
|
||||
* @param int $namespace
|
||||
*/
|
||||
function generateLimit( $namespace ) {
|
||||
private function generateLimit( $namespace ) {
|
||||
// T19961: make a title with the longest possible URL in this namespace
|
||||
$title = Title::makeTitle( $namespace, str_repeat( "\u{28B81}", 63 ) . "\u{5583}" );
|
||||
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ TEXT
|
|||
$this->output( "and initSiteStats.php to update page and revision counts\n" );
|
||||
}
|
||||
|
||||
function setNsfilter( array $namespaces ) {
|
||||
private function setNsfilter( array $namespaces ) {
|
||||
if ( count( $namespaces ) == 0 ) {
|
||||
$this->nsFilter = false;
|
||||
|
||||
|
|
@ -183,14 +183,14 @@ TEXT
|
|||
return is_array( $this->nsFilter ) && !in_array( $ns, $this->nsFilter );
|
||||
}
|
||||
|
||||
function reportPage( $page ) {
|
||||
private function reportPage( $page ) {
|
||||
$this->pageCount++;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Revision $rev
|
||||
*/
|
||||
function handleRevision( $rev ) {
|
||||
private function handleRevision( $rev ) {
|
||||
$title = $rev->getTitle();
|
||||
if ( !$title ) {
|
||||
$this->progress( "Got bogus revision with null title!" );
|
||||
|
|
@ -214,7 +214,7 @@ TEXT
|
|||
* @param Revision $revision
|
||||
* @return bool
|
||||
*/
|
||||
function handleUpload( $revision ) {
|
||||
private function handleUpload( $revision ) {
|
||||
if ( $this->uploads ) {
|
||||
if ( $this->skippedNamespace( $revision ) ) {
|
||||
return false;
|
||||
|
|
@ -236,7 +236,7 @@ TEXT
|
|||
return false;
|
||||
}
|
||||
|
||||
function handleLogItem( $rev ) {
|
||||
private function handleLogItem( $rev ) {
|
||||
if ( $this->skippedNamespace( $rev ) ) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -248,13 +248,13 @@ TEXT
|
|||
}
|
||||
}
|
||||
|
||||
function report( $final = false ) {
|
||||
private function report( $final = false ) {
|
||||
if ( $final xor ( $this->pageCount % $this->reportingInterval == 0 ) ) {
|
||||
$this->showReport();
|
||||
}
|
||||
}
|
||||
|
||||
function showReport() {
|
||||
private function showReport() {
|
||||
if ( !$this->mQuiet ) {
|
||||
$delta = microtime( true ) - $this->startTime;
|
||||
if ( $delta ) {
|
||||
|
|
@ -274,11 +274,11 @@ TEXT
|
|||
wfWaitForSlaves();
|
||||
}
|
||||
|
||||
function progress( $string ) {
|
||||
private function progress( $string ) {
|
||||
fwrite( $this->stderr, $string . "\n" );
|
||||
}
|
||||
|
||||
function importFromFile( $filename ) {
|
||||
private function importFromFile( $filename ) {
|
||||
if ( preg_match( '/\.gz$/', $filename ) ) {
|
||||
$filename = 'compress.zlib://' . $filename;
|
||||
} elseif ( preg_match( '/\.bz2$/', $filename ) ) {
|
||||
|
|
@ -292,7 +292,7 @@ TEXT
|
|||
return $this->importFromHandle( $file );
|
||||
}
|
||||
|
||||
function importFromStdin() {
|
||||
private function importFromStdin() {
|
||||
$file = fopen( 'php://stdin', 'rt' );
|
||||
if ( self::posix_isatty( $file ) ) {
|
||||
$this->maybeHelp( true );
|
||||
|
|
@ -301,7 +301,7 @@ TEXT
|
|||
return $this->importFromHandle( $file );
|
||||
}
|
||||
|
||||
function importFromHandle( $handle ) {
|
||||
private function importFromHandle( $handle ) {
|
||||
$this->startTime = microtime( true );
|
||||
|
||||
$source = new ImportStreamSource( $handle );
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ abstract class BackupDumper extends Maintenance {
|
|||
* @param string $name
|
||||
* @param string $class Name of output filter plugin class
|
||||
*/
|
||||
function registerOutput( $name, $class ) {
|
||||
public function registerOutput( $name, $class ) {
|
||||
$this->outputTypes[$name] = $class;
|
||||
}
|
||||
|
||||
|
|
@ -160,7 +160,7 @@ abstract class BackupDumper extends Maintenance {
|
|||
* @param string $name
|
||||
* @param string $class Name of filter plugin class
|
||||
*/
|
||||
function registerFilter( $name, $class ) {
|
||||
public function registerFilter( $name, $class ) {
|
||||
$this->filterTypes[$name] = $class;
|
||||
}
|
||||
|
||||
|
|
@ -171,7 +171,7 @@ abstract class BackupDumper extends Maintenance {
|
|||
* method that takes a BackupDumper as a parameter.
|
||||
* @param string $file Full or relative path to the PHP file to load, or empty
|
||||
*/
|
||||
function loadPlugin( $class, $file ) {
|
||||
public function loadPlugin( $class, $file ) {
|
||||
if ( $file != '' ) {
|
||||
require_once $file;
|
||||
}
|
||||
|
|
@ -186,7 +186,7 @@ abstract class BackupDumper extends Maintenance {
|
|||
/**
|
||||
* Processes arguments and sets $this->$sink accordingly
|
||||
*/
|
||||
function processOptions() {
|
||||
protected function processOptions() {
|
||||
$sink = null;
|
||||
$sinks = [];
|
||||
|
||||
|
|
@ -284,7 +284,7 @@ abstract class BackupDumper extends Maintenance {
|
|||
}
|
||||
}
|
||||
|
||||
function dump( $history, $text = WikiExporter::TEXT ) {
|
||||
public function dump( $history, $text = WikiExporter::TEXT ) {
|
||||
# Notice messages will foul up your XML output even if they're
|
||||
# relatively harmless.
|
||||
if ( ini_get( 'display_errors' ) ) {
|
||||
|
|
@ -339,7 +339,7 @@ abstract class BackupDumper extends Maintenance {
|
|||
* constant per-revision rate.
|
||||
* @param int $history WikiExporter::CURRENT or WikiExporter::FULL
|
||||
*/
|
||||
function initProgress( $history = WikiExporter::FULL ) {
|
||||
public function initProgress( $history = WikiExporter::FULL ) {
|
||||
$table = ( $history == WikiExporter::CURRENT ) ? 'page' : 'revision';
|
||||
$field = ( $history == WikiExporter::CURRENT ) ? 'page_id' : 'rev_id';
|
||||
|
||||
|
|
@ -359,7 +359,7 @@ abstract class BackupDumper extends Maintenance {
|
|||
* connection by name.
|
||||
* @return IMaintainableDatabase
|
||||
*/
|
||||
function backupDb() {
|
||||
protected function backupDb() {
|
||||
if ( $this->forcedDb !== null ) {
|
||||
return $this->forcedDb;
|
||||
}
|
||||
|
|
@ -386,34 +386,34 @@ abstract class BackupDumper extends Maintenance {
|
|||
$this->forcedDb = $db;
|
||||
}
|
||||
|
||||
function __destruct() {
|
||||
public function __destruct() {
|
||||
if ( isset( $this->lb ) ) {
|
||||
$this->lb->closeAll();
|
||||
}
|
||||
}
|
||||
|
||||
function backupServer() {
|
||||
protected function backupServer() {
|
||||
global $wgDBserver;
|
||||
|
||||
return $this->server ?: $wgDBserver;
|
||||
}
|
||||
|
||||
function reportPage() {
|
||||
public function reportPage() {
|
||||
$this->pageCount++;
|
||||
}
|
||||
|
||||
function revCount() {
|
||||
public function revCount() {
|
||||
$this->revCount++;
|
||||
$this->report();
|
||||
}
|
||||
|
||||
function report( $final = false ) {
|
||||
public function report( $final = false ) {
|
||||
if ( $final xor ( $this->revCount % $this->reportingInterval == 0 ) ) {
|
||||
$this->showReport();
|
||||
}
|
||||
}
|
||||
|
||||
function showReport() {
|
||||
public function showReport() {
|
||||
if ( $this->reporting ) {
|
||||
$now = wfTimestamp( TS_DB );
|
||||
$nowts = microtime( true );
|
||||
|
|
@ -454,7 +454,7 @@ abstract class BackupDumper extends Maintenance {
|
|||
}
|
||||
}
|
||||
|
||||
function progress( $string ) {
|
||||
protected function progress( $string ) {
|
||||
if ( $this->reporting ) {
|
||||
fwrite( $this->stderr, $string . "\n" );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ class SevenZipStream {
|
|||
return substr( $path, strlen( $prefix ) );
|
||||
}
|
||||
|
||||
function stream_open( $path, $mode, $options, &$opened_path ) {
|
||||
public function stream_open( $path, $mode, $options, &$opened_path ) {
|
||||
if ( $mode[0] == 'r' ) {
|
||||
$options = 'e -bd -so';
|
||||
} elseif ( $mode[0] == 'w' ) {
|
||||
|
|
@ -60,37 +60,37 @@ class SevenZipStream {
|
|||
return ( $this->stream !== false );
|
||||
}
|
||||
|
||||
function url_stat( $path, $flags ) {
|
||||
public function url_stat( $path, $flags ) {
|
||||
return stat( $this->stripPath( $path ) );
|
||||
}
|
||||
|
||||
// This is all so lame; there should be a default class we can extend
|
||||
|
||||
function stream_close() {
|
||||
public function stream_close() {
|
||||
return fclose( $this->stream );
|
||||
}
|
||||
|
||||
function stream_flush() {
|
||||
public function stream_flush() {
|
||||
return fflush( $this->stream );
|
||||
}
|
||||
|
||||
function stream_read( $count ) {
|
||||
public function stream_read( $count ) {
|
||||
return fread( $this->stream, $count );
|
||||
}
|
||||
|
||||
function stream_write( $data ) {
|
||||
public function stream_write( $data ) {
|
||||
return fwrite( $this->stream, $data );
|
||||
}
|
||||
|
||||
function stream_tell() {
|
||||
public function stream_tell() {
|
||||
return ftell( $this->stream );
|
||||
}
|
||||
|
||||
function stream_eof() {
|
||||
public function stream_eof() {
|
||||
return feof( $this->stream );
|
||||
}
|
||||
|
||||
function stream_seek( $offset, $whence ) {
|
||||
public function stream_seek( $offset, $whence ) {
|
||||
return fseek( $this->stream, $offset, $whence );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ TEXT
|
|||
$this->dump( true );
|
||||
}
|
||||
|
||||
function processOptions() {
|
||||
protected function processOptions() {
|
||||
parent::processOptions();
|
||||
|
||||
if ( $this->hasOption( 'buffersize' ) ) {
|
||||
|
|
@ -211,7 +211,7 @@ TEXT
|
|||
* @throws MWException
|
||||
* @suppress PhanTypeObjectUnsetDeclaredProperty
|
||||
*/
|
||||
function rotateDb() {
|
||||
protected function rotateDb() {
|
||||
// Cleaning up old connections
|
||||
if ( isset( $this->lb ) ) {
|
||||
$this->lb->closeAll();
|
||||
|
|
@ -250,12 +250,12 @@ TEXT
|
|||
}
|
||||
}
|
||||
|
||||
function initProgress( $history = WikiExporter::FULL ) {
|
||||
public function initProgress( $history = WikiExporter::FULL ) {
|
||||
parent::initProgress();
|
||||
$this->timeOfCheckpoint = $this->startTime;
|
||||
}
|
||||
|
||||
function dump( $history, $text = WikiExporter::TEXT ) {
|
||||
public function dump( $history, $text = WikiExporter::TEXT ) {
|
||||
// Notice messages will foul up your XML output even if they're
|
||||
// relatively harmless.
|
||||
if ( ini_get( 'display_errors' ) ) {
|
||||
|
|
@ -296,7 +296,7 @@ TEXT
|
|||
$this->report( true );
|
||||
}
|
||||
|
||||
function processFileOpt( $opt ) {
|
||||
protected function processFileOpt( $opt ) {
|
||||
$split = explode( ':', $opt, 2 );
|
||||
$val = $split[0];
|
||||
$param = '';
|
||||
|
|
@ -332,7 +332,7 @@ TEXT
|
|||
/**
|
||||
* Overridden to include prefetch ratio if enabled.
|
||||
*/
|
||||
function showReport() {
|
||||
public function showReport() {
|
||||
if ( !$this->prefetch ) {
|
||||
parent::showReport();
|
||||
|
||||
|
|
@ -394,11 +394,11 @@ TEXT
|
|||
}
|
||||
}
|
||||
|
||||
function setTimeExceeded() {
|
||||
private function setTimeExceeded() {
|
||||
$this->timeExceeded = true;
|
||||
}
|
||||
|
||||
function checkIfTimeExceeded() {
|
||||
private function checkIfTimeExceeded() {
|
||||
if ( $this->maxTimeAllowed
|
||||
&& ( $this->lastTime - $this->timeOfCheckpoint > $this->maxTimeAllowed )
|
||||
) {
|
||||
|
|
@ -408,7 +408,7 @@ TEXT
|
|||
return false;
|
||||
}
|
||||
|
||||
function finalOptionCheck() {
|
||||
private function finalOptionCheck() {
|
||||
if ( ( $this->checkpointFiles && !$this->maxTimeAllowed )
|
||||
|| ( $this->maxTimeAllowed && !$this->checkpointFiles )
|
||||
) {
|
||||
|
|
@ -437,7 +437,7 @@ TEXT
|
|||
* @param resource $input
|
||||
* @return bool
|
||||
*/
|
||||
function readDump( $input ) {
|
||||
protected function readDump( $input ) {
|
||||
$this->buffer = "";
|
||||
$this->openElement = false;
|
||||
$this->atStart = true;
|
||||
|
|
@ -557,7 +557,7 @@ TEXT
|
|||
* @throws MWException
|
||||
* @return string The revision text for $id, or ""
|
||||
*/
|
||||
function getText( $id, $model = null, $format = null ) {
|
||||
protected function getText( $id, $model = null, $format = null ) {
|
||||
global $wgContentHandlerUseDB;
|
||||
|
||||
$prefetchNotTried = true; // Whether or not we already tried to get the text via prefetch.
|
||||
|
|
@ -760,7 +760,7 @@ TEXT
|
|||
return $text;
|
||||
}
|
||||
|
||||
function openSpawn() {
|
||||
protected function openSpawn() {
|
||||
global $IP;
|
||||
|
||||
$wiki = WikiMap::getWikiIdFromDbDomain( WikiMap::getCurrentWikiDbDomain() );
|
||||
|
|
@ -901,7 +901,7 @@ TEXT
|
|||
return $normalized;
|
||||
}
|
||||
|
||||
function startElement( $parser, $name, $attribs ) {
|
||||
protected function startElement( $parser, $name, $attribs ) {
|
||||
$this->checkpointJustWritten = false;
|
||||
|
||||
$this->clearOpenElement( null );
|
||||
|
|
@ -938,7 +938,7 @@ TEXT
|
|||
}
|
||||
}
|
||||
|
||||
function endElement( $parser, $name ) {
|
||||
protected function endElement( $parser, $name ) {
|
||||
$this->checkpointJustWritten = false;
|
||||
|
||||
if ( $this->openElement ) {
|
||||
|
|
@ -998,7 +998,7 @@ TEXT
|
|||
}
|
||||
}
|
||||
|
||||
function characterData( $parser, $data ) {
|
||||
protected function characterData( $parser, $data ) {
|
||||
$this->clearOpenElement( null );
|
||||
if ( $this->lastName == "id" ) {
|
||||
if ( $this->state == "revision" ) {
|
||||
|
|
@ -1023,7 +1023,7 @@ TEXT
|
|||
$this->buffer .= htmlspecialchars( $data );
|
||||
}
|
||||
|
||||
function clearOpenElement( $style ) {
|
||||
protected function clearOpenElement( $style ) {
|
||||
if ( $this->openElement ) {
|
||||
$this->buffer .= Xml::element( $this->openElement[0], $this->openElement[1], $style );
|
||||
$this->openElement = false;
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
/** A general output object. Need to be overridden */
|
||||
class StatsOutput {
|
||||
function formatPercent( $subset, $total, $revert = false, $accuracy = 2 ) {
|
||||
public function formatPercent( $subset, $total, $revert = false, $accuracy = 2 ) {
|
||||
Wikimedia\suppressWarnings();
|
||||
$return = sprintf( '%.' . $accuracy . 'f%%', 100 * $subset / $total );
|
||||
Wikimedia\restoreWarnings();
|
||||
|
|
@ -34,25 +34,25 @@ class StatsOutput {
|
|||
}
|
||||
|
||||
# Override the following methods
|
||||
function heading() {
|
||||
public function heading() {
|
||||
}
|
||||
|
||||
function footer() {
|
||||
public function footer() {
|
||||
}
|
||||
|
||||
function blockstart() {
|
||||
public function blockstart() {
|
||||
}
|
||||
|
||||
function blockend() {
|
||||
public function blockend() {
|
||||
}
|
||||
|
||||
function element( $in, $heading = false ) {
|
||||
public function element( $in, $heading = false ) {
|
||||
}
|
||||
}
|
||||
|
||||
/** Outputs WikiText */
|
||||
class WikiStatsOutput extends StatsOutput {
|
||||
function heading() {
|
||||
public function heading() {
|
||||
global $wgDummyLanguageCodes;
|
||||
$version = SpecialVersion::getVersion( 'nodb' );
|
||||
echo "'''Statistics are based on:''' <code>" . $version . "</code>\n\n";
|
||||
|
|
@ -75,23 +75,23 @@ class WikiStatsOutput extends StatsOutput {
|
|||
'border: 1px #AAAAAA solid; border-collapse: collapse; clear:both; width:100%;"' . "\n";
|
||||
}
|
||||
|
||||
function footer() {
|
||||
public function footer() {
|
||||
echo "|}\n";
|
||||
}
|
||||
|
||||
function blockstart() {
|
||||
public function blockstart() {
|
||||
echo "|-\n";
|
||||
}
|
||||
|
||||
function blockend() {
|
||||
public function blockend() {
|
||||
echo '';
|
||||
}
|
||||
|
||||
function element( $in, $heading = false ) {
|
||||
public function element( $in, $heading = false ) {
|
||||
echo ( $heading ? '!' : '|' ) . "$in\n";
|
||||
}
|
||||
|
||||
function formatPercent( $subset, $total, $revert = false, $accuracy = 2 ) {
|
||||
public function formatPercent( $subset, $total, $revert = false, $accuracy = 2 ) {
|
||||
Wikimedia\suppressWarnings();
|
||||
$v = round( 255 * $subset / $total );
|
||||
Wikimedia\restoreWarnings();
|
||||
|
|
@ -125,22 +125,22 @@ class WikiStatsOutput extends StatsOutput {
|
|||
|
||||
/** Output text. To be used on a terminal for example. */
|
||||
class TextStatsOutput extends StatsOutput {
|
||||
function element( $in, $heading = false ) {
|
||||
public function element( $in, $heading = false ) {
|
||||
echo $in . "\t";
|
||||
}
|
||||
|
||||
function blockend() {
|
||||
public function blockend() {
|
||||
echo "\n";
|
||||
}
|
||||
}
|
||||
|
||||
/** csv output. Some people love excel */
|
||||
class CsvStatsOutput extends StatsOutput {
|
||||
function element( $in, $heading = false ) {
|
||||
public function element( $in, $heading = false ) {
|
||||
echo $in . ";";
|
||||
}
|
||||
|
||||
function blockend() {
|
||||
public function blockend() {
|
||||
echo "\n";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -473,7 +473,7 @@ ENDS;
|
|||
/**
|
||||
* Output the checks results as wiki text.
|
||||
*/
|
||||
function outputWiki() {
|
||||
private function outputWiki() {
|
||||
$detailText = '';
|
||||
$rows[] = '! Language !! Code !! Total !! ' .
|
||||
implode( ' !! ', array_diff( $this->checks, $this->nonMessageChecks() ) );
|
||||
|
|
|
|||
|
|
@ -138,12 +138,12 @@ class GenerateCollationData extends Maintenance {
|
|||
$this->generateFirstChars();
|
||||
}
|
||||
|
||||
function loadUcd() {
|
||||
private function loadUcd() {
|
||||
$uxr = new UcdXmlReader( "{$this->dataDir}/ucd.all.grouped.xml" );
|
||||
$uxr->readChars( [ $this, 'charCallback' ] );
|
||||
}
|
||||
|
||||
function charCallback( $data ) {
|
||||
private function charCallback( $data ) {
|
||||
// Skip non-printable characters,
|
||||
// but do not skip a normal space (U+0020) since
|
||||
// people like to use that as a fake no header symbol.
|
||||
|
|
@ -193,7 +193,7 @@ class GenerateCollationData extends Maintenance {
|
|||
}
|
||||
}
|
||||
|
||||
function generateFirstChars() {
|
||||
private function generateFirstChars() {
|
||||
$file = fopen( "{$this->dataDir}/allkeys.txt", 'r' );
|
||||
if ( !$file ) {
|
||||
$this->fatalError( "Unable to open allkeys.txt" );
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ class Languages {
|
|||
* Load the list of languages: all the Messages*.php
|
||||
* files in the languages directory.
|
||||
*/
|
||||
function __construct() {
|
||||
public function __construct() {
|
||||
Hooks::run( 'LocalisationIgnoredOptionalMessages',
|
||||
[ &$this->mIgnoredMessages, &$this->mOptionalMessages ] );
|
||||
|
||||
|
|
@ -795,7 +795,7 @@ class ExtensionLanguages extends Languages {
|
|||
* Load the messages group.
|
||||
* @param MessageGroup $group The messages group.
|
||||
*/
|
||||
function __construct( MessageGroup $group ) {
|
||||
public function __construct( MessageGroup $group ) {
|
||||
$this->mMessageGroup = $group;
|
||||
|
||||
$this->mIgnoredMessages = $this->mMessageGroup->getIgnored();
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ class PPFuzzTester {
|
|||
}
|
||||
}
|
||||
|
||||
function makeInputText( $max = false ) {
|
||||
public function makeInputText( $max = false ) {
|
||||
if ( $max === false ) {
|
||||
$max = $this->maxLength;
|
||||
}
|
||||
|
|
@ -132,17 +132,17 @@ class PPFuzzTester {
|
|||
return $s;
|
||||
}
|
||||
|
||||
function makeTitle() {
|
||||
public function makeTitle() {
|
||||
return Title::newFromText( mt_rand( 0, 1000000 ), mt_rand( 0, 10 ) );
|
||||
}
|
||||
|
||||
/*
|
||||
function pickOutputType() {
|
||||
public function pickOutputType() {
|
||||
$count = count( $this->outputTypes );
|
||||
return $this->outputTypes[ mt_rand( 0, $count - 1 ) ];
|
||||
}*/
|
||||
|
||||
function pickEntryPoint() {
|
||||
public function pickEntryPoint() {
|
||||
$count = count( $this->entryPoints );
|
||||
|
||||
return $this->entryPoints[mt_rand( 0, $count - 1 )];
|
||||
|
|
@ -183,7 +183,7 @@ class PPFuzzTest {
|
|||
* @param Title $title
|
||||
* @return array
|
||||
*/
|
||||
function templateHook( $title ) {
|
||||
public function templateHook( $title ) {
|
||||
$titleText = $title->getPrefixedDBkey();
|
||||
|
||||
if ( !isset( $this->templates[$titleText] ) ) {
|
||||
|
|
@ -234,7 +234,7 @@ class PPFuzzTest {
|
|||
return $this->output;
|
||||
}
|
||||
|
||||
function getReport() {
|
||||
public function getReport() {
|
||||
$s = "Title: " . $this->title->getPrefixedDBkey() . "\n" .
|
||||
// "Output type: {$this->outputType}\n" .
|
||||
"Entry point: {$this->entryPoint}\n" .
|
||||
|
|
@ -258,7 +258,7 @@ class PPFuzzTest {
|
|||
class PPFuzzUser extends User {
|
||||
public $ppfz_test, $mDataLoaded;
|
||||
|
||||
function load( $flags = null ) {
|
||||
public function load( $flags = null ) {
|
||||
if ( $this->mDataLoaded ) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -266,7 +266,7 @@ class PPFuzzUser extends User {
|
|||
$this->loadDefaults( $this->mName );
|
||||
}
|
||||
|
||||
function getOption( $oname, $defaultOverride = null, $ignoreHidden = false ) {
|
||||
public function getOption( $oname, $defaultOverride = null, $ignoreHidden = false ) {
|
||||
if ( $oname === 'fancysig' ) {
|
||||
return $this->ppfz_test->fancySig;
|
||||
} elseif ( $oname === 'nickname' ) {
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ class ImageBuilder extends Maintenance {
|
|||
/**
|
||||
* @return LocalRepo
|
||||
*/
|
||||
function getRepo() {
|
||||
private function getRepo() {
|
||||
if ( $this->repo === null ) {
|
||||
$this->repo = RepoGroup::singleton()->getLocalRepo();
|
||||
}
|
||||
|
|
@ -106,7 +106,7 @@ class ImageBuilder extends Maintenance {
|
|||
return $this->repo;
|
||||
}
|
||||
|
||||
function build() {
|
||||
private function build() {
|
||||
$this->buildImage();
|
||||
$this->buildOldImage();
|
||||
}
|
||||
|
|
@ -115,7 +115,7 @@ class ImageBuilder extends Maintenance {
|
|||
* @param int $count
|
||||
* @param string $table
|
||||
*/
|
||||
function init( $count, $table ) {
|
||||
private function init( $count, $table ) {
|
||||
$this->processed = 0;
|
||||
$this->updated = 0;
|
||||
$this->count = $count;
|
||||
|
|
@ -123,7 +123,7 @@ class ImageBuilder extends Maintenance {
|
|||
$this->table = $table;
|
||||
}
|
||||
|
||||
function progress( $updated ) {
|
||||
private function progress( $updated ) {
|
||||
$this->updated += $updated;
|
||||
$this->processed++;
|
||||
if ( $this->processed % 100 != 0 ) {
|
||||
|
|
@ -150,7 +150,7 @@ class ImageBuilder extends Maintenance {
|
|||
flush();
|
||||
}
|
||||
|
||||
function buildTable( $table, $key, $queryInfo, $callback ) {
|
||||
private function buildTable( $table, $key, $queryInfo, $callback ) {
|
||||
$count = $this->dbw->selectField( $table, 'count(*)', '', __METHOD__ );
|
||||
$this->init( $count, $table );
|
||||
$this->output( "Processing $table...\n" );
|
||||
|
|
@ -170,12 +170,12 @@ class ImageBuilder extends Maintenance {
|
|||
$this->output( "Finished $table... $this->updated of $this->processed rows updated\n" );
|
||||
}
|
||||
|
||||
function buildImage() {
|
||||
private function buildImage() {
|
||||
$callback = [ $this, 'imageCallback' ];
|
||||
$this->buildTable( 'image', 'img_name', LocalFile::getQueryInfo(), $callback );
|
||||
}
|
||||
|
||||
function imageCallback( $row, $copy ) {
|
||||
private function imageCallback( $row, $copy ) {
|
||||
// Create a File object from the row
|
||||
// This will also upgrade it
|
||||
$file = $this->getRepo()->newFileFromRow( $row );
|
||||
|
|
@ -183,12 +183,12 @@ class ImageBuilder extends Maintenance {
|
|||
return $file->getUpgraded();
|
||||
}
|
||||
|
||||
function buildOldImage() {
|
||||
private function buildOldImage() {
|
||||
$this->buildTable( 'oldimage', 'oi_archive_name', OldLocalFile::getQueryInfo(),
|
||||
[ $this, 'oldimageCallback' ] );
|
||||
}
|
||||
|
||||
function oldimageCallback( $row, $copy ) {
|
||||
private function oldimageCallback( $row, $copy ) {
|
||||
// Create a File object from the row
|
||||
// This will also upgrade it
|
||||
if ( $row->oi_archive_name == '' ) {
|
||||
|
|
@ -201,11 +201,11 @@ class ImageBuilder extends Maintenance {
|
|||
return $file->getUpgraded();
|
||||
}
|
||||
|
||||
function crawlMissing() {
|
||||
private function crawlMissing() {
|
||||
$this->getRepo()->enumFiles( [ $this, 'checkMissingImage' ] );
|
||||
}
|
||||
|
||||
function checkMissingImage( $fullpath ) {
|
||||
private function checkMissingImage( $fullpath ) {
|
||||
$filename = wfBaseName( $fullpath );
|
||||
$row = $this->dbw->selectRow( 'image',
|
||||
[ 'img_name' ],
|
||||
|
|
@ -217,7 +217,7 @@ class ImageBuilder extends Maintenance {
|
|||
}
|
||||
}
|
||||
|
||||
function addMissingImage( $filename, $fullpath ) {
|
||||
private function addMissingImage( $filename, $fullpath ) {
|
||||
$timestamp = $this->dbw->timestamp( $this->getRepo()->getFileTimestamp( $fullpath ) );
|
||||
$services = MediaWikiServices::getInstance();
|
||||
|
||||
|
|
|
|||
|
|
@ -213,7 +213,7 @@ class RefreshImageMetadata extends Maintenance {
|
|||
* @param IDatabase $dbw
|
||||
* @return array
|
||||
*/
|
||||
function getConditions( $dbw ) {
|
||||
private function getConditions( $dbw ) {
|
||||
$conds = [];
|
||||
|
||||
$end = $this->getOption( 'end', false );
|
||||
|
|
@ -245,7 +245,7 @@ class RefreshImageMetadata extends Maintenance {
|
|||
* @param bool $force
|
||||
* @param bool $brokenOnly
|
||||
*/
|
||||
function setupParameters( $force, $brokenOnly ) {
|
||||
private function setupParameters( $force, $brokenOnly ) {
|
||||
global $wgUpdateCompatibleMetadata;
|
||||
|
||||
if ( $brokenOnly ) {
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ class CheckStorage {
|
|||
'fixable' => 'Errors which would already be fixed if --fix was specified',
|
||||
];
|
||||
|
||||
function check( $fix = false, $xml = '' ) {
|
||||
public function check( $fix = false, $xml = '' ) {
|
||||
global $wgMultiContentRevisionSchemaMigrationStage;
|
||||
|
||||
$dbr = wfGetDB( DB_REPLICA );
|
||||
|
|
@ -398,7 +398,7 @@ class CheckStorage {
|
|||
}
|
||||
}
|
||||
|
||||
function addError( $type, $msg, $ids ) {
|
||||
private function addError( $type, $msg, $ids ) {
|
||||
if ( is_array( $ids ) && count( $ids ) == 1 ) {
|
||||
$ids = reset( $ids );
|
||||
}
|
||||
|
|
@ -421,7 +421,7 @@ class CheckStorage {
|
|||
$this->errors[$type] = $this->errors[$type] + array_flip( $revIds );
|
||||
}
|
||||
|
||||
function checkExternalConcatBlobs( $externalConcatBlobs ) {
|
||||
private function checkExternalConcatBlobs( $externalConcatBlobs ) {
|
||||
if ( !count( $externalConcatBlobs ) ) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -463,7 +463,7 @@ class CheckStorage {
|
|||
}
|
||||
}
|
||||
|
||||
function restoreText( $revIds, $xml ) {
|
||||
private function restoreText( $revIds, $xml ) {
|
||||
global $wgDBname;
|
||||
$tmpDir = wfTempDir();
|
||||
|
||||
|
|
@ -524,7 +524,7 @@ class CheckStorage {
|
|||
$importer->doImport();
|
||||
}
|
||||
|
||||
function importRevision( &$revision, &$importer ) {
|
||||
private function importRevision( &$revision, &$importer ) {
|
||||
$id = $revision->getID();
|
||||
$content = $revision->getContent( RevisionRecord::RAW );
|
||||
$id = $id ?: '';
|
||||
|
|
|
|||
|
|
@ -94,11 +94,11 @@ class RecompressTracked {
|
|||
'critical-log' => 'criticalLog',
|
||||
];
|
||||
|
||||
static function getOptionsWithArgs() {
|
||||
public static function getOptionsWithArgs() {
|
||||
return self::$optionsWithArgs;
|
||||
}
|
||||
|
||||
static function newFromCommandLine( $args, $options ) {
|
||||
public static function newFromCommandLine( $args, $options ) {
|
||||
$jobOptions = [ 'destClusters' => $args ];
|
||||
foreach ( self::$cmdLineOptionMap as $cmdOption => $classOption ) {
|
||||
if ( isset( $options[$cmdOption] ) ) {
|
||||
|
|
@ -129,28 +129,28 @@ class RecompressTracked {
|
|||
->newSqlBlobStore();
|
||||
}
|
||||
|
||||
function debug( $msg ) {
|
||||
public function debug( $msg ) {
|
||||
wfDebug( "$msg\n" );
|
||||
if ( $this->debugLog ) {
|
||||
$this->logToFile( $msg, $this->debugLog );
|
||||
}
|
||||
}
|
||||
|
||||
function info( $msg ) {
|
||||
public function info( $msg ) {
|
||||
echo "$msg\n";
|
||||
if ( $this->infoLog ) {
|
||||
$this->logToFile( $msg, $this->infoLog );
|
||||
}
|
||||
}
|
||||
|
||||
function critical( $msg ) {
|
||||
public function critical( $msg ) {
|
||||
echo "$msg\n";
|
||||
if ( $this->criticalLog ) {
|
||||
$this->logToFile( $msg, $this->criticalLog );
|
||||
}
|
||||
}
|
||||
|
||||
function logToFile( $msg, $file ) {
|
||||
private function logToFile( $msg, $file ) {
|
||||
$header = '[' . date( 'd\TH:i:s' ) . '] ' . wfHostname() . ' ' . posix_getpid();
|
||||
if ( $this->childId !== false ) {
|
||||
$header .= "({$this->childId})";
|
||||
|
|
@ -164,7 +164,7 @@ class RecompressTracked {
|
|||
* This allows us to use the replica DB for things that were committed in a
|
||||
* previous part of this batch process.
|
||||
*/
|
||||
function syncDBs() {
|
||||
private function syncDBs() {
|
||||
$dbw = wfGetDB( DB_MASTER );
|
||||
$dbr = wfGetDB( DB_REPLICA );
|
||||
$pos = $dbw->getMasterPos();
|
||||
|
|
@ -201,7 +201,7 @@ class RecompressTracked {
|
|||
* Make sure the tracking table exists and isn't empty
|
||||
* @return bool
|
||||
*/
|
||||
function checkTrackingTable() {
|
||||
private function checkTrackingTable() {
|
||||
$dbr = wfGetDB( DB_REPLICA );
|
||||
if ( !$dbr->tableExists( 'blob_tracking' ) ) {
|
||||
$this->critical( "Error: blob_tracking table does not exist" );
|
||||
|
|
@ -224,7 +224,7 @@ class RecompressTracked {
|
|||
* This necessary because text recompression is slow: loading, compressing and
|
||||
* writing are all slow.
|
||||
*/
|
||||
function startChildProcs() {
|
||||
private function startChildProcs() {
|
||||
$wiki = WikiMap::getWikiIdFromDbDomain( WikiMap::getCurrentWikiDbDomain() );
|
||||
|
||||
$cmd = 'php ' . Shell::escape( __FILE__ );
|
||||
|
|
@ -265,7 +265,7 @@ class RecompressTracked {
|
|||
/**
|
||||
* Gracefully terminate the child processes
|
||||
*/
|
||||
function killChildProcs() {
|
||||
private function killChildProcs() {
|
||||
$this->info( "Waiting for child processes to finish..." );
|
||||
for ( $i = 0; $i < $this->numProcs; $i++ ) {
|
||||
$this->dispatchToChild( $i, 'quit' );
|
||||
|
|
@ -284,7 +284,7 @@ class RecompressTracked {
|
|||
* This may block until a child process finishes its work and becomes available.
|
||||
* @param array|string ...$args
|
||||
*/
|
||||
function dispatch( ...$args ) {
|
||||
private function dispatch( ...$args ) {
|
||||
$pipes = $this->childPipes;
|
||||
$x = [];
|
||||
$y = [];
|
||||
|
|
@ -311,7 +311,7 @@ class RecompressTracked {
|
|||
* @param int $childId
|
||||
* @param array|string $args
|
||||
*/
|
||||
function dispatchToChild( $childId, $args ) {
|
||||
private function dispatchToChild( $childId, $args ) {
|
||||
$args = (array)$args;
|
||||
$cmd = implode( ' ', $args );
|
||||
fwrite( $this->childPipes[$childId], "$cmd\n" );
|
||||
|
|
@ -320,7 +320,7 @@ class RecompressTracked {
|
|||
/**
|
||||
* Move all tracked pages to the new clusters
|
||||
*/
|
||||
function doAllPages() {
|
||||
private function doAllPages() {
|
||||
$dbr = wfGetDB( DB_REPLICA );
|
||||
$i = 0;
|
||||
$startId = 0;
|
||||
|
|
@ -377,7 +377,7 @@ class RecompressTracked {
|
|||
* @param int $current
|
||||
* @param int $end
|
||||
*/
|
||||
function report( $label, $current, $end ) {
|
||||
private function report( $label, $current, $end ) {
|
||||
$this->numBatches++;
|
||||
if ( $current == $end || $this->numBatches >= $this->reportingInterval ) {
|
||||
$this->numBatches = 0;
|
||||
|
|
@ -389,7 +389,7 @@ class RecompressTracked {
|
|||
/**
|
||||
* Move all orphan text to the new clusters
|
||||
*/
|
||||
function doAllOrphans() {
|
||||
private function doAllOrphans() {
|
||||
$dbr = wfGetDB( DB_REPLICA );
|
||||
$startId = 0;
|
||||
$i = 0;
|
||||
|
|
@ -489,7 +489,7 @@ class RecompressTracked {
|
|||
*
|
||||
* @param int $pageId
|
||||
*/
|
||||
function doPage( $pageId ) {
|
||||
private function doPage( $pageId ) {
|
||||
$title = Title::newFromID( $pageId );
|
||||
if ( $title ) {
|
||||
$titleText = $title->getPrefixedText();
|
||||
|
|
@ -571,7 +571,7 @@ class RecompressTracked {
|
|||
* @param int $textId
|
||||
* @param string $url
|
||||
*/
|
||||
function moveTextRow( $textId, $url ) {
|
||||
public function moveTextRow( $textId, $url ) {
|
||||
if ( $this->copyOnly ) {
|
||||
$this->critical( "Internal error: can't call moveTextRow() in --copy-only mode" );
|
||||
exit( 1 );
|
||||
|
|
@ -606,7 +606,7 @@ class RecompressTracked {
|
|||
*
|
||||
* @param array $conds
|
||||
*/
|
||||
function finishIncompleteMoves( $conds ) {
|
||||
private function finishIncompleteMoves( $conds ) {
|
||||
$dbr = wfGetDB( DB_REPLICA );
|
||||
$lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
|
||||
|
||||
|
|
@ -643,7 +643,7 @@ class RecompressTracked {
|
|||
* Returns the name of the next target cluster
|
||||
* @return string
|
||||
*/
|
||||
function getTargetCluster() {
|
||||
public function getTargetCluster() {
|
||||
$cluster = next( $this->destClusters );
|
||||
if ( $cluster === false ) {
|
||||
$cluster = reset( $this->destClusters );
|
||||
|
|
@ -657,7 +657,7 @@ class RecompressTracked {
|
|||
* @param string $cluster
|
||||
* @return IMaintainableDatabase
|
||||
*/
|
||||
function getExtDB( $cluster ) {
|
||||
private function getExtDB( $cluster ) {
|
||||
$lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
|
||||
$lb = $lbFactory->getExternalLB( $cluster );
|
||||
|
||||
|
|
@ -669,7 +669,7 @@ class RecompressTracked {
|
|||
*
|
||||
* @param array $textIds
|
||||
*/
|
||||
function doOrphanList( $textIds ) {
|
||||
private function doOrphanList( $textIds ) {
|
||||
// Finish incomplete moves
|
||||
if ( !$this->copyOnly ) {
|
||||
$this->finishIncompleteMoves( [ 'bt_text_id' => $textIds ] );
|
||||
|
|
@ -742,7 +742,7 @@ class CgzCopyTransaction {
|
|||
* @param int $textId
|
||||
* @return bool
|
||||
*/
|
||||
function addItem( $text, $textId ) {
|
||||
public function addItem( $text, $textId ) {
|
||||
if ( !$this->cgz ) {
|
||||
$class = $this->blobClass;
|
||||
$this->cgz = new $class;
|
||||
|
|
@ -754,14 +754,14 @@ class CgzCopyTransaction {
|
|||
return $this->cgz->isHappy();
|
||||
}
|
||||
|
||||
function getSize() {
|
||||
public function getSize() {
|
||||
return count( $this->texts );
|
||||
}
|
||||
|
||||
/**
|
||||
* Recompress text after some aberrant modification
|
||||
*/
|
||||
function recompress() {
|
||||
public function recompress() {
|
||||
$class = $this->blobClass;
|
||||
$this->cgz = new $class;
|
||||
$this->referrers = [];
|
||||
|
|
@ -776,7 +776,7 @@ class CgzCopyTransaction {
|
|||
* Does nothing if no text items have been added.
|
||||
* May skip the move if --copy-only is set.
|
||||
*/
|
||||
function commit() {
|
||||
public function commit() {
|
||||
$originalCount = count( $this->texts );
|
||||
if ( !$originalCount ) {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ class TrackBlobs {
|
|||
}
|
||||
}
|
||||
|
||||
function run() {
|
||||
public function run() {
|
||||
$this->checkIntegrity();
|
||||
$this->initTrackingTable();
|
||||
$this->trackRevisions();
|
||||
|
|
@ -69,7 +69,7 @@ class TrackBlobs {
|
|||
}
|
||||
}
|
||||
|
||||
function checkIntegrity() {
|
||||
private function checkIntegrity() {
|
||||
echo "Doing integrity check...\n";
|
||||
$dbr = wfGetDB( DB_REPLICA );
|
||||
|
||||
|
|
@ -91,7 +91,7 @@ class TrackBlobs {
|
|||
echo "Integrity check OK\n";
|
||||
}
|
||||
|
||||
function initTrackingTable() {
|
||||
private function initTrackingTable() {
|
||||
$dbw = wfGetDB( DB_MASTER );
|
||||
if ( $dbw->tableExists( 'blob_tracking' ) ) {
|
||||
$dbw->query( 'DROP TABLE ' . $dbw->tableName( 'blob_tracking' ) );
|
||||
|
|
@ -100,7 +100,7 @@ class TrackBlobs {
|
|||
$dbw->sourceFile( __DIR__ . '/blob_tracking.sql' );
|
||||
}
|
||||
|
||||
function getTextClause() {
|
||||
private function getTextClause() {
|
||||
if ( !$this->textClause ) {
|
||||
$dbr = wfGetDB( DB_REPLICA );
|
||||
$this->textClause = '';
|
||||
|
|
@ -115,7 +115,7 @@ class TrackBlobs {
|
|||
return $this->textClause;
|
||||
}
|
||||
|
||||
function interpretPointer( $text ) {
|
||||
private function interpretPointer( $text ) {
|
||||
if ( !preg_match( '!^DB://(\w+)/(\d+)(?:/([0-9a-fA-F]+)|)$!', $text, $m ) ) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -130,7 +130,7 @@ class TrackBlobs {
|
|||
/**
|
||||
* Scan the revision table for rows stored in the specified clusters
|
||||
*/
|
||||
function trackRevisions() {
|
||||
private function trackRevisions() {
|
||||
global $wgMultiContentRevisionSchemaMigrationStage;
|
||||
|
||||
$dbw = wfGetDB( DB_MASTER );
|
||||
|
|
@ -225,7 +225,7 @@ class TrackBlobs {
|
|||
* Orphan text here does not imply DB corruption -- deleted text tracked by the
|
||||
* archive table counts as orphan for our purposes.
|
||||
*/
|
||||
function trackOrphanText() {
|
||||
private function trackOrphanText() {
|
||||
# Wait until the blob_tracking table is available in the replica DB
|
||||
$dbw = wfGetDB( DB_MASTER );
|
||||
$dbr = wfGetDB( DB_REPLICA );
|
||||
|
|
@ -311,7 +311,7 @@ class TrackBlobs {
|
|||
* Orphan blobs are indicative of DB corruption. They are inaccessible and
|
||||
* should probably be deleted.
|
||||
*/
|
||||
function findOrphanBlobs() {
|
||||
private function findOrphanBlobs() {
|
||||
if ( !extension_loaded( 'gmp' ) ) {
|
||||
echo "Can't find orphan blobs, need bitfield support provided by GMP.\n";
|
||||
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ class UpdateMediaWiki extends Maintenance {
|
|||
return Maintenance::DB_ADMIN;
|
||||
}
|
||||
|
||||
function compatChecks() {
|
||||
private function compatChecks() {
|
||||
$minimumPcreVersion = Installer::MINIMUM_PCRE_VERSION;
|
||||
|
||||
$pcreVersion = explode( ' ', PCRE_VERSION, 2 )[0];
|
||||
|
|
@ -223,7 +223,7 @@ class UpdateMediaWiki extends Maintenance {
|
|||
$this->output( "\nDone in $timeDiff.\n" );
|
||||
}
|
||||
|
||||
function afterFinalSetup() {
|
||||
protected function afterFinalSetup() {
|
||||
global $wgLocalisationCacheConf;
|
||||
|
||||
# Don't try to access the database
|
||||
|
|
|
|||
|
|
@ -243,7 +243,7 @@ TEXT
|
|||
* @param IDatabase $dbw
|
||||
* @return string
|
||||
*/
|
||||
function getBatchCondition( $row, $dbw ) {
|
||||
private function getBatchCondition( $row, $dbw ) {
|
||||
if ( $this->hasOption( 'previous-collation' ) ) {
|
||||
$fields = [ 'cl_to', 'cl_type', 'cl_from' ];
|
||||
} else {
|
||||
|
|
@ -275,7 +275,7 @@ TEXT
|
|||
return $cond;
|
||||
}
|
||||
|
||||
function updateSortKeySizeHistogram( $key ) {
|
||||
private function updateSortKeySizeHistogram( $key ) {
|
||||
$length = strlen( $key );
|
||||
if ( !isset( $this->sizeHistogram[$length] ) ) {
|
||||
$this->sizeHistogram[$length] = 0;
|
||||
|
|
@ -283,7 +283,7 @@ TEXT
|
|||
$this->sizeHistogram[$length]++;
|
||||
}
|
||||
|
||||
function showSortKeySizeHistogram() {
|
||||
private function showSortKeySizeHistogram() {
|
||||
$maxLength = max( array_keys( $this->sizeHistogram ) );
|
||||
if ( $maxLength == 0 ) {
|
||||
return;
|
||||
|
|
|
|||
Loading…
Reference in a new issue