"I can't import dumps from Wikipedia" complaints
* (bug 7460) Revert broken patch for bug 7226 which slows down
Special:Allmessages by a factor of 16
+* Committed a bunch of live hacks from Wikimedia servers
== Languages updated ==
$success = false;
- if ( $this->mFlags & DBO_PERSISTENT ) {
- @/**/$this->mConn = mysql_pconnect( $server, $user, $password );
- } else {
- # Create a new connection...
- @/**/$this->mConn = mysql_connect( $server, $user, $password, true );
+ wfProfileIn("dbconnect-$server");
+
+ # LIVE PATCH by Tim, ask Domas for why: retry loop
+ $this->mConn = false;
+ for ( $i = 0; $i < 3 && !$this->mConn; $i++ ) {
+ if ( $i > 1 ) {
+ usleep( 1000 );
+ }
+ if ( $this->mFlags & DBO_PERSISTENT ) {
+ @/**/$this->mConn = mysql_pconnect( $server, $user, $password );
+ } else {
+ # Create a new connection...
+ @/**/$this->mConn = mysql_connect( $server, $user, $password, true );
+ }
+ if ($this->mConn === false) {
+ wfLogDBError("Connect loop error ($server): " . mysql_errno() . " - " . mysql_error()."\n");
+ }
}
+
+ wfProfileOut("dbconnect-$server");
if ( $dbName != '' ) {
if ( $this->mConn !== false ) {
if ( !$success ) {
$error = "Error selecting database $dbName on server {$this->mServer} " .
"from client host {$wguname['nodename']}\n";
+ wfLogDBError(" Error selecting database $dbname on server {$this->mServer} \n");
wfDebug( $error );
}
} else {
class FSException extends MWException { }
-?>
\ No newline at end of file
+?>
wfProfileOut( __METHOD__ );
return $times;
}
+ wfIncrStats( 'lag_cache_miss_expired' );
+ } else {
+ wfIncrStats( 'lag_cache_miss_absent' );
}
# Cache key missing or expired
# But don't give the timestamp to the caller
unset($times['timestamp']);
- wfIncrStats( 'lag_cache_miss' );
wfProfileOut( __METHOD__ );
return $times;
}
global $wgContLang;
$this->mId = $id;
$wgContLang->getMagic( $this );
+ if ( !$this->mSynonyms ) {
+ $this->mSynonyms = array( 'dkjsagfjsgashfajsh' );
+ #throw new MWException( "Error: invalid magic word '$id'" );
+ wfDebugLog( 'exception', "Error: invalid magic word '$id'\n" );
+ }
}
/**
*/
global $wgUseTidy, $wgAlwaysUseTidy, $wgContLang;
- $fname = 'Parser::parse';
+ $fname = 'Parser::parse-' . wfGetCaller();
wfProfileIn( $fname );
if ( $clearState ) {
wfProfileIn($fname);
- $this->mTitle = $wgTitle;
+ if ( $wgTitle ) {
+ $this->mTitle = $wgTitle;
+ } else {
+ $this->mTitle = Title::newFromText('msg');
+ }
$this->mOptions = $options;
$this->setOutputType( OT_MSG );
$this->clearState();
require_once(dirname(__FILE__).'/Profiler.php');
class ProfilerSimple extends Profiler {
+ var $mMinimumTime = 0;
+
function ProfilerSimple() {
global $wgRequestTime,$wgRUstart;
if (!empty($wgRequestTime) && !empty($wgRUstart)) {
}
}
+ function setMinimum( $min ) {
+ $this->mMinimumTime = $min;
+ }
+
function profileIn($functionname) {
global $wgDebugFunctionEntry;
if ($wgDebugFunctionEntry) {
global $wgUDPProfilerPort;
global $wgDBname;
+ if ( $this->mCollated['-total']['real'] < $this->mMinimumTime ) {
+ # Less than minimum, ignore
+ return;
+ }
+
+
$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
$plength=0;
$packet="";
# of the extension file. This allows the extension to perform
# any necessary initialisation in the fully initialised environment
foreach ( $wgExtensionFunctions as $func ) {
+ $profName = $fname.'-extensions-'.strval( $func );
+ wfProfileIn( $profName );
call_user_func( $func );
+ wfProfileOut( $profName );
}
// For compatibility
if ( $updates ) {
$site_stats = $dbw->tableName( 'site_stats' );
$sql = $dbw->limitResultForUpdate("UPDATE $site_stats SET $updates", 1);
+ $dbw->begin();
$dbw->query( $sql, $fname );
+ $dbw->commit();
}
+
+ /*
+ global $wgDBname, $wgTitle;
+ if ( $this->mGood && $wgDBname == 'enwiki' ) {
+ $good = $dbw->selectField( 'site_stats', 'ss_good_articles', '', $fname );
+ error_log( $good . ' ' . $wgTitle->getPrefixedDBkey() . "\n", 3, '/home/wikipedia/logs/million.log' );
+ }
+ */
}
}
?>
function wfSpecialExport( $page = '' ) {
global $wgOut, $wgRequest, $wgExportAllowListContributors;
global $wgExportAllowHistory, $wgExportMaxHistory;
- $maxLimit = 200;
$curonly = true;
$fullHistory = array(
'dir' => 'asc',
'offset' => false,
- 'limit' => $maxLimit,
+ 'limit' => $wgExportMaxHistory,
);
if( $wgRequest->wasPosted() ) {
$page = $wgRequest->getText( 'pages' );
$history = array(
'dir' => 'asc',
'offset' => false,
- 'limit' => $maxLimit,
+ 'limit' => $wgExportMaxHistory,
);
$historyCheck = $wgRequest->getCheck( 'history' );
if ( $curonly ) {
$history = MW_EXPORT_CURRENT;
} elseif ( !$historyCheck ) {
- if ( $limit > 0 && $limit < $maxLimit ) {
+ if ( $limit > 0 && $limit < $wgExportMaxHistory ) {
$history['limit'] = $limit;
}
if ( !is_null( $offset ) ) {
$exporter->openStream();
foreach( $pages as $page ) {
+ /*
if( $wgExportMaxHistory && !$curonly ) {
$title = Title::newFromText( $page );
if( $title ) {
continue;
}
}
- }
+ }*/
$exporter->pageByName( $page );
}
$dm = $wgContLang->getDirMark();
$title = Title::makeTitleSafe( $result->namespace, $result->title );
+ if ( !$title ) {
+ return '<!-- Invalid title ' . htmlspecialchars( "{$result->namespace}:{$result->title}" ). '-->';
+ }
$hlink = $skin->makeKnownLinkObj( $title, wfMsgHtml( 'hist' ), 'action=history' );
$plink = $this->isCached()
? $skin->makeLinkObj( $title )
$stat = @stat( $fname );
if ( !$stat ) {
header( 'HTTP/1.0 404 Not Found' );
+ $encFile = htmlspecialchars( $fname );
+ $encScript = htmlspecialchars( $_SERVER['SCRIPT_NAME'] );
echo "<html><body>
<h1>File not found</h1>
-<p>Although this PHP script ({$_SERVER['SCRIPT_NAME']}) exists, the file requested for output
-does not.</p>
+<p>Although this PHP script ($encScript) exists, the file requested for output
+($encFile) does not.</p>
</body></html>";
return;
}
*/
function doUpdates ( &$updates ) {
wfProfileIn( 'MediaWiki::doUpdates' );
+ $dbw =& wfGetDB( DB_MASTER );
foreach( $updates as $up ) {
$up->doUpdate();
+
+ # Commit after every update to prevent lock contention
+ if ( $dbw->trxLevel() ) {
+ $dbw->commit();
+ }
}
wfProfileOut( 'MediaWiki::doUpdates' );
}
print "Initialising tables\n";
dbsource( "$maintenance/tables.sql", $dbw );
dbsource( "$IP/extensions/OAI/update_table.sql", $dbw );
+ dbsource( "$IP/extensions/AntiSpoof/mysql/patch-antispoof.sql", $dbw );
$dbw->query( "INSERT INTO site_stats(ss_row_id) VALUES (1)" );
# Initialise external storage
- if ( $wgDefaultExternalStore && preg_match( '!^DB://(.*)$!', $wgDefaultExternalStore, $m ) ) {
- print "Initialising external storage...\n";
+ if ( is_array( $wgDefaultExternalStore ) ) {
+ $stores = $wgDefaultExternalStore;
+ } elseif ( $stores ) {
+ $stores = array( $wgDefaultExternalStore );
+ } else {
+ $stores = array();
+ }
+ if ( count( $stores ) ) {
require_once( 'ExternalStoreDB.php' );
+ print "Initialising external storage $store...\n";
global $wgDBuser, $wgDBpassword, $wgExternalServers;
- $cluster = $m[1];
-
- # Hack
- $wgExternalServers[$cluster][0]['user'] = $wgDBuser;
- $wgExternalServers[$cluster][0]['password'] = $wgDBpassword;
-
- $store = new ExternalStoreDB;
- $extdb =& $store->getMaster( $cluster );
- $extdb->query( "SET table_type=InnoDB" );
- $extdb->query( "CREATE DATABASE $dbName" );
- $extdb->selectDB( $dbName );
- dbsource( "$maintenance/storage/blobs.sql", $extdb );
- $extdb->immediateCommit();
+ foreach ( $stores as $storeURL ) {
+ if ( !preg_match( '!^DB://(.*)$!', $storeURL, $m ) ) {
+ continue;
+ }
+
+ $cluster = $m[1];
+
+ # Hack
+ $wgExternalServers[$cluster][0]['user'] = $wgDBuser;
+ $wgExternalServers[$cluster][0]['password'] = $wgDBpassword;
+
+ $store = new ExternalStoreDB;
+ $extdb =& $store->getMaster( $cluster );
+ $extdb->query( "SET table_type=InnoDB" );
+ $extdb->query( "CREATE DATABASE $dbName" );
+ $extdb->selectDB( $dbName );
+ dbsource( "$maintenance/storage/blobs.sql", $extdb );
+ $extdb->immediateCommit();
+ }
}
$wgTitle = Title::newMainPage();
fclose( $file );
print "Sourcing interwiki SQL\n";
dbsource( $tempname, $dbw );
- unlink( $tempname );
+ #unlink( $tempname );
+
+ # Create the upload dir
+ global $wgUploadDirectory;
+ if( file_exists( $wgUploadDirectory ) ) {
+ echo "$wgUploadDirectory already exists.\n";
+ } else {
+ echo "Creating $wgUploadDirectory...\n";
+ mkdir( $wgUploadDirectory, 0777 );
+ chmod( $wgUploadDirectory, 0777 );
+ }
print "Script ended. You now want to run sync-common-all to publish *dblist files (check them for duplicates first)\n";
}
} else {
$art = new Article( $page );
}
- $art->doDelete( $reason );
+ $success = $art->doDeleteArticle( $reason );
$dbw->immediateCommit();
- print "\n";
+ if ( $success ) {
+ print "\n";
+ } else {
+ print " FAILED\n";
+ }
if ( $interval ) {
sleep( $interval );
'wikinews' => new Site( 'wikinews', 'n', 'wikinews.org' ),
'wikisource' => new Site( 'wikisource', 's', 'wikisource.org' ),
'wikimedia' => new Site( 'wikimedia', 'chapter', 'wikimedia.org' ),
+ 'wikiversity' => new Site( 'wikiversity', 'v', 'wikiversity.org' ),
);
# List of language prefixes likely to be found in multi-language sites
require_once('commandLine.inc');
+function microtime_float()
+{
+ list($usec, $sec) = explode(" ", microtime());
+ return ((float)$usec + (float)$sec);
+}
+
+
#$wgDebugLogFile = '/dev/stdout';
if ( isset( $args[0] ) ) {
print "set: $set incr: $incr get: $get time: $exectime\n";
}
-function microtime_float()
-{
- list($usec, $sec) = explode(" ", microtime());
- return ((float)$usec + (float)$sec);
-}
-
?>
foreach( $hosts as $host ) {
print "--\n-- $host\n--\n\n-- wikiuser\n\n";
print "GRANT REPLICATION CLIENT,PROCESS ON *.* TO 'wikiuser'@'$host' IDENTIFIED BY '$wikiuser_pass';\n";
- print "GRANT ALL PRIVILEGES ON `boardvote`.* TO 'wikiuser'@'$host' IDENTIFIED BY '$wikiuser_pass';\n";
- print "GRANT ALL PRIVILEGES ON `boardvote2005`.* TO 'wikiuser'@'$host' IDENTIFIED BY '$wikiuser_pass';\n";
+ print "GRANT ALL PRIVILEGES ON `boardvote%`.* TO 'wikiuser'@'$host' IDENTIFIED BY '$wikiuser_pass';\n";
foreach( $databases as $db ) {
print "GRANT SELECT, INSERT, UPDATE, DELETE ON `$db`.* TO 'wikiuser'@'$host' IDENTIFIED BY '$wikiuser_pass';\n";
}
print "\n-- wikiadmin\n\n";
print "GRANT PROCESS, REPLICATION CLIENT ON *.* TO 'wikiadmin'@'$host' IDENTIFIED BY '$wikiadmin_pass';\n";
- print "GRANT ALL PRIVILEGES ON `boardvote`.* TO wikiadmin@'$host' IDENTIFIED BY '$wikiadmin_pass';\n";
- print "GRANT ALL PRIVILEGES ON `boardvote2005`.* TO wikiadmin@'$host' IDENTIFIED BY '$wikiadmin_pass';\n";
+ print "GRANT ALL PRIVILEGES ON `boardvote%`.* TO wikiadmin@'$host' IDENTIFIED BY '$wikiadmin_pass';\n";
foreach ( $databases as $db ) {
print "GRANT ALL PRIVILEGES ON `$db`.* TO wikiadmin@'$host' IDENTIFIED BY '$wikiadmin_pass';\n";
}
<?php
+$optionsWithArgs = array( 'maxjobs' );
+$wgUseNormalUser = true;
require_once( 'commandLine.inc' );
require_once( "$IP/includes/JobQueue.php" );
require_once( "$IP/includes/FakeTitle.php" );
+if ( isset( $options['maxjobs'] ) ) {
+ $maxJobs = $options['maxjobs'];
+} else {
+ $maxJobs = 10000;
+}
+
// Trigger errors on inappropriate use of $wgTitle
$wgTitle = new FakeTitle;
$dbw =& wfGetDB( DB_MASTER );
+$n = 0;
while ( $dbw->selectField( 'job', 'count(*)', '', 'runJobs.php' ) ) {
while ( false != ($job = Job::pop()) ) {
wfWaitForSlaves( 5 );
if ( !$job->run() ) {
print "Error: {$job->error}\n";
}
+ if ( $maxJobs && ++$n > $maxJobs ) {
+ break 2;
+ }
}
}
?>
$titleObj = Title::makeTitle( $pageRow->page_namespace, $pageRow->page_title );
print "$pageId\t" . $titleObj->getPrefixedDBkey() . " ";
+ print_r(
+ 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
+ );
+ exit;
+
# Load revisions
$revRes = $dbw->select( $tables, $fields,
array(
<?php
+$wgNoDBParam = true;
$optionsWithArgs = array( 'o' );
require_once( dirname(__FILE__).'/../maintenance/commandLine.inc' );
require_once( dirname(__FILE__).'/serialize.php' );
<?php
if ( !defined( 'MEDIAWIKI' ) ) {
+ $wgNoDBParam = true;
$optionsWithArgs = array( 'o' );
require_once( dirname(__FILE__).'/../maintenance/commandLine.inc' );
$thumb = false;
}
-if ( $thumb && $thumb->path ) {
+if ( $img->lastError && $img->lastError !== true ) {
+ header( 'HTTP/1.0 500 Internal Server Error' );
+ echo "<html><body><h1>Thumbnail generation error</h1><p>" .
+ htmlspecialchars( $img->lastError ) . "<br>" . wfHostname() .
+ "</p></body></html>";
+} elseif ( $thumb && $thumb->path ) {
wfStreamFile( $thumb->path );
} else {
$badtitle = wfMsg( 'badtitle' );