r62582 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62581‎ | r62582 | r62583 >
Date:12:12, 16 February 2010
Author:maxsem
Status:deferred (Comments)
Tags:
Comment:
Switched tests to portable table duplication
Modified paths:
  • /trunk/phase3/maintenance/tests/MediaWiki_Setup.php (modified) (history)
  • /trunk/phase3/maintenance/tests/SearchMySQLTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/tests/SearchMySQLTest.php
@@ -7,7 +7,7 @@
88 function setUp() {
99 $GLOBALS['wgContLang'] = new Language;
1010 $this->db = $this->buildTestDatabase(
11 - array( 'page', 'revision', 'text', 'searchindex' ) );
 11+ array( 'page', 'revision', 'text', 'searchindex', 'user' ) );
1212 if( $this->db ) {
1313 $this->insertSearchData();
1414 }
Index: trunk/phase3/maintenance/tests/MediaWiki_Setup.php
@@ -12,31 +12,11 @@
1313 $db->tablePrefix( 'parsertest_' );
1414
1515 if( $db->isOpen() ) {
16 - if ( !( strcmp( $db->getServerVersion(), '4.1' ) < 0 and $db->getType() == 'mysql' ) ) {
17 - # Database that supports CREATE TABLE ... LIKE
18 - foreach ( $tables as $tbl ) {
19 - $newTableName = $db->tableName( $tbl );
20 - $tableName = $oldTableNames[$tbl];
21 - $db->query( "CREATE TEMPORARY TABLE $newTableName (LIKE $tableName)" );
22 - }
23 - } else {
24 - # Hack for MySQL versions < 4.1, which don't support
25 - # "CREATE TABLE ... LIKE". Note that
26 - # "CREATE TEMPORARY TABLE ... SELECT * FROM ... LIMIT 0"
27 - # would not create the indexes we need....
28 - foreach ( $tables as $tbl ) {
29 - $res = $db->query( "SHOW CREATE TABLE $tbl" );
30 - $row = $db->fetchRow($res);
31 - $create = $row[1];
32 - $create_tmp = preg_replace( '/CREATE TABLE `(.*?)`/', 'CREATE TEMPORARY TABLE `'
33 - . $wgDBprefix . '\\1`', $create );
34 - if ($create === $create_tmp) {
35 - # Couldn't do replacement
36 - wfDie( "could not create temporary table $tbl" );
37 - }
38 - $db->query( $create_tmp );
39 - }
40 -
 16+ foreach ( $tables as $tbl ) {
 17+ $newTableName = $db->tableName( $tbl );
 18+ $tableName = $oldTableNames[$tbl];
 19+ $db->query( "DROP TABLE IF EXISTS $newTableName", __METHOD__ );
 20+ $db->duplicateTableStructure( $tableName, $newTableName, __METHOD__ );
4121 }
4222 return $db;
4323 } else {

Comments

#Comment by MaxSem (talk | contribs)   12:14, 16 February 2010

The change to SearchMySQLTest was committed prematurely, I'll commit code that uses it a bit later.

Status & tagging log