jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/387507 )
Change subject: Backport of formatting cleanup. ...................................................................... Backport of formatting cleanup. commit 1624d3f637840248994c1480707c0979298ff4df Author: Seamus Lee <seamuslee...@gmail.com> Date: Sun Aug 27 12:03:46 2017 +1000 Lint civicrm.drush.inc Backported this from https://github.com/civicrm/civicrm-drupal/pull/473 to keep the following commit cleaner Change-Id: Ia9792ce1c4902a77a8535a1a3251fa8a6d3b0000 --- M drupal/drush/civicrm.drush.inc 1 file changed, 102 insertions(+), 121 deletions(-) Approvals: Mepps: Looks good to me, approved jenkins-bot: Verified diff --git a/drupal/drush/civicrm.drush.inc b/drupal/drush/civicrm.drush.inc index c9a73ca..72c4c49 100644 --- a/drupal/drush/civicrm.drush.inc +++ b/drupal/drush/civicrm.drush.inc @@ -23,7 +23,7 @@ | GNU Affero General Public License or the licensing of CiviCRM, | | see the CiviCRM license FAQ at http://civicrm.org/licensing | +--------------------------------------------------------------------+ -*/ + */ /** * @@ -49,7 +49,7 @@ */ /** - * Implementation of hook_drush_command(). + * Implements hook_drush_command(). * * In this hook, you specify which commands your * drush module makes available, what it does and @@ -60,8 +60,6 @@ * * @See drush_parse_command() for a list of recognized keys. * - * @return - * An associative array describing your command(s). */ function civicrm_drush_command() { $items = array(); @@ -69,8 +67,7 @@ // the key in the $items array is the name of the command. $items['civicrm-api'] = array( 'description' => 'CLI access to CiviCRM APIs. It can return pretty-printor json formatted data.', - 'examples' => - array( + 'examples' => array( 'drush civicrm-api contact.create first_name=John last_name=Doe contact_type=Individual' => 'Create a new contact named John Doe', 'drush civicrm-api contact.create id=1 --out=json' => 'Find/display a contact in JSON format', ), @@ -82,8 +79,7 @@ ); $items['civicrm-install'] = array( 'description' => "Install a new instance of CiviCRM.", - 'options' => - array( + 'options' => array( 'dbuser' => 'MySQL username for your Drupal/CiviCRM database.', 'dbpass' => 'MySQL password for your Drupal/CiviCRM database.', 'dbhost' => 'MySQL host for your Drupal/CiviCRM database. Defaults to localhost.', @@ -145,10 +141,8 @@ ); $items['civicrm-update-cfg'] = array( 'description' => "Update config_backend to correct config settings, especially when the CiviCRM site has been cloned / migrated.", - 'examples' => - array( - 'drush -l http://example.com/civicrm civicrm-update-cfg' => - 'Update config_backend to correct config settings for civicrm installation on example.com site.', + 'examples' => array( + 'drush -l http://example.com/civicrm civicrm-update-cfg' => 'Update config_backend to correct config settings for civicrm installation on example.com site.', ), 'aliases' => array('cvupcfg'), ); @@ -157,45 +151,32 @@ ); $items['civicrm-upgrade'] = array( 'description' => "Replace CiviCRM codebase with new specified tarfile and upgrade database by executing the CiviCRM upgrade process - civicrm/upgrade?reset=1.", - 'examples' => - array( - 'drush civicrm-upgrade --tarfile=~/tarballs/civicrm-4.1.2-drupal.tar.gz' => - 'Replace old CiviCRM codebase with new v4.1.2 and run upgrade process.', + 'examples' => array( + 'drush civicrm-upgrade --tarfile=~/tarballs/civicrm-4.1.2-drupal.tar.gz' => 'Replace old CiviCRM codebase with new v4.1.2 and run upgrade process.', ), - 'options' => - array( - 'tarfile' => - 'Path of new CiviCRM tarfile, with which current CiviCRM codebase is to be replaced.', - 'backup-dir' => - 'Specify a directory to backup current CiviCRM codebase and database into, defaults to a backup directory above your Drupal root.', + 'options' => array( + 'tarfile' => 'Path of new CiviCRM tarfile, with which current CiviCRM codebase is to be replaced.', + 'backup-dir' => 'Specify a directory to backup current CiviCRM codebase and database into, defaults to a backup directory above your Drupal root.', ), 'aliases' => array('cvup'), ); $items['civicrm-restore'] = array( 'description' => 'Restore CiviCRM codebase and database back from the specified backup directory.', - 'examples' => - array( - 'drush civicrm-restore --restore-dir=../backup/modules/20100309200249' => - 'Replace current civicrm codebase with the $restore-dir/civicrm codebase, and reload the database with $restore-dir/civicrm.sql file', + 'examples' => array( + 'drush civicrm-restore --restore-dir=../backup/modules/20100309200249' => 'Replace current civicrm codebase with the $restore-dir/civicrm codebase, and reload the database with $restore-dir/civicrm.sql file', ), - 'options' => - array( - 'restore-dir' => - 'Path of directory having backed up CiviCRM codebase and database.', - 'backup-dir' => - 'Specify a directory to backup current CiviCRM codebase and database into, defaults to a backup directory above your Drupal root.', + 'options' => array( + 'restore-dir' => 'Path of directory having backed up CiviCRM codebase and database.', + 'backup-dir' => 'Specify a directory to backup current CiviCRM codebase and database into, defaults to a backup directory above your Drupal root.', ), ); $items['civicrm-rest'] = array( 'description' => "Rest interface for accessing CiviCRM APIs. It can return xml or json formatted data.", - 'examples' => - array( - "drush civicrm-rest --query='civicrm/contact/search&json=1&key=7decb879f28ac4a0c6a92f0f7889a0c9&api_key=7decb879f28ac4a0c6a92f0f7889a0c9'" => - 'Use contact search api to return data in json format.', + 'examples' => array( + "drush civicrm-rest --query='civicrm/contact/search&json=1&key=7decb879f28ac4a0c6a92f0f7889a0c9&api_key=7decb879f28ac4a0c6a92f0f7889a0c9'" => 'Use contact search api to return data in json format.', ), // TODO: This really makes more sense as an argument. - 'options' => - array('query' => 'Query part of url. Refer CiviCRM wiki doc for more details.'), + 'options' => array('query' => 'Query part of url. Refer CiviCRM wiki doc for more details.'), 'aliases' => array('cvr'), ); $items['civicrm-sql-conf'] = array( @@ -247,10 +228,8 @@ ); $items['civicrm-process-mail-queue'] = array( 'description' => "Process pending CiviMail mailing jobs.", - 'examples' => - array( - 'drush civicrm-process-mail-queue -u admin' => - 'Process CiviMail queue with admin credentials.', + 'examples' => array( + 'drush civicrm-process-mail-queue -u admin' => 'Process CiviMail queue with admin credentials.', ), ); $items['civicrm-member-records'] = array( @@ -268,8 +247,8 @@ */ function drush_civicrm_get_db_spec() { if (version_compare(DRUSH_VERSION, 7, '>=')) { - $sql = drush_sql_get_class(); - $db_spec = $sql->db_spec(); + $sql = drush_sql_get_class(); + $db_spec = $sql->db_spec(); } else { $db_spec = _drush_sql_get_db_spec(); @@ -278,7 +257,7 @@ } /** - * Implementation of drush_hook_COMMAND_validate for command 'civicrm-install' + * Implements hook_COMMAND_validate() for civicrm-install(). */ function drush_civicrm_install_validate() { // TODO: Replace these with required options (Drush 5). @@ -306,9 +285,9 @@ drush_set_option('dbname', $db_spec['database']); } - $crmpath = _civicrm_get_crmpath(); + $crmpath = _civicrm_get_crmpath(); $drupalRoot = drush_get_context('DRUSH_DRUPAL_ROOT'); - $modPath = "$drupalRoot/$crmpath"; + $modPath = "$drupalRoot/$crmpath"; if (!is_dir("$modPath/civicrm") && !drush_get_option('tarfile', FALSE)) { return drush_set_error('CIVICRM_INSTALL_TARFILE_NOT_SPECIFIED', dt('CiviCRM tarfile not specified.')); @@ -330,10 +309,10 @@ $dbhost = drush_get_option('dbhost', FALSE); $dbname = drush_get_option('dbname', FALSE); - $crmpath = _civicrm_get_crmpath(); + $crmpath = _civicrm_get_crmpath(); $drupalRoot = drush_get_context('DRUSH_DRUPAL_ROOT'); - $modPath = "$drupalRoot/$crmpath"; - $lang = drush_get_option('lang', ''); + $modPath = "$drupalRoot/$crmpath"; + $lang = drush_get_option('lang', ''); $loadGeneratedData = drush_get_option('load_generated_data', FALSE); if (!is_dir("$modPath/civicrm")) { @@ -377,7 +356,7 @@ } function _civicrm_install_db($dbuser, $dbpass, $dbhost, $dbname, - $modPath, $lang, $loadGeneratedData + $modPath, $lang, $loadGeneratedData ) { $drupalRoot = drush_get_context('DRUSH_DRUPAL_ROOT'); $siteRoot = drush_get_context('DRUSH_DRUPAL_SITE_ROOT', FALSE); @@ -418,8 +397,8 @@ } else { drush_log(dt("No sql files could be retrieved for \"" . $lang . - "\", using default language." - ), 'warning'); + "\", using default language." + ), 'warning'); } } civicrm_source($dsn, $data_file); @@ -449,15 +428,17 @@ return TRUE; } -// generates civicrm.settings.php file +/** + * Generates civicrm.settings.php file + */ function _civicrm_generate_settings_file($dbuser, $dbpass, $dbhost, $dbname, $modPath) { $drupalRoot = drush_get_context('DRUSH_DRUPAL_ROOT'); - $siteRoot = drush_get_context('DRUSH_DRUPAL_SITE_ROOT', FALSE); - $crmPath = "$modPath/civicrm"; + $siteRoot = drush_get_context('DRUSH_DRUPAL_SITE_ROOT', FALSE); + $crmPath = "$modPath/civicrm"; $files = array( "$crmPath/templates/CRM/common/civicrm.settings.php.template", - "$crmPath/templates/CRM/common/civicrm.settings.php.tpl" + "$crmPath/templates/CRM/common/civicrm.settings.php.tpl", ); $settingsTplFile = NULL; @@ -525,16 +506,11 @@ } /** - * Implementation of hook_drush_help(). + * Implements hook_drush_help(). * * This function is called whenever a drush user calls * 'drush help <name-of-your-command>' * - * @param - * A string with the help section (prepend with 'drush:') - * - * @return - * A string with the help text for your command. */ function civicrm_drush_help($section) { switch ($section) { @@ -575,7 +551,7 @@ */ function drush_civicrm_ext_list() { civicrm_initialize(); - try{ + try { $result = civicrm_api3('extension', 'get', array( 'options' => array( 'limit' => 0, @@ -605,11 +581,12 @@ */ function drush_civicrm_ext_install($extension_name) { civicrm_initialize(); - try{ + try { $result = civicrm_api('extension', 'install', array('key' => $extension_name, 'version' => 3)); - if($result['values'] && $result['values'] == 1) { + if ($result['values'] && $result['values'] == 1) { drush_print(dt("Extension !ename installed.", array('!ename' => $extension_name))); - } else { + } + else { drush_log(t('Extension !ename could not be installed.', array('!ename' => $extension_name)), 'error'); } } @@ -627,11 +604,12 @@ */ function drush_civicrm_ext_disable($extension_name) { civicrm_initialize(); - try{ + try { $result = civicrm_api('extension', 'disable', array('key' => $extension_name, 'version' => 3)); - if($result['values'] && $result['values'] == 1) { + if ($result['values'] && $result['values'] == 1) { drush_print(dt("Extension !ename disabled.", array('!ename' => $extension_name))); - } else { + } + else { drush_log(t('Extension !ename could not be disabled.', array('!ename' => $extension_name)), 'error'); } } @@ -649,11 +627,12 @@ */ function drush_civicrm_ext_uninstall($extension_name) { civicrm_initialize(); - try{ + try { $result = civicrm_api('extension', 'uninstall', array('key' => $extension_name, 'version' => 3)); - if($result['values'] && $result['values'] == 1) { + if ($result['values'] && $result['values'] == 1) { drush_print(dt("Extension !ename uninstalled.", array('!ename' => $extension_name))); - } else { + } + else { drush_log(t('Extension !ename could not be uninstalled.', array('!ename' => $extension_name)), 'error'); } } @@ -667,7 +646,7 @@ } /** - * Implementation of drush_hook_COMMAND_validate for command 'civicrm-upgrade-db' + * Implements drush_hook_COMMAND_validate() for civicrm-upgrade-db(). */ function drush_civicrm_upgrade_db_validate() { if (!defined('CIVICRM_UPGRADE_ACTIVE')) { @@ -727,7 +706,7 @@ require_once 'CRM/Core/Smarty.php'; $template = CRM_Core_Smarty::singleton(); - require_once ('CRM/Upgrade/Page/Upgrade.php'); + require_once 'CRM/Upgrade/Page/Upgrade.php'; $upgrade = new CRM_Upgrade_Page_Upgrade(); // new since CiviCRM 4.1 @@ -747,7 +726,7 @@ } /** - * Implementation of drush_hook_COMMAND_validate for command 'civicrm-update-cfg' + * Implements drush_hook_COMMAND_validate() for civicrm-update-cfg(). */ function drush_civicrm_update_cfg_validate() { return _civicrm_init(); @@ -779,11 +758,13 @@ drush_log(dt('Config successfully updated.'), 'completed'); } - else drush_log(dt('Config update failed.'), 'failed'); + else { + drush_log(dt('Config update failed.'), 'failed'); + } } /** - * Implements hook_drush_cache_clear. + * Implements hook_drush_cache_clear(). */ function civicrm_drush_cache_clear(&$types) { if (_civicrm_init(FALSE)) { @@ -830,7 +811,7 @@ } /** - * Implementation of drush_hook_COMMAND_validate for command 'civicrm-enable-debug' + * Implements drush_hook_COMMAND_validate() for civicrm-enable-debug(). */ function drush_civicrm_enable_debug_validate() { return _civicrm_init(); @@ -855,7 +836,7 @@ } /** - * Implementation of drush_hook_COMMAND_validate for command 'civicrm-disable-debug' + * Implements drush_hook_COMMAND_validate() for civicrm-disable-debug(). */ function drush_civicrm_disable_debug_validate() { return _civicrm_init(); @@ -880,7 +861,7 @@ } /** - * Implementation of drush_hook_COMMAND_validate for command 'civicrm-upgrade' + * Implements drush_hook_COMMAND_validate() for civicrm-upgrade(). */ function drush_civicrm_upgrade_validate() { // TODO: use Drush to download tarfile. @@ -903,8 +884,8 @@ function drush_civicrm_upgrade() { global $civicrm_root; - $tarfile = drush_get_option('tarfile', FALSE); - $date = date('YmdHis'); + $tarfile = drush_get_option('tarfile', FALSE); + $date = date('YmdHis'); $backup_file = "civicrm"; $basepath = explode('/', $civicrm_root); @@ -912,19 +893,19 @@ $project_path = implode('/', $basepath) . '/'; $drupal_root = drush_get_context('DRUSH_DRUPAL_ROOT'); - $backup_dir = drush_get_option('backup-dir', $drupal_root . '/../backup'); - $backup_dir = rtrim($backup_dir, '/'); + $backup_dir = drush_get_option('backup-dir', $drupal_root . '/../backup'); + $backup_dir = rtrim($backup_dir, '/'); drush_print(dt("\nThe upgrade process involves - ")); drush_print(dt("1. Backing up current CiviCRM code as => !path", - array('!path' => "$backup_dir/modules/$date/$backup_file") - )); + array('!path' => "$backup_dir/modules/$date/$backup_file") + )); drush_print(dt("2. Backing up database as => !path", - array('!path' => "$backup_dir/modules/$date/$backup_file.sql") - )); + array('!path' => "$backup_dir/modules/$date/$backup_file.sql") + )); drush_print(dt("3. Unpacking tarfile to => !path", - array('!path' => "$project_path") - )); + array('!path' => "$project_path") + )); drush_print(dt("4. Executing civicrm/upgrade?reset=1 just as a browser would.\n")); if (!drush_confirm(dt('Do you really want to continue?'))) { return drush_user_abort(); @@ -938,8 +919,8 @@ $backup_target = $backup_dir . '/' . $backup_file; if (!drush_op('rename', $civicrm_root, $backup_target)) { return drush_set_error('CIVICRM_BACKUP_FAILED', dt('Failed to backup CiviCRM project directory !source to !backup_target', - array('!source' => $civicrm_root, '!backup_target' => $backup_target) - )); + array('!source' => $civicrm_root, '!backup_target' => $backup_target) + )); } drush_log(dt("\n1. Code backed up."), 'ok'); @@ -960,7 +941,7 @@ } /** - * Implementation of drush_hook_COMMAND_validate for command 'civicrm-restore' + * Implements drush_hook_COMMAND_validate() for civicrm-restore(). */ function drush_civicrm_restore_validate() { _civicrm_dsn_init(); @@ -991,16 +972,16 @@ function drush_civicrm_restore() { $restore_dir = drush_get_option('restore-dir', FALSE); $restore_dir = rtrim($restore_dir, '/'); - $sql_file = $restore_dir . '/civicrm.sql'; - $code_dir = $restore_dir . '/civicrm'; - $date = date('YmdHis'); + $sql_file = $restore_dir . '/civicrm.sql'; + $code_dir = $restore_dir . '/civicrm'; + $date = date('YmdHis'); global $civicrm_root; $civicrm_root_base = explode('/', $civicrm_root); array_pop($civicrm_root_base); $civicrm_root_base = implode('/', $civicrm_root_base) . '/'; - $drupal_root = drush_get_context('DRUSH_DRUPAL_ROOT'); + $drupal_root = drush_get_context('DRUSH_DRUPAL_ROOT'); $restore_backup_dir = drush_get_option('backup-dir', $drupal_root . '/../backup'); $restore_backup_dir = rtrim($restore_backup_dir, '/'); @@ -1012,8 +993,8 @@ drush_print(dt("3. Loading '\$restore-dir/civicrm.sql' file into the database.")); drush_print(); drush_print(dt("Note: Before restoring a backup will be taken in '!path' directory.", - array('!path' => "$restore_backup_dir/modules/restore") - )); + array('!path' => "$restore_backup_dir/modules/restore") + )); drush_print(); if (!drush_confirm(dt('Do you really want to continue?'))) { return drush_user_abort(); @@ -1032,13 +1013,13 @@ drush_log(dt('Restoring civicrm codebase ..')); if (is_dir($civicrm_root) && !drush_op('rename', $civicrm_root, $restore_backup_dir . '/civicrm')) { return drush_set_error('CIVICRM_RESTORE_CODE_FAILED', dt("Failed to take backup for '!destination' directory", - array('!destination' => $civicrm_root) - )); + array('!destination' => $civicrm_root) + )); } if (!drush_op('rename', $code_dir, $civicrm_root)) { return drush_set_error('CIVICRM_RESTORE_DESTINATION_FAILED', dt("Failed to restore civicrm directory '!source' to '!dest'", - array('!source' => $code_dir, '!dest' => $civicrm_root_base) - )); + array('!source' => $code_dir, '!dest' => $civicrm_root_base) + )); } drush_log(dt('Codebase restored.'), 'ok'); @@ -1113,7 +1094,7 @@ $_REQUEST['name'] = drush_get_option('civicrm_cron_username', NULL); $_REQUEST['pass'] = drush_get_option('civicrm_cron_password', NULL); - $_REQUEST['key'] = drush_get_option('civicrm_sitekey', NULL); + $_REQUEST['key'] = drush_get_option('civicrm_sitekey', NULL); global $argv; $argv = array( @@ -1131,7 +1112,7 @@ } /** - * Implementation of drush_hook_COMMAND_validate for command 'civicrm-rest' ('cvr') + * Implements drush_hook_COMMAND_validate() for civicrm-rest(). */ function drush_civicrm_rest_validate() { $query = drush_get_option('query', FALSE); @@ -1146,8 +1127,8 @@ * Implementation of command 'civicrm-rest' ('cvr') */ function drush_civicrm_rest() { - $query = drush_get_option('query', FALSE); - $query = explode('&', $query); + $query = drush_get_option('query', FALSE); + $query = explode('&', $query); $_GET['q'] = array_shift($query); foreach ($query as $keyVal) { list($key, $val) = explode('=', $keyVal); @@ -1475,8 +1456,8 @@ } global $cmsPath; - $cmsPath = $drupal_root = drush_get_context('DRUSH_DRUPAL_ROOT'); - $site_root = drush_get_context('DRUSH_DRUPAL_SITE_ROOT', FALSE); + $cmsPath = $drupal_root = drush_get_context('DRUSH_DRUPAL_ROOT'); + $site_root = drush_get_context('DRUSH_DRUPAL_SITE_ROOT', FALSE); $civicrmSettingsFile = "$drupal_root/$site_root/civicrm.settings.php"; if (!file_exists($civicrmSettingsFile)) { @@ -1600,20 +1581,20 @@ ) ); if ($result['contactMatching']) { - $status .= PHP_EOL . ts('Found one matching contact record.', - array( - 'count' => $result['contactMatching'], - 'plural' => 'Found %count matching contact records.', - ) - ); + $status .= PHP_EOL . ts('Found one matching contact record.', + array( + 'count' => $result['contactMatching'], + 'plural' => 'Found %count matching contact records.', + ) + ); } $status .= PHP_EOL . ts('Created one new contact record.', - array( - 'count' => $result['contactCreated'], - 'plural' => 'Created %count new contact records.', - ) - ); + array( + 'count' => $result['contactCreated'], + 'plural' => 'Created %count new contact records.', + ) + ); drush_print(dt($status)); return $result; } -- To view, visit https://gerrit.wikimedia.org/r/387507 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ia9792ce1c4902a77a8535a1a3251fa8a6d3b0000 Gerrit-PatchSet: 1 Gerrit-Project: wikimedia/fundraising/crm/civicrm Gerrit-Branch: master Gerrit-Owner: Eileen <emcnaugh...@wikimedia.org> Gerrit-Reviewer: Ejegg <ej...@ejegg.com> Gerrit-Reviewer: Mepps <me...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits