summaryrefslogtreecommitdiff
path: root/includes/installer/OracleInstaller.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/installer/OracleInstaller.php')
-rw-r--r--includes/installer/OracleInstaller.php61
1 files changed, 52 insertions, 9 deletions
diff --git a/includes/installer/OracleInstaller.php b/includes/installer/OracleInstaller.php
index e8538890..77575100 100644
--- a/includes/installer/OracleInstaller.php
+++ b/includes/installer/OracleInstaller.php
@@ -59,35 +59,51 @@ class OracleInstaller extends DatabaseInstaller {
if ( $this->getVar( 'wgDBserver' ) == 'localhost' ) {
$this->parent->setVar( 'wgDBserver', '' );
}
- return
- $this->getTextBox( 'wgDBserver', 'config-db-host-oracle', array(), $this->parent->getHelpBox( 'config-db-host-oracle-help' ) ) .
+
+ return $this->getTextBox(
+ 'wgDBserver',
+ 'config-db-host-oracle',
+ array(),
+ $this->parent->getHelpBox( 'config-db-host-oracle-help' )
+ ) .
Html::openElement( 'fieldset' ) .
Html::element( 'legend', array(), wfMessage( 'config-db-wiki-settings' )->text() ) .
$this->getTextBox( 'wgDBprefix', 'config-db-prefix' ) .
$this->getTextBox( '_OracleDefTS', 'config-oracle-def-ts' ) .
- $this->getTextBox( '_OracleTempTS', 'config-oracle-temp-ts', array(), $this->parent->getHelpBox( 'config-db-oracle-help' ) ) .
+ $this->getTextBox(
+ '_OracleTempTS',
+ 'config-oracle-temp-ts',
+ array(),
+ $this->parent->getHelpBox( 'config-db-oracle-help' )
+ ) .
Html::closeElement( 'fieldset' ) .
- $this->parent->getWarningBox( wfMessage( 'config-db-account-oracle-warn' )->text() ).
- $this->getInstallUserBox().
+ $this->parent->getWarningBox( wfMessage( 'config-db-account-oracle-warn' )->text() ) .
+ $this->getInstallUserBox() .
$this->getWebUserBox();
}
public function submitInstallUserBox() {
parent::submitInstallUserBox();
$this->parent->setVar( '_InstallDBname', $this->getVar( '_InstallUser' ) );
+
return Status::newGood();
}
public function submitConnectForm() {
// Get variables from the request
- $newValues = $this->setVarsFromRequest( array( 'wgDBserver', 'wgDBprefix', 'wgDBuser', 'wgDBpassword' ) );
+ $newValues = $this->setVarsFromRequest(
+ 'wgDBserver',
+ 'wgDBprefix',
+ 'wgDBuser',
+ 'wgDBpassword'
+ );
$this->parent->setVar( 'wgDBname', $this->getVar( 'wgDBuser' ) );
// Validate them
$status = Status::newGood();
if ( !strlen( $newValues['wgDBserver'] ) ) {
$status->fatal( 'config-missing-db-server-oracle' );
- } elseif ( !preg_match( '/^[a-zA-Z0-9_\.]+$/', $newValues['wgDBserver'] ) ) {
+ } elseif ( !self::checkConnectStringFormat( $newValues['wgDBserver'] ) ) {
$status->fatal( 'config-invalid-db-server-oracle', $newValues['wgDBserver'] );
}
if ( !preg_match( '/^[a-zA-Z0-9_]*$/', $newValues['wgDBprefix'] ) ) {
@@ -163,6 +179,7 @@ class OracleInstaller extends DatabaseInstaller {
$this->connError = $e->db->lastErrno();
$status->fatal( 'config-connection-error', $e->getMessage() );
}
+
return $status;
}
@@ -182,6 +199,7 @@ class OracleInstaller extends DatabaseInstaller {
$this->connError = $e->db->lastErrno();
$status->fatal( 'config-connection-error', $e->getMessage() );
}
+
return $status;
}
@@ -190,6 +208,7 @@ class OracleInstaller extends DatabaseInstaller {
$this->parent->setVar( 'wgDBname', $this->getVar( 'wgDBuser' ) );
$retVal = parent::needsUpgrade();
$this->parent->setVar( 'wgDBname', $tempDBname );
+
return $retVal;
}
@@ -204,6 +223,7 @@ class OracleInstaller extends DatabaseInstaller {
public function setupDatabase() {
$status = Status::newGood();
+
return $status;
}
@@ -286,15 +306,38 @@ class OracleInstaller extends DatabaseInstaller {
foreach ( $varNames as $name ) {
$vars[$name] = $this->getVar( $name );
}
+
return $vars;
}
public function getLocalSettings() {
$prefix = $this->getVar( 'wgDBprefix' );
- return
-"# Oracle specific settings
+
+ return "# Oracle specific settings
\$wgDBprefix = \"{$prefix}\";
";
}
+ /**
+ * Function checks the format of Oracle connect string
+ * The actual validity of the string is checked by attempting to connect
+ *
+ * Regex should be able to validate all connect string formats
+ * [//](host|tns_name)[:port][/service_name][:POOLED]
+ * http://www.orafaq.com/wiki/EZCONNECT
+ *
+ * @since 1.22
+ *
+ * @param string $connect_string
+ *
+ * @return bool Whether the connection string is valid.
+ */
+ public static function checkConnectStringFormat( $connect_string ) {
+ // @@codingStandardsIgnoreStart Long lines with regular expressions.
+ // @todo Very long regular expression. Make more readable?
+ $isValid = preg_match( '/^[[:alpha:]][\w\-]*(?:\.[[:alpha:]][\w\-]*){0,2}$/', $connect_string ); // TNS name
+ $isValid |= preg_match( '/^(?:\/\/)?[\w\-\.]+(?::[\d]+)?(?:\/(?:[\w\-\.]+(?::(pooled|dedicated|shared))?)?(?:\/[\w\-\.]+)?)?$/', $connect_string ); // EZConnect
+ // @@codingStandardsIgnoreEnd
+ return (bool)$isValid;
+ }
}