+ /**
+ * Override this to provide DBMS-specific schema variables, to be
+ * substituted into tables.sql and other schema files.
+ */
+ public function getSchemaVars() {
+ return array();
+ }
+
+ /**
+ * Set appropriate schema variables in the current database connection.
+ *
+ * This should be called after any request data has been imported, but before
+ * any write operations to the database.
+ */
+ public function setupSchemaVars() {
+ $status = $this->getConnection();
+ if ( $status->isOK() ) {
+ $status->value->setSchemaVars( $this->getSchemaVars() );
+ } else {
+ throw new MWException( __METHOD__.': unexpected DB connection error' );
+ }
+ }
+
+ /**
+ * Set up LBFactory so that wfGetDB() etc. works.
+ * We set up a special LBFactory instance which returns the current
+ * installer connection.
+ */
+ public function enableLB() {
+ $status = $this->getConnection();
+ if ( !$status->isOK() ) {
+ throw new MWException( __METHOD__.': unexpected DB connection error' );
+ }
+ LBFactory::setInstance( new LBFactory_Single( array(
+ 'connection' => $status->value ) ) );
+ }
+
+ /**
+ * Perform database upgrades
+ *
+ * @return Boolean
+ */
+ public function doUpgrade() {
+ $this->setupSchemaVars();
+ $this->enableLB();
+
+ $ret = true;
+ ob_start( array( $this, 'outputHandler' ) );
+ try {
+ $up = DatabaseUpdater::newForDB( $this->db );
+ $up->doUpdates();
+ } catch ( MWException $e ) {
+ echo "\nAn error occured:\n";
+ echo $e->getText();
+ $ret = false;
+ }
+ ob_end_flush();
+ return $ret;
+ }
+
+ /**
+ * Allow DB installers a chance to make last-minute changes before installation
+ * occurs. This happens before setupDatabase() or createTables() is called, but
+ * long after the constructor. Helpful for things like modifying setup steps :)
+ */
+ public function preInstall() {
+
+ }
+
+ /**
+ * Allow DB installers a chance to make checks before upgrade.
+ */
+ public function preUpgrade() {
+
+ }
+
+ /**
+ * Get an array of MW configuration globals that will be configured by this class.
+ */
+ public function getGlobalNames() {
+ return $this->globalNames;
+ }
+
+ /**