From ce334f973210f3f4c045b7d37f6651df4af85540 Mon Sep 17 00:00:00 2001 From: Daniel Friesen Date: Sun, 4 May 2008 09:00:17 +0000 Subject: [PATCH] New variable $wgSharedDBtables. This allows altering of the list of tables which enabling $wgSharedDB affects. For backwards compatibility this is set to an array containing the user table. --- RELEASE-NOTES | 2 ++ includes/Database.php | 6 ++++-- includes/DefaultSettings.php | 13 +++++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index fd412d949d..2b2e4c05f3 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -99,6 +99,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 709) Cannot rename/move images and other media files [EXPERIMENTAL] * Custom rollback summaries now accept the same arguments as the default message * (bug 12542) Added hooks for expansion of Special:Listusers +* Added new variable $wgSharedDBtables for altering the list of tables which are + shared when $wgSharedDB is enabled. === Bug fixes in 1.13 === diff --git a/includes/Database.php b/includes/Database.php index 1f19226e32..2b20d98e72 100644 --- a/includes/Database.php +++ b/includes/Database.php @@ -1365,13 +1365,15 @@ class Database { * @param string $name database table name */ function tableName( $name ) { - global $wgSharedDB; + global $wgSharedDB, $wgSharedDBtables; # Skip quoted literals if ( $name{0} != '`' ) { if ( $this->mTablePrefix !== '' && strpos( $name, '.' ) === false ) { $name = "{$this->mTablePrefix}$name"; } - if ( isset( $wgSharedDB ) && "{$this->mTablePrefix}user" == $name ) { + if ( isset( $wgSharedDB ) && isset( $wgSharedDBtables ) + && substr( $name, 0, strlen($this->mTablePrefix) ) == $this->mTablePrefix + && in_array( substr( $name, strlen($this->mTablePrefix) ), $wgSharedDBtables ) ) { $name = "`$wgSharedDB`.`$name`"; } else { # Standard quoting diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 92dac4af0e..3ee9ea4697 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -586,6 +586,19 @@ $wgCheckDBSchema = true; */ $wgSharedDB = null; +/** + * List of database tables (without prefixes) to share when $wgSharedDB is enabled. + * This only includes the user table by default for backwards compatibility. + * However you may remove it so that you can enable extensions using the shared DB + * without having shared users. Or you can add in another table, such as interwiki + * to force MediaWiki to use the shared version of the table instead. + * + * Be carefull with sharing tables. The images, revisions, pages, and many of the + * other tables may have bad side effects if you share them. + * EXPERIMENTAL + */ +$wgSharedDBtables = array( 'user' ); + /** * Database load balancer * This is a two-dimensional array, an array of server info structures -- 2.20.1