Various live patches ported from REL1_4
authorTim Starling <tstarling@users.mediawiki.org>
Tue, 12 Apr 2005 04:03:21 +0000 (04:03 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Tue, 12 Apr 2005 04:03:21 +0000 (04:03 +0000)
includes/Database.php
includes/Defines.php
includes/Image.php
includes/Math.php
includes/Parser.php
includes/Title.php
maintenance/InitialiseMessages.inc
maintenance/commandLine.inc
maintenance/eval.php
maintenance/ourusers.php

index 7c38b0f..458d054 100644 (file)
@@ -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" .
index c5e16a6..84770d3 100644 (file)
@@ -12,6 +12,7 @@ define( 'DBO_NOBUFFER', 2 );
 define( 'DBO_IGNORE', 4 );
 define( 'DBO_TRX', 8 );
 define( 'DBO_DEFAULT', 16 );
+define( 'DBO_PERSISTENT', 32 );
 /**#@-*/
 
 /**#@+
index cb94ca8..7d353a5 100644 (file)
@@ -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
index ac5d569..3506394 100644 (file)
@@ -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' ) 
+                               );
+                       }
                        
                }
                
index e517d57..d5ddd25 100644 (file)
@@ -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 ) {
index 7e61e2c..eb79258 100644 (file)
@@ -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', 
index ffa43b9..3976d18 100755 (executable)
@@ -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';
index 8c25f3c..86f0731 100644 (file)
@@ -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";
index 9ef4958..ec09bc8 100755 (executable)
  * @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";
 
 ?>
index d8f0244..f603e1f 100644 (file)
@@ -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 ) {