From cdb3f96ab8f00a5e27a7333731e862d6896c989d Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Tue, 12 Apr 2005 04:03:21 +0000 Subject: [PATCH] Various live patches ported from REL1_4 --- includes/Database.php | 16 ++++++++++++++-- includes/Defines.php | 1 + includes/Image.php | 19 +++++++++++++++++++ includes/Math.php | 28 +++++++++++++++------------- includes/Parser.php | 27 +++++++++++++++------------ includes/Title.php | 6 +++++- maintenance/InitialiseMessages.inc | 2 +- maintenance/commandLine.inc | 2 +- maintenance/eval.php | 12 +++++++++--- maintenance/ourusers.php | 6 +++++- 10 files changed, 85 insertions(+), 34 deletions(-) diff --git a/includes/Database.php b/includes/Database.php index 7c38b0fc0d..458d054407 100644 --- a/includes/Database.php +++ b/includes/Database.php @@ -148,6 +148,13 @@ class Database { $this->mFlags |= DBO_TRX; } } + + /* + // Faster read-only access + if ( wfReadOnly() ) { + $this->mFlags |= DBO_PERSISTENT; + $this->mFlags &= ~DBO_TRX; + }*/ /** Get the default table prefix*/ if ( $tablePrefix == 'get from global' ) { @@ -196,7 +203,12 @@ class Database { $success = false; - @/**/$this->mConn = mysql_connect( $server, $user, $password ); + if ( $this->mFlags & DBO_PERSISTENT ) { + @/**/$this->mConn = mysql_pconnect( $server, $user, $password ); + } else { + @/**/$this->mConn = mysql_connect( $server, $user, $password ); + } + if ( $dbName != '' ) { if ( $this->mConn !== false ) { $success = @/**/mysql_select_db( $dbName, $this->mConn ); @@ -333,7 +345,7 @@ class Database { wfDebug("SQL ERROR (ignored): " . $error . "\n"); } else { $sql1line = str_replace( "\n", "\\n", $sql ); - wfLogDBError("$fname\t$errno\t$error\t$sql1line\n"); + wfLogDBError("$fname\t{$this->mServer}\t$errno\t$error\t$sql1line\n"); wfDebug("SQL ERROR: " . $error . "\n"); if ( $wgCommandLineMode || !$this->mOut || empty( $wgFullyInitialised ) ) { $message = "A database error has occurred\n" . diff --git a/includes/Defines.php b/includes/Defines.php index c5e16a64a3..84770d3433 100644 --- a/includes/Defines.php +++ b/includes/Defines.php @@ -12,6 +12,7 @@ define( 'DBO_NOBUFFER', 2 ); define( 'DBO_IGNORE', 4 ); define( 'DBO_TRX', 8 ); define( 'DBO_DEFAULT', 16 ); +define( 'DBO_PERSISTENT', 32 ); /**#@-*/ /**#@+ diff --git a/includes/Image.php b/includes/Image.php index cb94ca8793..7d353a5ecb 100644 --- a/includes/Image.php +++ b/includes/Image.php @@ -1060,6 +1060,25 @@ function wfGetSVGsize( $filename ) { "width=\"$width\" height=\"$height\"" ); } +/** + * Is an image on the bad image list? + */ +function wfIsBadImage( $name ) { + global $wgLang; + + $lines = explode("\n", wfMsgForContent( 'bad_image_list' )); + foreach ( $lines as $line ) { + if ( preg_match( '/^\*\s*\[\[:(' . $wgLang->getNsText( NS_IMAGE ) . ':[^\]]*)\]\]/', $line, $m ) ) { + $t = Title::newFromText( $m[1] ); + if ( $t->getDBkey() == $name ) { + return true; + } + } + } + return false; +} + + /** * Wrapper class for thumbnail images diff --git a/includes/Math.php b/includes/Math.php index ac5d5699cb..3506394ab9 100644 --- a/includes/Math.php +++ b/includes/Math.php @@ -123,20 +123,22 @@ class MathRenderer { } # Now save it back to the DB: - $outmd5_sql = pack('H32', $this->hash); - - $md5_sql = pack('H32', $this->md5); # Binary packed, not hex + if ( !wfReadOnly() ) { + $outmd5_sql = pack('H32', $this->hash); - $dbw =& wfGetDB( DB_MASTER ); - $dbw->replace( 'math', array( 'math_inputhash' ), - array( - 'math_inputhash' => $md5_sql, - 'math_outputhash' => $outmd5_sql, - 'math_html_conservativeness' => $this->conservativeness, - 'math_html' => $this->html, - 'math_mathml' => $this->mathml, - ), $fname, array( 'IGNORE' ) - ); + $md5_sql = pack('H32', $this->md5); # Binary packed, not hex + + $dbw =& wfGetDB( DB_MASTER ); + $dbw->replace( 'math', array( 'math_inputhash' ), + array( + 'math_inputhash' => $md5_sql, + 'math_outputhash' => $outmd5_sql, + 'math_html_conservativeness' => $this->conservativeness, + 'math_html' => $this->html, + 'math_mathml' => $this->mathml, + ), $fname, array( 'IGNORE' ) + ); + } } diff --git a/includes/Parser.php b/includes/Parser.php index e517d570a2..d5ddd25551 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -1254,19 +1254,22 @@ class Parser if ( $ns == NS_IMAGE ) { wfProfileIn( "$fname-image" ); - - # recursively parse links inside the image caption - # actually, this will parse them in any other parameters, too, - # but it might be hard to fix that, and it doesn't matter ATM - $text = $this->replaceExternalLinks($text); - $text = $this->replaceInternalLinks($text); - - # cloak any absolute URLs inside the image markup, so replaceExternalLinks() won't touch them - $s .= $prefix . str_replace('http://', 'http-noparse://', $sk->makeImageLinkObj( $nt, $text ) ) . $trail; - $wgLinkCache->addImageLinkObj( $nt ); - + if ( !wfIsBadImage( $nt->getDBkey() ) ) { + # recursively parse links inside the image caption + # actually, this will parse them in any other parameters, too, + # but it might be hard to fix that, and it doesn't matter ATM + $text = $this->replaceExternalLinks($text); + $text = $this->replaceInternalLinks($text); + + # cloak any absolute URLs inside the image markup, so replaceExternalLinks() won't touch them + $s .= $prefix . str_replace('http://', 'http-noparse://', $sk->makeImageLinkObj( $nt, $text ) ) . $trail; + $wgLinkCache->addImageLinkObj( $nt ); + + wfProfileOut( "$fname-image" ); + continue; + } wfProfileOut( "$fname-image" ); - continue; + } if ( $ns == NS_CATEGORY ) { diff --git a/includes/Title.php b/includes/Title.php index 7e61e2c792..eb79258121 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -823,7 +823,7 @@ class Title { function userCan($action) { $fname = 'Title::userCanEdit'; wfProfileIn( $fname ); - + global $wgUser; if( NS_SPECIAL == $this->mNamespace ) { wfProfileOut( $fname ); @@ -1073,6 +1073,10 @@ class Title { * @access public */ function invalidateCache() { + if ( wfReadOnly() ) { + return; + } + $now = wfTimestampNow(); $dbw =& wfGetDB( DB_MASTER ); $success = $dbw->update( 'page', diff --git a/maintenance/InitialiseMessages.inc b/maintenance/InitialiseMessages.inc index ffa43b91f1..3976d1864d 100755 --- a/maintenance/InitialiseMessages.inc +++ b/maintenance/InitialiseMessages.inc @@ -144,7 +144,7 @@ function initialiseMessagesReal( $overwrite = false, $messageArray = false ) { # Decide whether or not each one needs to be overwritten $existingTitles = array(); while ( $row ) { - if ( $row->rev_user_text != $username ) { + if ( $row->rev_user_text != $username && $row->rev_user_text != 'Template namespace initialisation script' ) { $existingTitles[$row->page_title] = 'keep'; } else { $existingTitles[$row->page_title] = 'chuck'; diff --git a/maintenance/commandLine.inc b/maintenance/commandLine.inc index 8c25f3cf33..86f0731840 100644 --- a/maintenance/commandLine.inc +++ b/maintenance/commandLine.inc @@ -114,7 +114,7 @@ if ( $sep == ":" && strpos( `hostname`, "wikimedia.org" ) !== false ) { ini_set( "include_path", ".:$IP:$IP/includes:$IP/languages:$IP/maintenance" ); require_once( "$IP/includes/Defines.php" ); - require_once( "/home/wikipedia/common/php-new/CommonSettings.php" ); + require_once( "/home/wikipedia/common/php-1.4/CommonSettings.php" ); } else { $wgWikiFarm = false; $settingsFile = "$IP/LocalSettings.php"; diff --git a/maintenance/eval.php b/maintenance/eval.php index 9ef4958fbf..ec09bc85bd 100755 --- a/maintenance/eval.php +++ b/maintenance/eval.php @@ -16,11 +16,14 @@ * @subpackage Maintenance */ +$wgForceLoadBalancing = (getenv('MW_BALANCE') ? true : false); + /** */ require_once( "commandLine.inc" ); -do { - $line = readconsole( "> " ); +$line = readconsole( "> " ); + +while ( $line !== false ) { $val = eval( $line . ";" ); if( is_null( $val ) ) { echo "\n"; @@ -32,6 +35,9 @@ do { if ( function_exists( "readline_add_history" ) ) { readline_add_history( $line ); } -} while ( 1 ); + $line = readconsole( "> " ); +} + +print "\n"; ?> diff --git a/maintenance/ourusers.php b/maintenance/ourusers.php index d8f0244f91..f603e1f13c 100644 --- a/maintenance/ourusers.php +++ b/maintenance/ourusers.php @@ -34,7 +34,8 @@ $hosts = array( '207.142.131.244', '207.142.131.249', '207.142.131.250', - + '207.142.131.216', + '10.0.%', ); $databases = array( @@ -43,6 +44,9 @@ $databases = array( '%wikiquote', '%wiktionary', '%wikisource', + '%wikinews', + '%wikiversity', + '%wikimedia', ); foreach( $hosts as $host ) { -- 2.20.1