From: Max Semenik Date: Sun, 6 Dec 2009 11:09:39 +0000 (+0000) Subject: Fixed duplicateTableStructure() for SQLite, it previously didn't copy row properties... X-Git-Tag: 1.31.0-rc.0~38614 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/operations/recherche.php?a=commitdiff_plain;h=a9927b34c5e4a14c6a1db6c56b3ce9ba90b42834;p=lhc%2Fweb%2Fwiklou.git Fixed duplicateTableStructure() for SQLite, it previously didn't copy row properties such as autoincrement. Resolves bug 20549 - parser tests now work with SQLite. --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index e050a63c70..af9b47236f 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -668,6 +668,7 @@ Hopefully we will remove this configuration var soon) the page selector when they have only one page * (bug 21559) "logempty" message is now wrapped in a div with class "mw-warning-logempty" when used in log extract +* (bug 20549) Parser tests were broken on SQLite backend == API changes in 1.16 == diff --git a/includes/db/DatabaseSqlite.php b/includes/db/DatabaseSqlite.php index bab37cd8fa..745bc71e18 100644 --- a/includes/db/DatabaseSqlite.php +++ b/includes/db/DatabaseSqlite.php @@ -521,7 +521,10 @@ class DatabaseSqlite extends DatabaseBase { } function duplicateTableStructure( $oldName, $newName, $temporary = false, $fname = 'DatabaseSqlite::duplicateTableStructure' ) { - return $this->query( 'CREATE ' . ( $temporary ? 'TEMPORARY ' : '' ) . " TABLE $newName AS SELECT * FROM $oldName LIMIT 0", $fname ); + $res = $this->query( "SELECT sql FROM sqlite_master WHERE tbl_name='$oldName' AND type='table'", $fname ); + $sql = $this->fetchObject( $res )->sql; + $sql = preg_replace( '/\b' . preg_quote( $oldName ) . '\b/', $newName, $sql, 1 ); + return $this->query( $sql, $fname ); } } // end DatabaseSqlite class