From: Pradeep Nayak Date: Tue, 5 Apr 2016 20:57:36 +0000 (+0530) Subject: --CRM-16617, code fixing for install, changed the parameters of function X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=e5d3a11dbad52dc3d4c56125ae7f25c2cbad2189;p=civicrm-core.git --CRM-16617, code fixing for install, changed the parameters of function --- diff --git a/CRM/Core/DAO.php b/CRM/Core/DAO.php index fa9fe9859d..dc987eb6cd 100644 --- a/CRM/Core/DAO.php +++ b/CRM/Core/DAO.php @@ -2561,14 +2561,13 @@ SELECT contact_id } /** - * 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_]*$/", @@ -2576,14 +2575,8 @@ SELECT contact_id $matches ); if (empty($matches)) { - if ($object) { - $object->error($testDetails); - } return FALSE; } - if ($object) { - $object->testing($testDetails); - } return TRUE; } diff --git a/install/index.php b/install/index.php index cd4091cba2..17a134f03d 100644 --- a/install/index.php +++ b/install/index.php @@ -394,17 +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."), ) ); - 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'], diff --git a/tests/phpunit/CRM/Core/DAOTest.php b/tests/phpunit/CRM/Core/DAOTest.php index 8536ff9921..c2f67a04c7 100644 --- a/tests/phpunit/CRM/Core/DAOTest.php +++ b/tests/phpunit/CRM/Core/DAOTest.php @@ -245,7 +245,7 @@ class CRM_Core_DAOTest extends CiviUnitTestCase { ); $testDetails = array(); foreach ($databases as $database => $val) { - $this->assertEquals(CRM_Core_DAO::requireValidDBName($database, $testDetails), $val); + $this->assertEquals(CRM_Core_DAO::requireValidDBName($database), $val); } }