Index: trunk/phase3/maintenance/parserTests.inc |
— | — | @@ -484,6 +484,7 @@ |
485 | 485 | throw new MWException( 'setupDatabase should be called before setupGlobals' ); |
486 | 486 | } |
487 | 487 | $this->databaseSetupDone = true; |
| 488 | + $this->oldTablePrefix = $wgDBprefix; |
488 | 489 | |
489 | 490 | # CREATE TEMPORARY TABLE breaks if there is more than one server |
490 | 491 | if ( wfGetLB()->getServerCount() != 1 ) { |
— | — | @@ -504,19 +505,28 @@ |
505 | 506 | $def = ''; |
506 | 507 | } |
507 | 508 | foreach ($tables as $tbl) { |
| 509 | + # Clean up from previous aborted run. So that table escaping |
| 510 | + # works correctly across DB engines, we need to change the pre- |
| 511 | + # fix back and forth so tableName() works right. |
| 512 | + $this->changePrefix( $this->oldTablePrefix ); |
508 | 513 | $oldTableName = $db->tableName( $tbl ); |
509 | | - # Clean up from previous aborted run |
510 | | - if ( $db->tableExists( "`parsertest_$tbl`" ) ) { |
511 | | - $db->query("DROP TABLE `parsertest_$tbl`"); |
| 514 | + $this->changePrefix( 'parsertest_' ); |
| 515 | + $newTableName = $db->tableName( $tbl ); |
| 516 | + |
| 517 | + if ( $db->tableExists( $tbl ) ) { |
| 518 | + $db->query("DROP TABLE $newTableName"); |
512 | 519 | } |
513 | 520 | # Create new table |
514 | | - $db->query("CREATE $temporary TABLE `parsertest_$tbl` (LIKE $oldTableName $def)"); |
| 521 | + $db->query("CREATE $temporary TABLE $newTableName (LIKE $oldTableName $def)"); |
515 | 522 | } |
516 | 523 | } else { |
517 | 524 | # Hack for MySQL versions < 4.1, which don't support |
518 | 525 | # "CREATE TABLE ... LIKE". Note that |
519 | 526 | # "CREATE TEMPORARY TABLE ... SELECT * FROM ... LIMIT 0" |
520 | 527 | # would not create the indexes we need.... |
| 528 | + # |
| 529 | + # Note that we don't bother changing around the prefixes here be- |
| 530 | + # cause we know we're using MySQL anyway. |
521 | 531 | foreach ($tables as $tbl) { |
522 | 532 | $oldTableName = $db->tableName( $tbl ); |
523 | 533 | $res = $db->query("SHOW CREATE TABLE $oldTableName"); |
— | — | @@ -532,9 +542,11 @@ |
533 | 543 | } |
534 | 544 | } |
535 | 545 | |
| 546 | + $this->changePrefix( 'parsertest_' ); |
| 547 | + |
536 | 548 | # Hack: insert a few Wikipedia in-project interwiki prefixes, |
537 | 549 | # for testing inter-language links |
538 | | - $db->insert( '`parsertest_interwiki`', array( |
| 550 | + $db->insert( 'interwiki', array( |
539 | 551 | array( 'iw_prefix' => 'Wikipedia', |
540 | 552 | 'iw_url' => 'http://en.wikipedia.org/wiki/$1', |
541 | 553 | 'iw_local' => 0 ), |
— | — | @@ -556,7 +568,7 @@ |
557 | 569 | ) ); |
558 | 570 | |
559 | 571 | # Hack: Insert an image to work with |
560 | | - $db->insert( '`parsertest_image`', array( |
| 572 | + $db->insert( 'image', array( |
561 | 573 | 'img_name' => 'Foobar.jpg', |
562 | 574 | 'img_size' => 12345, |
563 | 575 | 'img_description' => 'Some lame file', |
— | — | @@ -573,11 +585,7 @@ |
574 | 586 | ) ); |
575 | 587 | |
576 | 588 | # Update certain things in site_stats |
577 | | - $db->insert( '`parsertest_site_stats`', array( 'ss_row_id' => 1, 'ss_images' => 1, 'ss_good_articles' => 1 ) ); |
578 | | - |
579 | | - # Change the table prefix |
580 | | - $this->oldTablePrefix = $wgDBprefix; |
581 | | - $this->changePrefix( 'parsertest_' ); |
| 589 | + $db->insert( 'site_stats', array( 'ss_row_id' => 1, 'ss_images' => 1, 'ss_good_articles' => 1 ) ); |
582 | 590 | } |
583 | 591 | |
584 | 592 | /** |