Example #1
0
 /**
  * Apply a SQL source file to the database as part of running an installation step.
  *
  * @param string $sourceFileMethod
  * @param string $stepName
  * @param bool $archiveTableMustNotExist
  * @return Status
  */
 private function stepApplySourceFile($sourceFileMethod, $stepName, $archiveTableMustNotExist = false)
 {
     $status = $this->getConnection();
     if (!$status->isOK()) {
         return $status;
     }
     $this->db->selectDB($this->getVar('wgDBname'));
     if ($archiveTableMustNotExist && $this->db->tableExists('archive', __METHOD__)) {
         $status->warning("config-{$stepName}-tables-exist");
         $this->enableLB();
         return $status;
     }
     $this->db->setFlag(DBO_DDLMODE);
     // For Oracle's handling of schema files
     $this->db->begin(__METHOD__);
     $error = $this->db->sourceFile(call_user_func([$this, $sourceFileMethod], $this->db));
     if ($error !== true) {
         $this->db->reportQueryError($error, 0, '', __METHOD__);
         $this->db->rollback(__METHOD__);
         $status->fatal("config-{$stepName}-tables-failed", $error);
     } else {
         $this->db->commit(__METHOD__);
     }
     // Resume normal operations
     if ($status->isOK()) {
         $this->enableLB();
     }
     return $status;
 }
Example #2
0
 function reportQueryError($error, $errno, $sql, $fname, $tempIgnore = false)
 {
     if ($tempIgnore) {
         /* Check for constraint violation */
         if ($errno === '23505') {
             parent::reportQueryError($error, $errno, $sql, $fname, $tempIgnore);
             return;
         }
     }
     /* Transaction stays in the ERROR state until rolled back */
     if ($this->mTrxLevel) {
         $ignore = $this->ignoreErrors(true);
         $this->rollback(__METHOD__);
         $this->ignoreErrors($ignore);
     }
     parent::reportQueryError($error, $errno, $sql, $fname, false);
 }