}
/**
- * function to check valid db name
+ * function to check valid db name containing only characters in [0-9,a-z,A-Z_]
*
* @param $database
- * @param $testDetails
*
* @return bool
*/
- public static function requireValidDBName($database, $testDetails, $object = NULL) {
+ public static function requireValidDBName($database) {
$matches = array();
preg_match(
"/^[0-9]*[a-zA-Z_]+[a-zA-Z0-9_]*$/",
$matches
);
if (empty($matches)) {
- if ($object) {
- $object->error($testDetails);
- }
return FALSE;
}
- if ($object) {
- $object->testing($testDetails);
- }
return TRUE;
}
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 (!CRM_Core_DAO::requireValidDBName(
- $databaseConfig['database'],
- $this,
- 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."),
- ))
- ) {
+ $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'],
);
$testDetails = array();
foreach ($databases as $database => $val) {
- $this->assertEquals(CRM_Core_DAO::requireValidDBName($database, $testDetails), $val);
+ $this->assertEquals(CRM_Core_DAO::requireValidDBName($database), $val);
}
}