From cab0a1b0969e6d7f35e727a504bc70e55455da79 Mon Sep 17 00:00:00 2001 From: Greg Sabino Mullane Date: Fri, 14 Mar 2008 04:39:18 +0000 Subject: [PATCH] Fix for bug 13251, allows some rebuld scripts to work with Postgres. --- RELEASE-NOTES | 1 + maintenance/FiveUpgrade.inc | 13 +++++++++---- maintenance/rebuildall.php | 15 +++++++++------ 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index bf9403c774..eb8f733ae1 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -85,6 +85,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN for Internet Explorer's sake and standards compliance * (bug 13298) Tighter limits on Special:Newpages limits when embedding * Email subject in content language instead of sending user's UI language +* (bug 13251) Allow maintenance rebuild scripts to work with Postgres === API changes in 1.13 === diff --git a/maintenance/FiveUpgrade.inc b/maintenance/FiveUpgrade.inc index 62574f1834..f3d91e36c8 100644 --- a/maintenance/FiveUpgrade.inc +++ b/maintenance/FiveUpgrade.inc @@ -61,9 +61,10 @@ class FiveUpgrade { * @access private */ function &newConnection() { - global $wgDBadminuser, $wgDBadminpassword; + global $wgDBadminuser, $wgDBadminpassword, $wgDBtype; global $wgDBserver, $wgDBname; - $db = new Database( $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname ); + $dbclass = 'Database' . ucfirst( $wgDBtype ) ; + $db = new $dbclass( $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname ); return $db; } @@ -75,11 +76,15 @@ class FiveUpgrade { * @access private */ function &streamConnection() { + global $wgDBtype; + $timeout = 3600 * 24; $db =& $this->newConnection(); $db->bufferResults( false ); - $db->query( "SET net_read_timeout=$timeout" ); - $db->query( "SET net_write_timeout=$timeout" ); + if ($wgDBtype == 'mysql') { + $db->query( "SET net_read_timeout=$timeout" ); + $db->query( "SET net_write_timeout=$timeout" ); + } return $db; } diff --git a/maintenance/rebuildall.php b/maintenance/rebuildall.php index 1c2647b260..07622954df 100644 --- a/maintenance/rebuildall.php +++ b/maintenance/rebuildall.php @@ -14,12 +14,15 @@ require_once( "refreshLinks.inc" ); require_once( "rebuildtextindex.inc" ); require_once( "rebuildrecentchanges.inc" ); -$database = Database::newFromParams( $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname ); - -print "** Rebuilding fulltext search index (if you abort this will break searching; run this script again to fix):\n"; -dropTextIndex( $database ); -rebuildTextIndex( $database ); -createTextIndex( $database ); +$dbclass = 'Database' . ucfirst( $wgDBtype ) ; +$database = new $dbclass( $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname ); + +if ($wgDBtype == 'mysql') { + print "** Rebuilding fulltext search index (if you abort this will break searching; run this script again to fix):\n"; + dropTextIndex( $database ); + rebuildTextIndex( $database ); + createTextIndex( $database ); +} print "\n\n** Rebuilding recentchanges table:\n"; rebuildRecentChangesTable(); -- 2.20.1