Merge pull request #8163 from jitendrapurohit/nav-menu-fix
[civicrm-core.git] / install / index.php
index 372b567125fe76ba835a7ab490ef1bba8ca6958f..17a134f03de6cc1318dc0974ea6a904b4f0c5370 100644 (file)
@@ -394,6 +394,18 @@ class InstallRequirements {
             ts("An auto_increment_increment value greater than 1 is not currently supported. Please see issue CRM-7923 for further details and potential workaround."),
           )
         );
+        $testDetails = array(
+          ts("MySQL %1 Configuration", array(1 => $dbName)),
+          ts("Is the provided database name valid?"),
+          ts("The database name provided is not valid. Please use only 0-9, a-z, A-Z and _ as characters in the name."),
+        );
+        if (!CRM_Core_DAO::requireValidDBName($databaseConfig['database'])) {
+          $this->error($testDetails);
+          return FALSE;
+        }
+        else {
+          $this->testing($testDetails);
+        }
         $this->requireMySQLThreadStack($databaseConfig['server'],
           $databaseConfig['username'],
           $databaseConfig['password'],
@@ -408,14 +420,6 @@ class InstallRequirements {
         );
       }
       $onlyRequire = ($dbName == 'Drupal') ? TRUE : FALSE;
-      $this->requireValidDBName(
-        $databaseConfig['database'],
-        array(     
-          ts("MySQL %1 Configuration", array(1 => $dbName)),
-          ts("Is the provided database name valid?"),
-          ts("The database name provided is not valid. Please use only 0-9, a-z, A-Z and _ as characters in the name."),
-        )
-      );
       $this->requireDatabaseOrCreatePermissions(
         $databaseConfig['server'],
         $databaseConfig['username'],
@@ -1281,25 +1285,6 @@ class InstallRequirements {
     return count($this->warnings);
   }
 
-  /**
-   * function to check valid db name
-   *
-   * @param $database
-   * @param $testDetails
-   */
-  public function requireValidDBName($database, $testDetails) {
-    $matches = array();
-    preg_match(
-      "/^[0-9]*[a-zA-Z_]+[a-zA-Z0-9_]*$/",
-      $database,
-      $matches
-    );
-    if (empty($matches)) {
-      $this->error($testDetails);
-      return;
-    }
-  }
-
 }
 
 /**