Index: trunk/phase3/tests/phpunit/MediaWikiTestCase.php |
— | — | @@ -12,24 +12,33 @@ |
13 | 13 | protected $useTemporaryTables = true; |
14 | 14 | |
15 | 15 | function __construct( $name = null, array $data = array(), $dataName = '' ) { |
16 | | - if ($name !== null) { |
17 | | - $this->setName($name); |
18 | | - } |
| 16 | + if ($name !== null) { |
| 17 | + $this->setName($name); |
| 18 | + } |
19 | 19 | |
20 | | - $this->data = $data; |
21 | | - $this->dataName = $dataName; |
| 20 | + $this->data = $data; |
| 21 | + $this->dataName = $dataName; |
22 | 22 | } |
23 | 23 | |
24 | 24 | function run( PHPUnit_Framework_TestResult $result = NULL ) { |
25 | | - if( $this->needsDB() && !is_object( $this->dbClone ) ) { |
| 25 | + |
| 26 | + if( $this->needsDB() ) { |
| 27 | + |
| 28 | + $this->destroyDBCheck(); |
| 29 | + |
26 | 30 | $this->initDB(); |
27 | 31 | $this->addCoreDBData(); |
28 | 32 | $this->addDBData(); |
29 | 33 | } |
| 34 | + |
30 | 35 | parent::run( $result ); |
31 | 36 | } |
| 37 | + |
| 38 | + function __destruct() { |
| 39 | + $this->destroyDBCheck(); |
| 40 | + } |
32 | 41 | |
33 | | - function __destruct() { |
| 42 | + function destroyDBCheck() { |
34 | 43 | if( is_object( $this->dbClone ) && $this->dbClone instanceof CloneDatabase ) { |
35 | 44 | $this->destroyDB(); |
36 | 45 | } |
— | — | @@ -110,8 +119,8 @@ |
111 | 120 | |
112 | 121 | # Anonymous user |
113 | 122 | $this->db->insert( 'user', array( |
114 | | - 'user_id' => 0, |
115 | | - 'user_name' => 'Anonymous' ) ); |
| 123 | + 'user_id' => 0, |
| 124 | + 'user_name' => 'Anonymous' ) ); |
116 | 125 | } |
117 | 126 | |
118 | 127 | } |
Index: trunk/phase3/includes/GlobalFunctions.php |
— | — | @@ -1287,10 +1287,11 @@ |
1288 | 1288 | /** |
1289 | 1289 | * Sets dest to source and returns the original value of dest |
1290 | 1290 | * If source is NULL, it just returns the value, it doesn't set the variable |
| 1291 | + * If force is true, it will set the value even if source is NULL |
1291 | 1292 | */ |
1292 | | -function wfSetVar( &$dest, $source ) { |
| 1293 | +function wfSetVar( &$dest, $source, $force = false ) { |
1293 | 1294 | $temp = $dest; |
1294 | | - if ( !is_null( $source ) ) { |
| 1295 | + if ( !is_null( $source ) || $force ) { |
1295 | 1296 | $dest = $source; |
1296 | 1297 | } |
1297 | 1298 | return $temp; |
Index: trunk/phase3/includes/db/Database.php |
— | — | @@ -288,7 +288,7 @@ |
289 | 289 | } |
290 | 290 | |
291 | 291 | function tablePrefix( $prefix = null ) { |
292 | | - return wfSetVar( $this->mTablePrefix, $prefix ); |
| 292 | + return wfSetVar( $this->mTablePrefix, $prefix, true ); |
293 | 293 | } |
294 | 294 | |
295 | 295 | /** |
Index: trunk/phase3/includes/db/CloneDatabase.php |
— | — | @@ -85,12 +85,16 @@ |
86 | 86 | * Clone the table structure |
87 | 87 | */ |
88 | 88 | public function cloneTableStructure() { |
| 89 | + |
| 90 | + sort($this->tablesToClone); |
| 91 | + |
89 | 92 | foreach( $this->tablesToClone as $tbl ) { |
90 | 93 | # Clean up from previous aborted run. So that table escaping |
91 | 94 | # works correctly across DB engines, we need to change the pre- |
92 | 95 | # fix back and forth so tableName() works right. |
93 | 96 | $this->changePrefix( $this->oldTablePrefix ); |
94 | 97 | $oldTableName = $this->db->tableName( $tbl ); |
| 98 | + |
95 | 99 | $this->changePrefix( $this->newTablePrefix ); |
96 | 100 | $newTableName = $this->db->tableName( $tbl ); |
97 | 101 | |
— | — | @@ -99,7 +103,9 @@ |
100 | 104 | } |
101 | 105 | |
102 | 106 | # Create new table |
| 107 | + wfDebug( "Duplicating $oldTableName to $newTableName\n", __METHOD__ ); |
103 | 108 | $this->db->duplicateTableStructure( $oldTableName, $newTableName, $this->useTemporaryTables ); |
| 109 | + |
104 | 110 | } |
105 | 111 | } |
106 | 112 | |
Index: trunk/phase3/includes/db/DatabaseSqlite.php |
— | — | @@ -629,8 +629,11 @@ |
630 | 630 | $vars = get_object_vars($table); |
631 | 631 | $table = array_pop( $vars ); |
632 | 632 | |
633 | | - if( empty( $prefix ) || strpos( $table, $prefix ) === 0 ) { |
634 | | - $endArray[] = $table; |
| 633 | + if( !$prefix || strpos( $table, $prefix ) === 0 ) { |
| 634 | + if ( strpos( $table, 'sqlite_' ) !== 0 ) { |
| 635 | + $endArray[] = $table; |
| 636 | + } |
| 637 | + |
635 | 638 | } |
636 | 639 | } |
637 | 640 | |