function FiveUpgrade() {
$this->conversionTables = $this->prepareWindows1252();
- $this->dbw =& $this->newConnection();
- $this->dbr =& $this->streamConnection();
+ $this->loadBalancers = array();
+ $this->dbw = wfGetDB( DB_MASTER );
+ $this->dbr = $this->streamConnection();
$this->cleanupSwaps = array();
$this->emailAuth = false; # don't preauthenticate emails
* @return Database
* @access private
*/
- function &newConnection() {
- global $wgDBadminuser, $wgDBadminpassword, $wgDBtype;
- global $wgDBserver, $wgDBname;
- $dbclass = 'Database' . ucfirst( $wgDBtype ) ;
- $db = new $dbclass( $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname );
+ function newConnection() {
+ $lb = wfGetLBFactory()->newMainLB();
+ $db = $lb->getConnection( DB_MASTER );
+
+ $this->loadBalancers[] = $lb;
return $db;
}
+
+ /**
+ * Commit transactions and close the connections when we're done...
+ */
+ function close() {
+ foreach( $this->loadBalancers as $lb ) {
+ $lb->commitMasterChanges();
+ $lb->closeAll();
+ }
+ }
/**
* Open a second connection to the master server, with buffering off.
* @return Database
* @access private
*/
- function &streamConnection() {
+ function streamConnection() {
global $wgDBtype;
$timeout = 3600 * 24;
- $db =& $this->newConnection();
+ $db = $this->newConnection();
$db->bufferResults( false );
- if ($wgDBtype == 'mysql') {
+ if ($wgDBtype == 'mysql') {
$db->query( "SET net_read_timeout=$timeout" );
$db->query( "SET net_write_timeout=$timeout" );
}
} else {
global $IP;
$this->log( 'adding iw_trans...' );
- dbsource( $IP . '/maintenance/archives/patch-interwiki-trans.sql', $this->dbw );
+ $this->dbw->sourceFile( $IP . '/maintenance/archives/patch-interwiki-trans.sql' );
$this->log( 'added iw_trans.' );
}
$add = array();
while( $row = $this->dbr->fetchObject( $result ) ) {
$add[] = array(
- 'wl_user' => $row->wl_user,
- 'wl_namespace' => Namespace::getSubject( $row->wl_namespace ),
- 'wl_title' => $this->conv( $row->wl_title ),
- 'wl_notificationtimestamp' => '0' );
+ 'wl_user' => $row->wl_user,
+ 'wl_namespace' => MWNamespace::getSubject( $row->wl_namespace ),
+ 'wl_title' => $this->conv( $row->wl_title ),
+ 'wl_notificationtimestamp' => '0' );
$this->addChunk( $add );
$add[] = array(
- 'wl_user' => $row->wl_user,
- 'wl_namespace' => Namespace::getTalk( $row->wl_namespace ),
- 'wl_title' => $this->conv( $row->wl_title ),
- 'wl_notificationtimestamp' => '0' );
+ 'wl_user' => $row->wl_user,
+ 'wl_namespace' => MWNamespace::getTalk( $row->wl_namespace ),
+ 'wl_title' => $this->conv( $row->wl_title ),
+ 'wl_notificationtimestamp' => '0' );
$this->addChunk( $add );
}
$this->lastChunk( $add );