--CRM-16617, moved function to DAO
authorPradeep Nayak <pradpnayak@gmail.com>
Mon, 8 Feb 2016 14:59:29 +0000 (20:29 +0530)
committerPradeep Nayak <pradpnayak@gmail.com>
Sat, 13 Feb 2016 14:44:51 +0000 (20:14 +0530)
Conflicts:

CRM/Core/DAO.php

CRM/Core/DAO.php
install/index.php

index 189b6c8d59a626440de68f4d23b33d6c1fdba50d..f2f4ba5f237cea59a5b34ed643405ccd42441c1e 100644 (file)
@@ -2559,4 +2559,31 @@ SELECT contact_id
     return $clauses;
   }
 
+  /**
+   * function to check valid db name
+   *
+   * @param $database
+   * @param $testDetails
+   *
+   * @return bool
+   */
+  public static function requireValidDBName($database, $testDetails, $object = NULL) {
+    $matches = array();
+    preg_match(
+      "/^[0-9]*[a-zA-Z_]+[a-zA-Z0-9_]*$/",
+      $database,
+      $matches
+    );
+    if (empty($matches)) {
+      if ($object) {
+        $object->error($testDetails);
+      }
+      return FALSE;
+    }
+    if ($object) {
+      $object->testing($testDetails);
+    }
+    return TRUE;
+  }
+
 }
index 292879c52cfb6950ce9879a1ba0aaf9b9c3caddb..cd4091cba25ac8c2d7567606ae354bc82f94f6f6 100644 (file)
@@ -394,8 +394,9 @@ 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."),
           )
         );
-        if (!$this->requireValidDBName(
+        if (!CRM_Core_DAO::requireValidDBName(
           $databaseConfig['database'],
+          $this,
           array(
             ts("MySQL %1 Configuration", array(1 => $dbName)),
             ts("Is the provided database name valid?"),
@@ -1283,27 +1284,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 FALSE;
-    }
-    $this->testing($testDetails);
-    return TRUE;
-  }
-
 }
 
 /**