Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRM-10193 - Allow civicrm-sql-conf and civicrm-sql-cli with empty database #321

Merged
merged 3 commits into from
Jul 11, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions drush/civicrm.drush.inc
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ function civicrm_drush_command() {
// explicit callback declaration and non-standard name to avoid collision with "sql-conf"
'callback' => 'drush_civicrm_sqlconf',
'description' => 'Print CiviCRM database connection details.',
'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_CONFIGURATION,
);
$items['civicrm-sql-connect'] = array(
// explicit callback declaration and non-standard name to avoid collision with "sql-connect"
Expand Down Expand Up @@ -242,6 +243,7 @@ function civicrm_drush_command() {
'callback' => 'drush_civicrm_sqlcli',
'description' => "Open a SQL command-line interface using CiviCRM's credentials.",
'aliases' => array('cvsqlc'),
'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_CONFIGURATION,
);
$items['civicrm-process-mail-queue'] = array(
'description' => "Process pending CiviMail mailing jobs.",
Expand Down Expand Up @@ -1392,7 +1394,7 @@ function drush_civicrm_post_civicrm_sqlcli() {
function _civicrm_dsn_init($reset = FALSE) {
static $globalDbUrl = NULL;

if (!_civicrm_init()) {
if (!_civicrm_init(TRUE, FALSE)) {
return FALSE;
}

Expand Down Expand Up @@ -1442,13 +1444,15 @@ function _civicrm_dsn_close() {
* Initializes the CiviCRM environment and configuration.
* TODO: document why we can't call civicrm_initialize() directly.
*
* @param bool fail
* @param bool $fail
* If true, will halt drush. Otherwise, return false but do not interrupt.
* @param bool $load_config
* If true, loads the CiviCRM configuration.
*
* @return bool
* Returns TRUE if CiviCRM was initialized.
*/
function _civicrm_init($fail = TRUE) {
function _civicrm_init($fail = TRUE, $load_config = TRUE) {
static $init = NULL;

// return if already initialized
Expand Down Expand Up @@ -1490,9 +1494,10 @@ function _civicrm_init($fail = TRUE) {
CRM_Core_ClassLoader::singleton()->register();
}

// also initialize config object
require_once 'CRM/Core/Config.php';
$config = CRM_Core_Config::singleton();
if ($load_config) {
require_once 'CRM/Core/Config.php';
CRM_Core_Config::singleton();
}

$init = TRUE;
return $init;
Expand Down