https://www.mediawiki.org/wiki/Special:Code/MediaWiki/113838
Revision: 113838
Author: saper
Date: 2012-03-14 20:20:53 +0000 (Wed, 14 Mar 2012)
Log Message:
-----------
Follow-up to r15791: Rename "user" and "text" when upgrading on PostgreSQL
You can lie to me, but not to your installer.
Make DatabasePostgres::tableExists to check
for real table names, not faked ones.
DatabasePostgres is currently lying to the rest
of the MediaWiki that "mwuser" table is actually
called "user" and that "pagecontents" is called
"text". While MediaWiki does not care, the
installer (and updater do).
This allows us to overcome first hurdle
in getting MediaWiki 1.7.3 to update to trunk
on PostgreSQL and uncover further bugs.
For this commit to actually do something,
we rename those tables when upgrading to match
what we have in maintenance/postgres/tables.sql
And by the way, tell installer not to check
for "user" table, since most PostgreSQL users
will have "mwuser" instead. Picking "archive"
instead.
Modified Paths:
--------------
trunk/phase3/includes/db/DatabasePostgres.php
trunk/phase3/includes/installer/DatabaseInstaller.php
trunk/phase3/includes/installer/PostgresUpdater.php
Modified: trunk/phase3/includes/db/DatabasePostgres.php
===================================================================
--- trunk/phase3/includes/db/DatabasePostgres.php 2012-03-14 20:19:16 UTC
(rev 113837)
+++ trunk/phase3/includes/db/DatabasePostgres.php 2012-03-14 20:20:53 UTC
(rev 113838)
@@ -708,14 +708,19 @@
# Replace reserved words with better ones
switch( $name ) {
case 'user':
- return 'mwuser';
+ return $this->realTableName( 'mwuser', $format
);
case 'text':
- return 'pagecontent';
+ return $this->realTableName( 'pagecontent',
$format );
default:
- return parent::tableName( $name, $format );
+ return $this->realTableName( $name, $format );
}
}
+ /* Don't cheat on installer */
+ function realTableName( $name, $format = 'quoted' ) {
+ return parent::tableName( $name, $format );
+ }
+
/**
* Return the next in a sequence, save the value for retrieval via
insertId()
* @return null
@@ -990,7 +995,7 @@
if ( !$schema ) {
$schema = $this->getCoreSchema();
}
- $table = $this->tableName( $table, 'raw' );
+ $table = $this->realTableName( $table, 'raw' );
$etable = $this->addQuotes( $table );
$eschema = $this->addQuotes( $schema );
$SQL = "SELECT 1 FROM pg_catalog.pg_class c,
pg_catalog.pg_namespace n "
Modified: trunk/phase3/includes/installer/DatabaseInstaller.php
===================================================================
--- trunk/phase3/includes/installer/DatabaseInstaller.php 2012-03-14
20:19:16 UTC (rev 113837)
+++ trunk/phase3/includes/installer/DatabaseInstaller.php 2012-03-14
20:20:53 UTC (rev 113838)
@@ -158,7 +158,7 @@
}
$this->db->selectDB( $this->getVar( 'wgDBname' ) );
- if( $this->db->tableExists( 'user', __METHOD__ ) ) {
+ if( $this->db->tableExists( 'archive', __METHOD__ ) ) {
$status->warning( 'config-install-tables-exist' );
$this->enableLB();
return $status;
Modified: trunk/phase3/includes/installer/PostgresUpdater.php
===================================================================
--- trunk/phase3/includes/installer/PostgresUpdater.php 2012-03-14 20:19:16 UTC
(rev 113837)
+++ trunk/phase3/includes/installer/PostgresUpdater.php 2012-03-14 20:20:53 UTC
(rev 113838)
@@ -27,6 +27,11 @@
*/
protected function getCoreUpdateList() {
return array(
+ # rename tables 1.7.3
+ # r15791 Change reserved word table names "user" and
"text"
+ array( 'renameTable', 'user', 'mwuser'),
+ array( 'renameTable', 'text', 'pagecontent'),
+
# new sequences
array( 'addSequence', 'logging_log_id_seq' ),
array( 'addSequence', 'page_restrictions_pr_id_seq' ),
@@ -406,7 +411,8 @@
protected function renameTable( $old, $new ) {
if ( $this->db->tableExists( $old ) ) {
$this->output( "Renaming table $old to $new\n" );
- $old = $this->db->addQuotes( $old );
+ $old = $this->db->realTableName( $old, "quoted" );
+ $new = $this->db->realTableName( $new, "quoted" );
$this->db->query( "ALTER TABLE $old RENAME TO $new" );
}
}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs