From d2572f6fec8194286359497037822613afbba90b Mon Sep 17 00:00:00 2001 From: Greg Sabino Mullane Date: Wed, 19 Mar 2008 13:23:12 +0000 Subject: [PATCH] Patch from Sven Klemm from bug 13239: search_path tweaks for Postgres. --- maintenance/updaters.inc | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/maintenance/updaters.inc b/maintenance/updaters.inc index 8a112ddb67..1b434439ab 100644 --- a/maintenance/updaters.inc +++ b/maintenance/updaters.inc @@ -1301,21 +1301,23 @@ function do_postgres_updates() { list( $x,$y ) = explode( '=', $c ); $conf[$x] = $y; } - $newpath = array(); - if( $wgDBmwschema === 'mediawiki' ) { - if (!array_key_exists( 'search_path', $conf ) or strpos( $conf['search_path'],$wgDBmwschema ) === false ) { - echo "Adding in schema \"$wgDBmwschema\" to search_path for user \"$wgDBuser\"\n"; - $newpath[$wgDBmwschema] = 1; - } + if( !array_key_exists( 'search_path', $conf ) ) { + $search_path = ''; + } + else { + $search_path = $conf['search_path']; + } + if( strpos( $search_path, $wgDBmwschema ) === false ) { + echo "Adding in schema \"$wgDBmwschema\" to search_path for user \"$wgDBuser\"\n"; + $search_path = "$wgDBmwschema, $search_path"; } - if( !array_key_exists( 'search_path', $conf ) or strpos( $conf['search_path'],$wgDBts2schema ) === false ) { + if( strpos( $search_path, $wgDBts2schema ) === false ) { echo "Adding in schema \"$wgDBts2schema\" to search_path for user \"$wgDBuser\"\n"; - $newpath[$wgDBts2schema] = 1; + $search_path = "$search_path, $wgDBts2schema"; } - $searchpath = implode( ',', array_keys( $newpath ) ); - if( strlen( $searchpath ) ) { - $wgDatabase->doQuery( "ALTER USER $wgDBuser SET search_path = $searchpath" ); - $wgDatabase->doQuery( "SET search_path = $searchpath" ); + if( array_key_exists( 'search_path', $conf ) === false || $search_path != $conf['search_path'] ) { + $wgDatabase->doQuery( "ALTER USER $wgDBuser SET search_path = $search_path" ); + $wgDatabase->doQuery( "SET search_path = $search_path" ); } else { $path = $conf['search_path']; -- 2.20.1