* Removing unused local vars.
* Removing unused global declarations.
* removing one or two pass-by-refs parameter declarations where not required by PHP5.
* Adding some local variable declarations / initializations (initialized to either to array(), null) to keep static code analyzer happy.
* Changing lines like this: "extract( $dbw->tableNames( 'page', 'archive' ) );" to be like this: "list ($page, $archive) = $dbw->tableNamesN( 'page', 'archive' );".
* Add one or two braces to if-else blocks.
class FiveUpgrade {
function FiveUpgrade() {
- global $wgDatabase;
$this->conversionTables = $this->prepareWindows1252();
$this->dbw =& $this->newConnection();
$name_temp = $name . '_temp';
$this->log( "Migrating $name table to $name_temp..." );
- $table = $this->dbw->tableName( $name );
$table_temp = $this->dbw->tableName( $name_temp );
// Create temporary table; we're going to copy everything in there,
$this->log( "...converting from cur/old to page/revision/text DB structure." );
- extract( $this->dbw->tableNames( 'cur', 'old', 'page', 'revision', 'text' ) );
+ list ($cur, $old, $page, $revision, $text) = $this->dbw->tableNamesN( 'cur', 'old', 'page', 'revision', 'text' );
$this->log( "Creating page and revision tables..." );
$this->dbw->query("CREATE TABLE $page (
function upgradeLinks() {
$fname = 'FiveUpgrade::upgradeLinks';
$chunksize = 200;
- extract( $this->dbw->tableNames( 'links', 'brokenlinks', 'pagelinks', 'cur' ) );
+ list ($links, $brokenlinks, $pagelinks, $cur) = $this->dbw->tableNamesN( 'links', 'brokenlinks', 'pagelinks', 'cur' );
$this->log( 'Checking for interwiki table change in case of bogus items...' );
if( $this->dbw->fieldExists( 'interwiki', 'iw_trans' ) ) {
$fname = 'FiveUpgrade::upgradeWatchlist';
$chunksize = 100;
- extract( $this->dbw->tableNames( 'watchlist', 'watchlist_temp' ) );
+ list ($watchlist, $watchlist_temp) = $this->dbw->tableNamesN( 'watchlist', 'watchlist_temp' );
$this->log( 'Migrating watchlist table to watchlist_temp...' );
$this->dbw->query(
$add = array();
while( $row = $this->dbr->fetchObject( $result ) ) {
- $now = $this->dbw->timestamp();
$add[] = array(
'wl_user' => $row->wl_user,
'wl_namespace' => Namespace::getSubject( $row->wl_namespace ),
print "Initialising external storage $store...\n";
global $wgDBuser, $wgDBpassword, $wgExternalServers;
foreach ( $stores as $storeURL ) {
+ $m = array();
if ( !preg_match( '!^DB://(.*)$!', $storeURL, $m ) ) {
continue;
}
$sink = null;
$sinks = array();
foreach( $args as $arg ) {
+ $matches = array();
if( preg_match( '/^--(.+?)(?:=(.+?)(?::(.+?))?)?$/', $arg, $matches ) ) {
- @list( $full, $opt, $val, $param ) = $matches;
+ @list( /* $full */ , $opt, $val, $param ) = $matches;
switch( $opt ) {
case "plugin":
$this->loadPlugin( $val, $param );
$result = $this->dbr->query( $sql, $fname );
while( $row = $this->dbr->fetchObject( $result ) ) {
- $updated = call_user_func( $callback, $row );
+ call_user_func( $callback, $row );
}
$this->log( "Finished $table... $this->updated of $this->processed rows updated" );
$this->dbr->freeResult( $result );
if( $row->page_namespace == $this->namespace ) {
$talk = $target->getTalkPage();
- $xrow = $row;
$row->page_namespace = $talk->getNamespace();
if( $talk->exists() ) {
return $this->processPage( $row );
print $title->getPrefixedDBkey() . " ...";
$rev = Revision::newFromTitle( $title );
- $reverted = false;
$revId = $rev->getId();
$currentRevId = $revId;
$regex = LinkFilter::makeRegex( $domain );
$result = $this->dbr->query( $sql, $fname );
while( $row = $this->dbr->fetchObject( $result ) ) {
- $updated = call_user_func( $callback, $row );
+ call_user_func( $callback, $row );
}
$this->log( "Finished $table... $this->updated of $this->processed rows updated" );
$this->dbr->freeResult( $result );
}
function processPage( $row ) {
- global $wgContLang;
-
$current = Title::makeTitle( $row->page_namespace, $row->page_title );
$display = $current->getPrefixedText();
$result = $this->dbr->query( $sql, $fname );
while( $row = $this->dbr->fetchObject( $result ) ) {
- $updated = call_user_func( $callback, $row );
+ call_user_func( $callback, $row );
}
$this->log( "Finished $table... $this->updated of $this->processed rows updated" );
$this->dbr->freeResult( $result );
}
function processEntry( $row ) {
- global $wgContLang;
-
$current = Title::makeTitle( $row->wl_namespace, $row->wl_title );
$display = $current->getPrefixedText();
global $wgLang, $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname;
global $noKeys, $logPerformance, $fh;
- $numRows = $tuplesAdded = $numBadLinks = $curRowsRead = 0; #counters etc
+ $tuplesAdded = $numBadLinks = $curRowsRead = 0; #counters etc
$totalTuplesInserted = 0; # total tuples INSERTed into links_temp
$reportCurReadProgress = true; #whether or not to give progress reports while reading IDs from cur table
#--------------------------------------------------------------------
$dbw =& wfGetDB( DB_MASTER );
- extract( $dbw->tableNames( 'cur', 'links', 'links_temp', 'links_backup' ) );
+ list ($cur, $links, $links_temp, $links_backup) = $dbw->tableNamesN( 'cur', 'links', 'links_temp', 'links_backup' );
$res = $dbw->query( "SELECT l_from FROM $links LIMIT 1" );
if ( $dbw->fieldType( $res, 0 ) == "int" ) {
* have a local image
*/
function doLocalImageDescriptions() {
- global $wgSharedUploadDirectory;
$chunkSize = 1000;
$dbr =& wfGetDB( DB_SLAVE );
/** Write an article specified by title */
function doArticle( $title ) {
- global $wgTitle, $wgSharedUploadPath, $wgSharedUploadDirectory;
- global $wgUploadDirectory;
-
if ( $this->noOverwrite ) {
$fileName = $this->dest.'/'.$this->getHashedFilename( $title );
if ( file_exists( $fileName ) ) {
}
/** Write the given text to the file identified by the given title object */
- function writeArticle( &$title, $text ) {
+ function writeArticle( $title, $text ) {
$filename = $this->getHashedFilename( $title );
# Temporary hack for current dump, this should be moved to
/** Set up globals required for parsing */
function setupGlobals( $currentDepth = NULL ) {
- global $wgUser, $wgTitle, $wgStylePath, $wgArticlePath, $wgMathPath;
+ global $wgUser, $wgStylePath, $wgArticlePath, $wgMathPath;
global $wgUploadPath, $wgLogo, $wgMaxCredits, $wgSharedUploadPath;
global $wgHideInterlanguageLinks, $wgUploadDirectory, $wgThumbnailScriptPath;
global $wgSharedThumbnailScriptPath, $wgEnableParserCache, $wgHooks, $wgServer;
}
/** Reads the content of a title object, executes the skin and captures the result */
- function getArticleHTML( &$title ) {
+ function getArticleHTML( $title ) {
global $wgOut, $wgTitle, $wgArticle, $wgUser;
$linkCache =& LinkCache::singleton();
$url = false;
if ( $query != '' ) {
+ $params = array();
parse_str( $query, $params );
if ( isset($params['action']) && $params['action'] == 'raw' ) {
if ( $params['gen'] == 'css' || $params['gen'] == 'js' ) {
} else {
$file = $this->getFriendlyName( $title->getPrefixedDBkey() );
// Clean up Monobook.css etc.
+ $matches = array();
if ( preg_match( '/^(.*)\.(css|js)_[0-9a-f]{4}$/', $file, $matches ) ) {
$file = $matches[1] . '.' . $matches[2];
}
}
# Split into characters
+ $m = array();
preg_match_all( '/./us', $dbk, $m );
$chars = $m[0];
wfDie( "m:Interwiki_map not found" );
}
- $iwArray = array();
- # Global iterwiki map
+ # Global iterwiki map
foreach ( $lines as $line ) {
if ( preg_match( '/^\|\s*(.*?)\s*\|\|\s*(.*?)\s*$/', $line, $matches ) ) {
$prefix = strtolower( $matches[1] );
#Multilanguage sites
foreach ($sites as $site)
- $sql .= makeLanguageLinks ( $site, "_".$site->suffix );
+ makeLanguageLinks ( $site, "_".$site->suffix );
foreach ( $dblist as $db ) {
continue;
}
$lang = $matches[1];
- $host = "$lang." . $site->url;
# Lateral links
foreach ( $sites as $targetSite ) {
# ------------------------------------------------------------------------------------------
-# Returns part of an INSERT statement, corresponding to all interlanguage links to a particular site
+# Executes part of an INSERT statement, corresponding to all interlanguage links to a particular site
function makeLanguageLinks( &$site, $source ) {
global $langlist, $languageAliases;
# Actual languages with their own databases
function getHooksFromDoc() {
global $doc;
$content = file_get_contents( $doc );
+ $m = array();
preg_match_all( "/\n'(.*?)'/", $content, $m);
return $m[1];
}
*/
function getHooksFromFile( $file ) {
$content = file_get_contents( $file );
+ $m = array();
preg_match_all( "/wfRunHooks\(\s*\'(.*?)\'/", $content, $m);
return $m[1];
}
global $slaveIndexes;
foreach ( $slaveIndexes as $i ) {
- $slaveIDs = array();
$db =& wfGetDB( $i );
$res = $db->select( 'page', array( 'page_id', 'page_latest' ), array( 'page_id<6054123' ), __METHOD__ );
while ( $row = $db->fetchObject( $res ) ) {
if ( count( $missingIDs ) ) {
print "Found " . count( $missingIDs ) . " lost in master, copying from slave... ";
$dbFrom = $db;
- $dbTo = $dbw;
$found = true;
$toMaster = true;
} else {
if ( count( $missingIDs ) ) {
print "Found " . count( $missingIDs ) . " missing revision(s), copying from master... ";
$dbFrom = $dbw;
- $dbTo = $db;
$found = true;
$toMaster = false;
} else {
$this->progress( "Got bogus revision with null title!" );
return;
}
- $display = $title->getPrefixedText();
- $timestamp = $rev->getTimestamp();
+ #$timestamp = $rev->getTimestamp();
+ #$display = $title->getPrefixedText();
#echo "$display $timestamp\n";
$this->revCount++;
if( $dhl = opendir( $dir ) ) {
while( ( $file = readdir( $dhl ) ) !== false ) {
if( is_file( $dir . '/' . $file ) ) {
- list( $name, $ext ) = splitFilename( $dir . '/' . $file );
+ list( /* $name */, $ext ) = splitFilename( $dir . '/' . $file );
if( array_search( strtolower( $ext ), $exts ) !== false )
$files[] = $dir . '/' . $file;
}
}
$lines = explode( '<li>', $text );
foreach( $lines as $line ) {
+ $matches = array();
if( preg_match( '!^(.*)</li>!', $line, $matches ) ) {
$this->importLine( $matches[1] );
}
# 01:55, 23 Aug 2004 - won't take in strtotimr
# "Aug 23 2004 01:55" - seems ok
# TODO: multilingual attempt to extract from the data in Language
+ $matches = array();
if( preg_match( '/^(\d+:\d+(?::\d+)?), (.*)$/', $date, $matches ) ) {
$date = $matches[2] . ' ' . $matches[1];
}
function importLine( $line ) {
foreach( $this->actions as $action => $regexp ) {
+ $matches = array();
if( preg_match( $regexp, $line, $matches ) ) {
if( $this->dummy ) {
#var_dump( $matches );
$a = explode( "\n", $s );
foreach ( $a as $l ) {
+ $m = array();
if ( preg_match( "/^([A-Za-z0-9_]+)=(.*)/", $l, $m ) ) {
$ops[$m[1]] = $m[2];
}
echo "\n<!-- Checking page directory " . xmlCommentSafe( $dir ) . " -->\n";
$mydir = opendir( $dir );
while( $entry = readdir( $mydir ) ) {
+ $m = array();
if( preg_match( '/^(.+)\.db$/', $entry, $m ) ) {
echo importPage( $prefix . $m[1] );
} else {
function fetchPage( $title )
{
- global $FS,$FS1,$FS2,$FS3, $wgRootDirectory;
+ global $FS1,$FS2,$FS3, $wgRootDirectory;
$fname = $wgRootDirectory . "/page/" . useModFilename( $title ) . ".db";
if( !file_exists( $fname ) ) {
function fetchKeptPages( $title )
{
- global $FS,$FS1,$FS2,$FS3, $wgRootDirectory, $wgTimezoneCorrection;
+ global $FS1,$FS2,$FS3, $wgRootDirectory;
$fname = $wgRootDirectory . "/keep/" . useModFilename( $title ) . ".kp";
if( !file_exists( $fname ) ) return array();
# History
$revisions = array_merge( $revisions, fetchKeptPages( $title ) );
if(count( $revisions ) == 0 ) {
- return $sql;
+ return NULL; // Was "$sql", which does not appear to be defined.
}
foreach( $revisions as $rev ) {
$text = xmlsafe( recodeText( $rev->text ) );
$minor = ($rev->minor ? '<minor/>' : '');
- list( $userid, $username ) = checkUserCache( $rev->username, $rev->host );
+ list( /* $userid */ , $username ) = checkUserCache( $rev->username, $rev->host );
$username = xmlsafe( recodeText( $username ) );
$timestamp = xmlsafe( timestamp2ISO8601( $rev->ts ) );
$comment = xmlsafe( recodeText( $rev->summary ) );
/*static*/ function makeRepository( $path, $type = NULL ) {
if ( !$type ) {
+ $m = array();
preg_match( '!(([-+\w]+)://)?.*?(\.[-\w\d.]+)?$!', $path, $m );
$proto = @$m[2];
- if( !$proto ) $type = 'dir';
- else if ( ( $proto == 'http' || $proto == 'https' )
- && preg_match( '!([^\w]svn|svn[^\w])!i', $path) ) $type = 'svn'; #HACK!
- else $type = $proto;
+ if ( !$proto ) {
+ $type = 'dir';
+ } else if ( ( $proto == 'http' || $proto == 'https' ) && preg_match( '!([^\w]svn|svn[^\w])!i', $path) ) {
+ $type = 'svn'; #HACK!
+ } else {
+ $type = $proto;
+ }
}
- if ( $type == 'dir' || $type == 'file' ) return new LocalInstallerRepository( $path );
- else if ( $type == 'http' || $type == 'http' ) return new WebInstallerRepository( $path );
- else return new SVNInstallerRepository( $path );
+ if ( $type == 'dir' || $type == 'file' ) { return new LocalInstallerRepository( $path ); }
+ else if ( $type == 'http' || $type == 'http' ) { return new WebInstallerRepository( $path ); }
+ else { return new SVNInstallerRepository( $path ); }
}
}
$n = basename($f);
if ( !is_dir( $f ) ) {
+ $m = array();
if ( !preg_match( '/(.*)\.(tgz|tar\.gz|zip)/', $n, $m ) ) continue;
$n = $m[1];
}
print ( $txt );
return false;
}
-
+
+ $m = array();
$ok = preg_match_all( '!<a\s[^>]*href\s*=\s*['."'".'"]([^/'."'".'"]+)\.tgz['."'".'"][^>]*>.*?</a>!si', $txt, $m, PREG_SET_ORDER );
if ( !$ok ) {
ExtensionInstaller::error( "listing index from {$this->path} does not match!" );
function printListing( ) {
ExtensionInstaller::note( "SVN list {$this->path}..." );
+ $code = null; // Shell Exec return value.
$txt = wfShellExec( 'svn ls ' . escapeshellarg( $this->path ), $code );
if ( $code !== 0 ) {
ExtensionInstaller::error( "svn list for {$this->path} failed!" );
$ll = preg_split('/(\s*[\r\n]\s*)+/', $txt);
foreach ( $ll as $line ) {
+ $m = array();
if ( !preg_match('!^(.*)/$!', $line, $m) ) continue;
$n = $m[1];
$this->isdir= $isdir;
$this->islocal = $islocal;
+ $m = array();
preg_match( '!([-+\w]+://)?.*?(\.[-\w\d.]+)?$!', $path, $m );
$this->protocol = @$m[1];
if ( $this->extensions == '.tgz' || $this->extensions == '.tar.gz' ) { #tgz file
ExtensionInstaller::note( "extracting $file..." );
+ $code = null; // shell Exec return value.
wfShellExec( 'tar zxvf ' . escapeshellarg( $file ) . ' -C ' . escapeshellarg( $target ), $code );
if ( $code !== 0 ) {
}
else if ( $this->extensions == '.zip' ) { #zip file
ExtensionInstaller::note( "extracting $file..." );
+ $code = null; // shell Exec return value.
wfShellExec( 'unzip ' . escapeshellarg( $file ) . ' -d ' . escapeshellarg( $target ) , $code );
if ( $code !== 0 ) {
}
/*static*/ function makeResource( $url ) {
+ $m = array();
preg_match( '!(([-+\w]+)://)?.*?(\.[-\w\d.]+)?$!', $url, $m );
$proto = @$m[2];
$ext = @$m[3];
if ( $ext ) $ext = strtolower( $ext );
- if ( !$proto ) return new LocalInstallerResource( $url, $ext ? false : true );
- else if ( $ext && ( $proto == 'http' || $proto == 'http' || $proto == 'ftp' ) ) return new WebInstallerResource( $url );
- else return new SVNInstallerResource( $url );
+ if ( !$proto ) { return new LocalInstallerResource( $url, $ext ? false : true ); }
+ else if ( $ext && ( $proto == 'http' || $proto == 'http' || $proto == 'ftp' ) ) { return new WebInstallerResource( $url ); }
+ else { return new SVNInstallerResource( $url ); }
}
}
function fetch( $target ) {
ExtensionInstaller::note( "SVN checkout of {$this->path}..." );
+ $code = null; // shell exec return val.
wfShellExec( 'svn co ' . escapeshellarg( $this->path ) . ' ' . escapeshellarg( $target ), $code );
if ( $code !== 0 ) {
$s = $this->prompt( $msg . " [yes/no]: ");
$s = strtolower( trim($s) );
- if ( $s == 'yes' || $s == 'y' ) return true;
- else if ( $s == 'no' || $s == 'n' ) return false;
- else print "bad response: $s\n";
+ if ( $s == 'yes' || $s == 'y' ) { return true; }
+ else if ( $s == 'no' || $s == 'n' ) { return false; }
+ else { print "bad response: $s\n"; }
}
}
if ( !$repos && file_exists("$tgt/.svn") && is_dir("$tgt/.svn") ) {
$svn = file_get_contents( "$tgt/.svn/entries" );
+ $m = array();
if ( preg_match( '!url="(.*?)"!', $svn, $m ) ) {
$repos = dirname( $m[1] ) . '/extensions';
}
#TODO: detect $source mismatching $name !!
$mode = EXTINST_WRITEPATCH;
-if ( isset( $options['nopatch'] ) || @$wgExtensionInstallerNoPatch ) $mode = EXTINST_NOPATCH;
-else if ( isset( $options['hotpatch'] ) || @$wgExtensionInstallerHotPatch ) $mode = EXTINST_HOTPATCH;
+if ( isset( $options['nopatch'] ) || @$wgExtensionInstallerNoPatch ) { $mode = EXTINST_NOPATCH; }
+else if ( isset( $options['hotpatch'] ) || @$wgExtensionInstallerHotPatch ) { $mode = EXTINST_HOTPATCH; }
if ( !file_exists( "$tgt/LocalSettings.php" ) ) {
die("can't find $tgt/LocalSettings.php\n");
private $mExtArray;
function __construct( $ext18nFilename, $extArrayName ) {
- $exif = false;
$this->mExt18nFilename = $ext18nFilename;
$this->mExtArrayName = $extArrayName;
// Provided array could not be found we try to guess it.
# Using the extension path ($m[1]) and filename ($m[2]):
+ $m = array();
preg_match( '%.*/(.*)/(.*).i18n\.php%', $this->mExt18nFilename, $m);
$arPathCandidate = 'wg' . $m[1].'Messages';
$arFileCandidate = 'wg' . $m[2].'Messages';
* @param $code The language code.
*/
function checkLanguage( $wgLanguages, $code ) {
- global $wgGeneralMessages, $wgRequiredMessagesNumber, $wgDisplayLevel, $wgLinks, $wgWikiLanguage, $wgChecks;
+ global $wgRequiredMessagesNumber, $wgDisplayLevel, $wgLinks, $wgWikiLanguage, $wgChecks;
# Get messages
$messages = $wgLanguages->getMessages( $code );
foreach ( glob( "$IP/languages/messages/Messages*.php" ) as $filename ) {
$base = basename( $filename );
+ $m = array();
if ( !preg_match( '/Messages(.*)\.php$/', $base, $m ) ) {
continue;
}
function getMediawikiMessages($languageCode = 'En') {
$foo = "wgAllMessages$languageCode";
- global $$foo, $wgSkinNamesEn;
+ global $$foo;
+ global $wgSkinNamesEn; // potentially unused global declaration?
// it might already be loaded in LocalSettings.php
if(!isset($$foo)) {
$langFile = $IP.'/languages/classes/Language'.$languageCode.'.php';
if (file_exists( $langFile ) ) {
print "Including $langFile\n";
- global $wgNamespaceNamesEn;
+ global $wgNamespaceNamesEn; // potentially unused global declaration?
include($langFile);
} else wfDie("ERROR: The file $langFile does not exist !\n");
}
* @param $write Write to the messages file?
*/
function rebuildLanguage( $code, $write ) {
- global $wgLanguages, $wg;
+ global $wgLanguages;
# Get messages
$messages = $wgLanguages->getMessages( $code );
* @return The PHP text.
*/
function writeMessagesArray( $messages, $ignoredComments = false ) {
- global $wgMessageStrucutre, $wgBlockComments, $wgMessageComments;
+ global $wgMessageStrucutre, $wgBlockComments;
# Sort messages to blocks
$sortedMessages['unknown'] = $messages;
$ok = true;
while( false !== ($line = fgets( $infile ) ) ) {
$n++;
+ $matches = array();
if( preg_match( '/^!!\s*(\w+)/', $line, $matches ) ) {
$section = strtolower( $matches[1] );
if( $section == 'endarticle') {
$options->setUseTex(true);
}
+ $m = array();
if (preg_match('/title=\[\[(.*)\]\]/', $opts, $m)) {
$titleText = $m[1];
}
$title =& Title::makeTitle( NS_MAIN, $titleText );
+ $matches = array();
if (preg_match('/\\bpst\\b/i', $opts)) {
$out = $parser->preSaveTransform( $input, $title, $user, $options );
} elseif (preg_match('/\\bmsg\\b/i', $opts)) {
$this->uploadDir = $this->setupUploadDir();
}
+ $m = array();
if( preg_match( '/language=([a-z]+(?:_[a-z]+)?)/', $opts, $m ) ) {
$lang = $m[1];
} else {
$portion * 100.0,
$this->table,
wfTimestamp( TS_DB, intval( $eta ) ),
- $completed,
+ $completed, // $completed does not appear to be defined.
$this->count,
- $rate,
+ $rate, // $rate does not appear to be defined.
$updateRate * 100.0 );
flush();
}
$iwArray = array();
foreach ( $lines as $line ) {
+ $matches = array();
if ( preg_match( '/^\|\s*(.*?)\s*\|\|\s*(https?:\/\/.*?)\s*$/', $line, $matches ) ) {
$prefix = strtolower( $matches[1] );
$url = $matches[2];
function rebuildRecentChangesTablePass2()
{
$dbw =& wfGetDB( DB_MASTER );
- extract( $dbw->tableNames( 'recentchanges', 'revision' ) );
-
- $ns = $id = $count = 0;
- $title = $ct = "";
+ list ($recentchanges, $revision) = $dbw->tableNamesN( 'recentchanges', 'revision' );
print( "Updating links...\n" );
function rebuildTextIndex( &$database )
{
- extract( $database->tableNames( 'page', 'revision', 'text', 'searchindex' ) );
+ list ($page, $revision, $text, $searchindex) = $database->tableNamesN( 'page', 'revision', 'text', 'searchindex' );
$sql = "SELECT MAX(page_id) AS count FROM $page";
$res = $database->query($sql, "rebuildTextIndex" );
array( 'old_id IN (' . implode( ',', $objectRevs ) . ')' ), $fname );
while ( $row = $dbr->fetchObject( $res ) ) {
$oldId = $row->old_id;
+ $matches = array();
if ( !preg_match( '/^O:(\d+):"(\w+)"/', $row->header, $matches ) ) {
$this->error( 'restore text', "Error: invalid object header", $oldId );
continue;
print "Starting from old_id $start...\n";
$dbw =& wfGetDB( DB_MASTER );
do {
- $end = $start + $chunksize;
$res = $dbw->select( 'text', array( 'old_id','old_flags','old_namespace','old_title','old_text' ),
"old_id>=$start", $fname, array( 'ORDER BY' => 'old_id', 'LIMIT' => $chunksize, 'FOR UPDATE' ) );
if( $dbw->numRows( $res ) == 0 ) {
#$tables[] = 'page';
#$conds[] = 'page_id=rev_page AND rev_id != page_latest';
- $oldReadsSinceLastSlaveWait = 0; #check slave lag periodically
- $totalMatchingRevisions = 0;
- $masterPos = false;
for ( $pageId = $startId; $pageId <= $maxPageId; $pageId++ ) {
wfWaitForSlaves( 5 );
'rev_id < ' . $pageRow->page_latest
) + $conds
);
- exit;
+ exit; // FIXME: is this "exit" supposed to be here? If no, delete, else delete dead code below.
# Load revisions
$revRes = $dbw->select( $tables, $fields,
$fname = 'resolveStubs';
$dbr =& wfGetDB( DB_SLAVE );
- $dbw =& wfGetDB( DB_MASTER );
$maxID = $dbr->selectField( 'text', 'MAX(old_id)', false, $fname );
$blockSize = 10000;
$numBlocks = intval( $maxID / $blockSize ) + 1;
printf( "%5.2f%%\n", $b / $numBlocks * 100 );
$start = intval($maxID / $numBlocks) * $b + 1;
$end = intval($maxID / $numBlocks) * ($b + 1);
- $stubs = array();
- $flagsArray = array();
-
$res = $dbr->select( 'text', array( 'old_id', 'old_text', 'old_flags' ),
"old_id>=$start AND old_id<=$end " .
* @return string
*/
function makeSql() {
- extract( $this->dbr->tableNames( 'page', 'pagelinks' ) );
+ list( $page, $pagelinks ) = $this->dbr->tableNamesN( 'page', 'pagelinks' );
$nsset = $this->makeNsSet();
return "SELECT DISTINCT page_namespace,page_title FROM $page,$pagelinks " .
"WHERE pl_from=page_id and page_namespace IN ( $nsset ) " .
echo wfTimestamp();
echo "......checking for duplicate entries.\n"; flush();
- extract( $wgDatabase->tableNames( 'cur', 'old', 'page', 'revision', 'text' ) );
+ list ($cur, $old, $page, $revision, $text) = $wgDatabase->tableNamesN( 'cur', 'old', 'page', 'revision', 'text' );
$rows = $wgDatabase->query( "SELECT cur_title, cur_namespace, COUNT(cur_namespace) AS c
FROM $cur GROUP BY cur_title, cur_namespace HAVING c>1", $fname );
function do_inverse_timestamp() {
global $wgDatabase;
- $fname="do_schema_restructuring";
if( $wgDatabase->fieldExists( 'revision', 'inverse_timestamp' ) ) {
echo "Removing revision.inverse_timestamp and fixing indexes... ";
dbsource( archive( 'patch-inverse_timestamp.sql' ), $wgDatabase );
$upgrade = str_replace( 'MWVERSION', $wgVersion, $upgrade );
$upgrade = str_replace( 'THISVERSION', $oldversion, $upgrade );
$upgrade = str_replace( 'SVERSION', $version, $upgrade );
- $res = $wgDatabase->query("BEGIN;\n\n $upgrade\n\nCOMMIT;\n");
+ $wgDatabase->query("BEGIN;\n\n $upgrade\n\nCOMMIT;\n");
return;
}
$names = array_map( array( $this, 'lockTable' ), $set );
$tables = implode( ',', $names );
- $result = $this->db->query( "LOCK TABLES $tables", $fname );
+ $this->db->query( "LOCK TABLES $tables", $fname );
}
function lockTable( $table ) {
*/
function unlock() {
$fname = 'UserDupes::unlock';
- $result = $this->db->query( "UNLOCK TABLES", $fname );
+ $this->db->query( "UNLOCK TABLES", $fname );
}
/**
function reassignEditsOn( $table, $field, $from, $to ) {
$fname = 'UserDupes::reassignEditsOn';
echo "reassigning on $table... ";
- $result = $this->db->update( $table,
+ $this->db->update( $table,
array( $field => $to ),
array( $field => $from ),
$fname );