Page MenuHomePhabricator

$wgSharedDB not working -- bad if statement in Database.php
Closed, ResolvedPublic

Description

Author: leonardburton

Description:
I had trouble getting $wgSharedDB working and I uncovered an error on Database.php.

Line 984 reade: "if ( isset( $wgSharedDB ) && 'user' == $name ) {"

when it should read something like:
if (isset( $wgSharedDB ) && $this->mTablePrefix.'user' == $name ) {

It is not comparing the table prefixes

After the code edit it works on my installation.

Thanks,

Leonard

Original Code

function tableName( $name ) {
        global $wgSharedDB;
        # Skip quoted literals
        if ( $name{0} != '`' ) {
                if ( $this->mTablePrefix !== '' &&  strpos( '.', $name )

false ) {

                        $name = "{$this->mTablePrefix}$name";
                }
                if ( isset( $wgSharedDB ) && 'user' == $name ) {
                        $name = "`$wgSharedDB`.`$name`";
                } else {
                        # Standard quoting
                        $name = "`$name`";
                }
        }
        return $name;
}

What I did for my purpose

function tableName( $name ) {

global $wgSharedDB;
# Skip quoted literals
if ( $name{0} != '`' ) {
        if ( $this->mTablePrefix !== '' &&  strpos( '.', $name )

false ) {

        $name = "{$this->mTablePrefix}$name";
}
if (isset( $wgSharedDB ) && $this->mTablePrefix.'user'

$name ) {

                        $name = "`$wgSharedDB`.`$name`";
                } else {
                        # Standard quoting
                        $name = "`$name`";
                }
        }
        return $name;
}

Version: 1.5.x
Severity: normal
URL: http://aroip.com/el/

Details

Reference
bz1976

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 8:20 PM
bzimport set Reference to bz1976.
bzimport added a subscriber: Unknown Object (MLST).

Michael.Keppler wrote:

patch for HEAD

The patch adds the tablePrefix to the comparison string (using the same quoted
string like two lines above with $name replaced by user).

Attached:

Michael.Keppler wrote:

patch for REL14

patch for REL14 does the same as for HEAD

Attached:

Fix applied to CVS HEAD and REL1_4.