From b1a49e2d5b5b28ee0f6731ab59d0cb06c4761eb0 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 26 Aug 2005 23:02:54 +0000 Subject: [PATCH] Drop MySQL 3.23.x support; 4.0 or greater required. --- RELEASE-NOTES | 5 +++ config/index.php | 14 +++---- includes/Block.php | 6 +-- includes/Database.php | 5 +-- includes/DefaultSettings.php | 5 ++- includes/SearchEngine.php | 11 ++--- includes/SearchMySQL3.php | 81 ------------------------------------ maintenance/refreshLinks.inc | 24 +---------- tests/RunTests.php | 6 --- tests/SearchMySQL3Test.php | 34 --------------- 10 files changed, 22 insertions(+), 169 deletions(-) delete mode 100644 includes/SearchMySQL3.php delete mode 100644 tests/SearchMySQL3Test.php diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 2cf2b3706e..254118725a 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -7,6 +7,10 @@ setting since version 1.2.0. If you have it on, turn it *off* if you can. Misc work going on..... +Big things to note: +* MySQL 3.23.x is no longer supported. + + == Changes since 1.5 == * please fill in for the last couple weeks @@ -58,6 +62,7 @@ fully support the editing toolbar, but was found to be too confusing. * (bug 3271) Updated LanguageNn.php for HEAD * (bug 3280) Respect 'move' group permission on page moves * (bug 2613) Clear saved passwords from the form +* Finally dropped MySQL 3.23.x support === Caveats === diff --git a/config/index.php b/config/index.php index 8952fce936..d9da0f7136 100644 --- a/config/index.php +++ b/config/index.php @@ -552,10 +552,8 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) { } print "
  • Connected to $myver"; - if( version_compare( $myver, "4.0.0" ) >= 0 ) { - print "; enabling MySQL 4 enhancements"; - $conf->DBmysql4 = true; - $local = writeLocalSettings( $conf ); + if( version_compare( $myver, "4.0.0" ) < 0 ) { + die( " -- mysql 4.0 or later required. Aborting." ); } $mysqlNewAuth = version_compare( $myver, "4.1.0", "ge" ); if( $mysqlNewAuth && $mysqlOldClient ) { @@ -1043,7 +1041,6 @@ function escapePhpString( $string ) { } function writeLocalSettings( $conf ) { - $conf->DBmysql4 = @$conf->DBmysql4 ? 'true' : 'false'; $conf->UseImageResize = $conf->UseImageResize ? 'true' : 'false'; $conf->PasswordSender = $conf->EmergencyContact; $zlib = ($conf->zlib ? "" : "# "); @@ -1118,6 +1115,10 @@ function writeLocalSettings( $conf ) { # This file was automatically generated by the MediaWiki installer. # If you make manual changes, please keep track in case you need to # recreate them later. +# +# See includes/DefaultSettings.php for all configurable settings +# and their default values, but don't forget to make changes in _this_ +# file, not there. \$IP = \"{$slconf['IP']}\"; ini_set( \"include_path\", \".$sep\$IP$sep\$IP/includes$sep\$IP/languages\" ); @@ -1174,9 +1175,6 @@ if ( \$wgCommandLineMode ) { \$wgDBprefix = \"{$slconf['DBprefix']}\"; \$wgDBtype = \"{$slconf['DBtype']}\"; -# If you're on MySQL 3.x, this next line must be FALSE: -\$wgDBmysql4 = {$conf->DBmysql4}; - ## Shared memory settings \$wgMainCacheType = $cacheType; \$wgMemCachedServers = $mcservers; diff --git a/includes/Block.php b/includes/Block.php index 721b1f7fa3..f8f01864fb 100644 --- a/includes/Block.php +++ b/includes/Block.php @@ -67,7 +67,7 @@ class Block */ function load( $address = '', $user = 0, $killExpired = true ) { - global $wgDBmysql4, $wgAntiLockFlags; + global $wgAntiLockFlags; $fname = 'Block::load'; wfDebug( "Block::load: '$address', '$user', $killExpired\n" ); @@ -92,8 +92,8 @@ class Block $sql = "SELECT * FROM $ipblocks WHERE ipb_user={$user} $options"; } elseif ($user=="") { $sql = "SELECT * FROM $ipblocks WHERE ipb_address='" . $db->strencode( $address ) . "' $options"; - } elseif ( $options=='' && $wgDBmysql4 ) { - # If there are no optiones (e.g. FOR UPDATE), use a UNION + } elseif ( $options=='' ) { + # If there are no options (e.g. FOR UPDATE), use a UNION # so that the query can make efficient use of indices $sql = "SELECT * FROM $ipblocks WHERE ipb_address='" . $db->strencode( $address ) . "' UNION SELECT * FROM $ipblocks WHERE ipb_user={$user}"; diff --git a/includes/Database.php b/includes/Database.php index 6f21171870..c4390cf4b7 100644 --- a/includes/Database.php +++ b/includes/Database.php @@ -1178,10 +1178,7 @@ class Database { * PostgreSQL doesn't have them and returns "" */ function useIndexClause( $index ) { - global $wgDBmysql4; - return $wgDBmysql4 - ? "FORCE INDEX ($index)" - : "USE INDEX ($index)"; + return "FORCE INDEX ($index)"; } /** diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index ab262c0ca0..4348041b46 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -447,8 +447,9 @@ $wgDBClusterTimeout = 10; $wgDBminWordLen = 4; /** Set to true if using InnoDB tables */ $wgDBtransactions = false; -/** Set to true to use enhanced fulltext search */ -$wgDBmysql4 = false; +/** Set to true for compatibility with extensions that might be checking. + * MySQL 3.23.x is no longer supported. */ +$wgDBmysql4 = true; /** * Other wikis on this site, can be administered from a single developer diff --git a/includes/SearchEngine.php b/includes/SearchEngine.php index abc4d58663..ee90ab7896 100644 --- a/includes/SearchEngine.php +++ b/includes/SearchEngine.php @@ -178,17 +178,12 @@ class SearchEngine { * @access private */ function create() { - global $wgDBtype, $wgDBmysql4, $wgSearchType; + global $wgDBtype, $wgSearchType; if( $wgSearchType ) { $class = $wgSearchType; } elseif( $wgDBtype == 'mysql' ) { - if( $wgDBmysql4 ) { - $class = 'SearchMySQL4'; - require_once( 'SearchMySQL4.php' ); - } else { - $class = 'SearchMysql3'; - require_once( 'SearchMySQL3.php' ); - } + $class = 'SearchMySQL4'; + require_once( 'SearchMySQL4.php' ); } else if ( $wgDBtype == 'PostgreSQL' ) { $class = 'SearchTsearch2'; require_once( 'SearchTsearch2.php' ); diff --git a/includes/SearchMySQL3.php b/includes/SearchMySQL3.php deleted file mode 100644 index 3636045187..0000000000 --- a/includes/SearchMySQL3.php +++ /dev/null @@ -1,81 +0,0 @@ - -# http://www.mediawiki.org/ -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# http://www.gnu.org/copyleft/gpl.html - -/** - * Search engine hook for MySQL 3.23.x - * @package MediaWiki - * @subpackage Search - */ - -/** */ -require_once( 'SearchMySQL.php' ); - -/** - * @package MediaWiki - * @subpackage Search - */ -class SearchMySQL3 extends SearchMySQL { - function SearchMySQL3( &$db ) { - $this->db =& $db; - } - - function parseQuery( $filteredText, $fulltext ) { - global $wgDBminWordLen, $wgContLang; - - $field = $this->getIndexField( $fulltext ); - - # on non mysql4 database: get list of words we don't want to search for - require_once( 'FulltextStoplist.php' ); - - $lc = SearchEngine::legalSearchChars() . '()'; - $q = preg_replace( "/([()])/", " \\1 ", $filteredText ); - $q = preg_replace( "/\\s+/", " ", $q ); - $w = explode( ' ', trim( $q ) ); - - $last = $cond = ''; - foreach ( $w as $word ) { - $word = $wgContLang->stripForSearch( $word ); - if ( 'and' == $word || 'or' == $word || 'not' == $word - || '(' == $word || ')' == $word ) { - $cond .= ' ' . strtoupper( $word ); - $last = ''; - } else if ( strlen( $word ) < $wgDBminWordLen ) { - continue; - } else if ( FulltextStoplist::inList( $word ) ) { - continue; - } else { - if ( '' != $last ) { $cond .= ' AND'; } - $cond .= " (MATCH ($field) AGAINST ('" . - $this->db->strencode( $word ). "'))"; - $last = $word; - $this->searchTerms[] = "\\b" . preg_quote( $word, '/' ) . "\\b"; - } - } - if ( 0 == count( $this->searchTerms ) ) { - # No searchable terms remaining. - # We have to return a term for the query or we get an SQL error. - return "0"; - } - - return '(' . $cond . ' )'; - } - -} - -?> diff --git a/maintenance/refreshLinks.inc b/maintenance/refreshLinks.inc index 355cf52002..73bfbdb590 100644 --- a/maintenance/refreshLinks.inc +++ b/maintenance/refreshLinks.inc @@ -124,29 +124,7 @@ function deleteLinksFromNonexistent( $maxLag = 0 ) { } $pTable = $dbw->tableName( $table ); - global $wgDBmysql4, $wgDBtype; - if( $wgDBmysql4 || $wgDBtype != 'mysql' ) { - $sql = "DELETE $pTable FROM $pTable LEFT JOIN $page ON page_id=$field WHERE page_id IS NULL"; - } else { - # Hack-around for MySQL 3.x, which lacks support - # for multi-table deletes. - - $sql = "SELECT DISTINCT $field AS id FROM $pTable LEFT JOIN $page ON page_id=$field WHERE page_id IS NULL"; - echo "Looking in $table from non-existent articles..."; - $result = $dbw->query( $sql ); - $ids = array(); - while( $row = $dbw->fetchObject( $result ) ) { - $ids[] = $row->id; - } - $dbw->freeResult( $result ); - - if( empty( $ids ) ) { - echo " none.\n"; - continue; - } - echo " found.\n"; - $sql = "DELETE FROM $pTable WHERE $field IN (" . implode( ",", $ids ) . ")"; - } + $sql = "DELETE $pTable FROM $pTable LEFT JOIN $page ON page_id=$field WHERE page_id IS NULL"; print "Deleting $table from non-existent articles..."; $dbw->query( $sql, $fname ); diff --git a/tests/RunTests.php b/tests/RunTests.php index 5291d935b6..81ed74ab93 100644 --- a/tests/RunTests.php +++ b/tests/RunTests.php @@ -10,11 +10,6 @@ define( "MEDIAWIKI", true ); require_once( 'PHPUnit.php' ); $testOptions = array( - 'mysql3' => array( - 'server' => null, - 'user' => null, - 'password' => null, - 'database' => null ), 'mysql4' => array( 'server' => null, 'user' => null, @@ -34,7 +29,6 @@ if( file_exists( 'LocalTestSettings.php' ) ) { $tests = array( 'GlobalTest', 'DatabaseTest', - 'SearchMySQL3Test', 'SearchMySQL4Test', 'ArticleTest', 'SanitizerTest', diff --git a/tests/SearchMySQL3Test.php b/tests/SearchMySQL3Test.php deleted file mode 100644 index 9767e1863f..0000000000 --- a/tests/SearchMySQL3Test.php +++ /dev/null @@ -1,34 +0,0 @@ -PHPUnit_TestCase( $name ); - } - - function setUp() { - $GLOBALS['wgContLang'] = new LanguageUtf8; - $this->db =& buildTestDatabase( - 'mysql3', - array( 'page', 'revision', 'text', 'searchindex' ) ); - if( $this->db ) { - $this->insertSearchData(); - } - $this->search =& new SearchMySQL3( $this->db ); - } - - function tearDown() { - if( !is_null( $this->db ) ) { - $this->db->close(); - } - unset( $this->db ); - unset( $this->search ); - } - -} - -?> \ No newline at end of file -- 2.20.1