search_api.drush.inc 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  1. <?php
  2. /**
  3. * @file
  4. * Drush commands for SearchAPI.
  5. *
  6. * Original file by agentrickard for Palantir.net
  7. */
  8. /**
  9. * Implements hook_drush_command().
  10. */
  11. function search_api_drush_command() {
  12. $items = array();
  13. $items['search-api-list'] = array(
  14. 'description' => 'List all search indexes.',
  15. 'examples' => array(
  16. 'drush searchapi-list' => dt('List all search indexes.'),
  17. 'drush sapi-l' => dt('Alias to list all search indexes.'),
  18. ),
  19. 'aliases' => array('sapi-l'),
  20. );
  21. $items['search-api-enable'] = array(
  22. 'description' => 'Enable one or all disabled search_api indexes.',
  23. 'examples' => array(
  24. 'drush searchapi-enable' => dt('Enable all disabled indexes.'),
  25. 'drush sapi-en' => dt('Alias to enable all disabled indexes.'),
  26. 'drush sapi-en 1' => dt('Enable index with the ID !id.', array('!id' => 1)),
  27. ),
  28. 'arguments' => array(
  29. 'index_id' => dt('The numeric ID or machine name of an index to enable.'),
  30. ),
  31. 'aliases' => array('sapi-en'),
  32. );
  33. $items['search-api-disable'] = array(
  34. 'description' => 'Disable one or all enabled search_api indexes.',
  35. 'examples' => array(
  36. 'drush searchapi-disable' => dt('Disable all enabled indexes.'),
  37. 'drush sapi-dis' => dt('Alias to disable all enabled indexes.'),
  38. 'drush sapi-dis 1' => dt('Disable index with the ID !id.', array('!id' => 1)),
  39. ),
  40. 'arguments' => array(
  41. 'index_id' => dt('The numeric ID or machine name of an index to disable.'),
  42. ),
  43. 'aliases' => array('sapi-dis'),
  44. );
  45. $items['search-api-status'] = array(
  46. 'description' => 'Show the status of one or all search indexes.',
  47. 'examples' => array(
  48. 'drush searchapi-status' => dt('Show the status of all search indexes.'),
  49. 'drush sapi-s' => dt('Alias to show the status of all search indexes.'),
  50. 'drush sapi-s 1' => dt('Show the status of the search index with the ID !id.', array('!id' => 1)),
  51. 'drush sapi-s default_node_index' => dt('Show the status of the search index with the machine name !name.', array('!name' => 'default_node_index')),
  52. ),
  53. 'arguments' => array(
  54. 'index_id' => dt('The numeric ID or machine name of an index.'),
  55. ),
  56. 'aliases' => array('sapi-s'),
  57. );
  58. $items['search-api-index'] = array(
  59. 'description' => 'Index items for one or all enabled search_api indexes.',
  60. 'examples' => array(
  61. 'drush searchapi-index' => dt('Index items for all enabled indexes.'),
  62. 'drush sapi-i' => dt('Alias to index items for all enabled indexes.'),
  63. 'drush sapi-i 1' => dt('Index items for the index with the ID !id.', array('!id' => 1)),
  64. 'drush sapi-i default_node_index' => dt('Index items for the index with the machine name !name.', array('!name' => 'default_node_index')),
  65. 'drush sapi-i 1 100' => dt("Index a maximum number of !limit items (index's cron batch size items per batch run) for the index with the ID !id.", array('!limit' => 100, '!id' => 1)),
  66. 'drush sapi-i 1 100 10' => dt("Index a maximum number of !limit items (!batch_size items per batch run) for the index with the ID !id.", array('!limit' => 100, '!batch_size' => 10, '!id' => 1)),
  67. ),
  68. 'arguments' => array(
  69. 'index_id' => dt('The numeric ID or machine name of an index.'),
  70. 'limit' => dt("The number of items to index (index's cron batch size items per run). Set to 0 to index all items. Defaults to 0 (index all)."),
  71. 'batch_size' => dt("The number of items to index per batch run. Set to 0 to index all items at once. Defaults to the index's cron batch size."),
  72. ),
  73. 'aliases' => array('sapi-i'),
  74. );
  75. $items['search-api-reindex'] = array(
  76. 'description' => 'Force reindexing of one or all search indexes, without clearing existing index data.',
  77. 'examples' => array(
  78. 'drush searchapi-reindex' => dt('Schedule all search indexes for reindexing.'),
  79. 'drush sapi-r' => dt('Alias to schedule all search indexes for reindexing .'),
  80. 'drush sapi-r 1' => dt('Schedule the search index with the ID !id for re-indexing.', array('!id' => 1)),
  81. 'drush sapi-r default_node_index' => dt('Schedule the search index with the machine name !name for re-indexing.', array('!name' => 'default_node_index')),
  82. ),
  83. 'arguments' => array(
  84. 'index_id' => dt('The numeric ID or machine name of an index.'),
  85. ),
  86. 'aliases' => array('sapi-r'),
  87. );
  88. $items['search-api-clear'] = array(
  89. 'description' => 'Clear one or all search indexes and mark them for re-indexing.',
  90. 'examples' => array(
  91. 'drush searchapi-clear' => dt('Clear all search indexes.'),
  92. 'drush sapi-c' => dt('Alias to clear all search indexes.'),
  93. 'drush sapi-c 1' => dt('Clear the search index with the ID !id.', array('!id' => 1)),
  94. 'drush sapi-c default_node_index' => dt('Clear the search index with the machine name !name.', array('!name' => 'default_node_index')),
  95. ),
  96. 'arguments' => array(
  97. 'index_id' => dt('The numeric ID or machine name of an index.'),
  98. ),
  99. 'aliases' => array('sapi-c'),
  100. );
  101. $items['search-api-set-index-server'] = array(
  102. 'description' => 'Set the search server used by a given index.',
  103. 'examples' => array(
  104. 'drush search-api-set-index-server default_node_index my_solr_server' => dt('Set the !index index to use the !server server.', array('!index' => 'default_node_index', '!server' => 'my_solr_server')),
  105. 'drush sapi-sis default_node_index my_solr_server' => dt('Alias to set the !index index to use the !server server.', array('!index' => 'default_node_index', '!server' => 'my_solr_server')),
  106. ),
  107. 'arguments' => array(
  108. 'index_id' => dt('The numeric ID or machine name of an index.'),
  109. 'server_id' => dt('The numeric ID or machine name of a server to set on the index.'),
  110. ),
  111. 'aliases' => array('sapi-sis'),
  112. );
  113. $items['search-api-server-list'] = array(
  114. 'description' => 'List all search servers.',
  115. 'examples' => array(
  116. 'drush search-api-server-list' => dt('List all search servers.'),
  117. 'drush sapi-sl' => dt('Alias to list all search servers.'),
  118. ),
  119. 'aliases' => array('sapi-sl'),
  120. );
  121. $items['search-api-server-enable'] = array(
  122. 'description' => 'Enable a search server.',
  123. 'examples' => array(
  124. 'drush search-api-server-e my_solr_server' => dt('Enable the !server search server.', array('!server' => 'my_solr_server')),
  125. 'drush sapi-se my_solr_server' => dt('Alias to enable the !server search server.', array('!server' => 'my_solr_server')),
  126. ),
  127. 'arguments' => array(
  128. 'server_id' => dt('The numeric ID or machine name of a search server to enable.'),
  129. ),
  130. 'aliases' => array('sapi-se'),
  131. );
  132. $items['search-api-server-disable'] = array(
  133. 'description' => 'Disable a search server.',
  134. 'examples' => array(
  135. 'drush search-api-server-disable' => dt('Disable the !server search server.', array('!server' => 'my_solr_server')),
  136. 'drush sapi-sd' => dt('Alias to disable the !server search server.', array('!server' => 'my_solr_server')),
  137. ),
  138. 'arguments' => array(
  139. 'server_id' => dt('The numeric ID or machine name of a search server to disable.'),
  140. ),
  141. 'aliases' => array('sapi-sd'),
  142. );
  143. return $items;
  144. }
  145. /**
  146. * List all search indexes.
  147. */
  148. function drush_search_api_list() {
  149. if (search_api_drush_static(__FUNCTION__)) {
  150. return;
  151. }
  152. // See search_api_list_indexes()
  153. $indexes = search_api_index_load_multiple(FALSE);
  154. if (empty($indexes)) {
  155. drush_print(dt('There are no indexes present.'));
  156. return;
  157. }
  158. $rows[] = array(
  159. dt('Id'),
  160. dt('Name'),
  161. dt('Index'),
  162. dt('Server'),
  163. dt('Type'),
  164. dt('Status'),
  165. dt('Limit'),
  166. );
  167. foreach ($indexes as $index) {
  168. $type = search_api_get_item_type_info($index->item_type);
  169. $type = isset($type['name']) ? $type['name'] : $index->item_type;
  170. try {
  171. $server = $index->server();
  172. $server = $server ? $server->name : '(' . dt('none') . ')';
  173. }
  174. catch (SearchApiException $e) {
  175. watchdog_exception('search_api', $e);
  176. $server = '(' . dt('unknown: !server', array('server' => $index->server)) . ')';
  177. }
  178. $row = array(
  179. $index->id,
  180. $index->name,
  181. $index->machine_name,
  182. $server,
  183. $type,
  184. $index->enabled ? dt('enabled') : dt('disabled'),
  185. $index->options['cron_limit'],
  186. );
  187. $rows[] = $row;
  188. }
  189. drush_print_table($rows);
  190. }
  191. /**
  192. * Enable index(es).
  193. *
  194. * @param string|integer $index_id
  195. * The index name or id which should be enabled.
  196. */
  197. function drush_search_api_enable($index_id = NULL) {
  198. if (search_api_drush_static(__FUNCTION__)) {
  199. return;
  200. }
  201. $indexes = search_api_drush_get_index($index_id);
  202. if (empty($indexes)) {
  203. return;
  204. }
  205. foreach ($indexes as $index) {
  206. $vars = array('!index' => $index->name);
  207. if (!$index->enabled) {
  208. drush_log(dt("Enabling index !index and queueing items for indexing.", $vars), 'notice');
  209. $success = FALSE;
  210. try {
  211. if ($success = search_api_index_enable($index->id)) {
  212. drush_log(dt("The index !index was successfully enabled.", $vars), 'ok');
  213. }
  214. }
  215. catch (SearchApiException $e) {
  216. drush_log($e->getMessage(), 'error');
  217. }
  218. if (!$success) {
  219. drush_log(dt("Error enabling index !index.", $vars), 'error');
  220. }
  221. }
  222. else {
  223. drush_log(dt("The index !index is already enabled.", $vars), 'error');
  224. }
  225. }
  226. }
  227. /**
  228. * Disable index(es).
  229. *
  230. * @param string|integer $index_id
  231. * The index name or id which should be disabled.
  232. */
  233. function drush_search_api_disable($index_id = NULL) {
  234. if (search_api_drush_static(__FUNCTION__)) {
  235. return;
  236. }
  237. $indexes = search_api_drush_get_index($index_id);
  238. if (empty($indexes)) {
  239. return;
  240. }
  241. foreach ($indexes as $index) {
  242. $vars = array('!index' => $index->name);
  243. if ($index->enabled) {
  244. $success = FALSE;
  245. try {
  246. if ($success = search_api_index_disable($index->id)) {
  247. drush_log(dt("The index !index was successfully disabled.", $vars), 'ok');
  248. }
  249. }
  250. catch (SearchApiException $e) {
  251. drush_log($e->getMessage(), 'error');
  252. }
  253. if (!$success) {
  254. drush_log(dt("Error disabling index !index.", $vars), 'error');
  255. }
  256. }
  257. else {
  258. drush_log(dt("The index !index is already disabled.", $vars), 'error');
  259. }
  260. }
  261. }
  262. /**
  263. * Display index status.
  264. */
  265. function drush_search_api_status($index_id = NULL) {
  266. if (search_api_drush_static(__FUNCTION__)) {
  267. return;
  268. }
  269. $indexes = search_api_drush_get_index($index_id);
  270. if (empty($indexes)) {
  271. return;
  272. }
  273. // See search_api_index_status()
  274. $rows = array(array(
  275. dt('Id'),
  276. dt('Index'),
  277. dt('% Complete'),
  278. dt('Indexed'),
  279. dt('Total'),
  280. ));
  281. foreach ($indexes as $index) {
  282. $status = search_api_index_status($index);
  283. $complete = ($status['total'] > 0) ? 100 * round($status['indexed'] / $status['total'], 3) . '%' : '-';
  284. $row = array(
  285. $index->id,
  286. $index->name,
  287. $complete,
  288. $status['indexed'],
  289. $status['total'],
  290. );
  291. $rows[] = $row;
  292. }
  293. drush_print_table($rows);
  294. }
  295. /**
  296. * Index items.
  297. *
  298. * @param string|integer $index_id
  299. * The index name or id for which items should be indexed.
  300. * @param integer $limit
  301. * Maximum number of items to index.
  302. * @param integer $batch_size
  303. * Number of items to index per batch.
  304. */
  305. function drush_search_api_index($index_id = NULL, $limit = NULL, $batch_size = NULL) {
  306. if (search_api_drush_static(__FUNCTION__)) {
  307. return;
  308. }
  309. $indexes = search_api_drush_get_index($index_id);
  310. if (empty($indexes)) {
  311. return;
  312. }
  313. $process_batch = FALSE;
  314. foreach ($indexes as $index) {
  315. if (_drush_search_api_batch_indexing_create($index, $limit, $batch_size)) {
  316. $process_batch = TRUE;
  317. }
  318. }
  319. if ($process_batch) {
  320. drush_backend_batch_process();
  321. }
  322. }
  323. /**
  324. * Creates and sets a batch for indexing items for a particular index.
  325. *
  326. * @param SearchApiIndex $index
  327. * The index for which items should be indexed.
  328. * @param int $limit
  329. * (optional) The maximum number of items to index, or NULL to index all
  330. * items.
  331. * @param int $batch_size
  332. * (optional) The number of items to index per batch, or NULL to index all
  333. * items at once.
  334. *
  335. * @return bool
  336. * TRUE if batch was created, FALSE otherwise.
  337. */
  338. function _drush_search_api_batch_indexing_create(SearchApiIndex $index, $limit = NULL, $batch_size = NULL) {
  339. // Get the number of remaining items to index.
  340. try {
  341. $datasource = $index->datasource();
  342. }
  343. catch (SearchApiException $e) {
  344. drush_log($e->getMessage(), 'error');
  345. return FALSE;
  346. }
  347. $index_status = $datasource->getIndexStatus($index);
  348. $remaining = $index_status['total'] - $index_status['indexed'];
  349. if ($remaining <= 0) {
  350. drush_log(dt("The index !index is up to date.", array('!index' => $index->name)), 'ok');
  351. return FALSE;
  352. }
  353. // Get the number of items to index per batch run.
  354. if (!isset($batch_size)) {
  355. $batch_size = empty($index->options['cron_limit']) ? SEARCH_API_DEFAULT_CRON_LIMIT : $index->options['cron_limit'];
  356. }
  357. elseif ($batch_size <= 0) {
  358. $batch_size = $remaining;
  359. }
  360. // Get the total number of items to index.
  361. if (!isset($limit) || !is_int($limit += 0) || $limit <= 0) {
  362. $limit = $remaining;
  363. }
  364. drush_log(dt("Indexing a maximum number of !limit items (!batch_size items per batch run) for the index !index.", array('!index' => $index->name, '!limit' => $limit, '!batch_size' => $batch_size)), 'ok');
  365. // Create the batch.
  366. if (!_search_api_batch_indexing_create($index, $batch_size, $limit, $remaining, TRUE)) {
  367. drush_log(dt("Couldn't create a batch, please check the batch size and limit parameters."), 'error');
  368. return FALSE;
  369. }
  370. return TRUE;
  371. }
  372. /**
  373. * Copy of formal_plural that works with drush as 't' may not be available.
  374. */
  375. function _search_api_drush_format_plural($count, $singular, $plural, array $args = array(), array $options = array()) {
  376. $args['@count'] = $count;
  377. if ($count == 1) {
  378. return dt($singular, $args, $options);
  379. }
  380. // Get the plural index through the gettext formula.
  381. $index = (function_exists('locale_get_plural')) ? locale_get_plural($count, isset($options['langcode']) ? $options['langcode'] : NULL) : -1;
  382. // If the index cannot be computed, use the plural as a fallback (which
  383. // allows for most flexiblity with the replaceable @count value).
  384. if ($index < 0) {
  385. return dt($plural, $args, $options);
  386. }
  387. else {
  388. switch ($index) {
  389. case "0":
  390. return dt($singular, $args, $options);
  391. case "1":
  392. return dt($plural, $args, $options);
  393. default:
  394. unset($args['@count']);
  395. $args['@count[' . $index . ']'] = $count;
  396. return dt(strtr($plural, array('@count' => '@count[' . $index . ']')), $args, $options);
  397. }
  398. }
  399. }
  400. /**
  401. * Mark for re-indexing.
  402. */
  403. function drush_search_api_reindex($index_id = NULL) {
  404. if (search_api_drush_static(__FUNCTION__)) {
  405. return;
  406. }
  407. $indexes = search_api_drush_get_index($index_id);
  408. if (empty($indexes)) {
  409. return;
  410. }
  411. // See search_api_index_reindex()
  412. foreach ($indexes as $index) {
  413. $index->reindex();
  414. drush_log(dt('!index was successfully marked for re-indexing.', array('!index' => $index->machine_name)), 'ok');
  415. }
  416. }
  417. /**
  418. * Clear an index.
  419. */
  420. function drush_search_api_clear($index_id = NULL) {
  421. if (search_api_drush_static(__FUNCTION__)) {
  422. return;
  423. }
  424. $indexes = search_api_drush_get_index($index_id);
  425. if (empty($indexes)) {
  426. return;
  427. }
  428. // See search_api_index_reindex()
  429. foreach ($indexes as $index) {
  430. $index->clear();
  431. drush_log(dt('!index was successfully cleared.', array('!index' => $index->machine_name)), 'ok');
  432. }
  433. }
  434. /**
  435. * Set the server for a given index.
  436. */
  437. function drush_search_api_set_index_server($index_id = NULL, $server_id = NULL) {
  438. if (search_api_drush_static(__FUNCTION__)) {
  439. return;
  440. }
  441. // Make sure we have parameters to work with.
  442. if (empty($index_id) || empty($server_id)) {
  443. drush_log(dt('You must specify both an index and server.'), 'error');
  444. return;
  445. }
  446. // Fetch current index and server data.
  447. $indexes = search_api_drush_get_index($index_id);
  448. $servers = search_api_drush_get_server($server_id);
  449. if (empty($indexes) || empty($servers)) {
  450. // If the specified index or server can't be found, just return. An
  451. // appropriate error message should have been printed already.
  452. return;
  453. }
  454. // Set the new server on the index.
  455. $success = FALSE;
  456. $index = reset($indexes);
  457. $server = reset($servers);
  458. try {
  459. $success = $index->update(array('server' => $server->machine_name));
  460. }
  461. catch (SearchApiException $e) {
  462. drush_log($e->getMessage(), 'error');
  463. }
  464. if ($success === FALSE) {
  465. drush_log(dt('There was an error setting index !index to use server !server.', array('!index' => $index->name, '!server' => $server->name)), 'error');
  466. }
  467. elseif (!$success) {
  468. drush_log(dt('Index !index was already using server !server.', array('!index' => $index->name, '!server' => $server->name)), 'ok');
  469. }
  470. else {
  471. drush_log(dt('Index !index has been set to use server !server and items have been queued for indexing.', array('!index' => $index->name, '!server' => $server->name)), 'ok');
  472. }
  473. }
  474. /**
  475. * Returns an index or all indexes as an array.
  476. *
  477. * @param string|int|null $index_id
  478. * (optional) The ID or machine name of the index to load. Defaults to
  479. * loading all available indexes.
  480. *
  481. * @return SearchApiIndex[]
  482. * An array of indexes.
  483. */
  484. function search_api_drush_get_index($index_id = NULL) {
  485. $ids = isset($index_id) ? array($index_id) : FALSE;
  486. $indexes = search_api_index_load_multiple($ids);
  487. if (empty($indexes)) {
  488. drush_set_error(dt('Invalid index_id or no indexes present. Listing all indexes:'));
  489. drush_print();
  490. drush_search_api_list();
  491. }
  492. return $indexes;
  493. }
  494. /**
  495. * Returns a server or all servers as an array.
  496. *
  497. * @param string|int|null $server_id
  498. * (optional) The ID or machine name of the server to load. Defaults to
  499. * loading all available servers.
  500. *
  501. * @return SearchApiServer[]
  502. * An array of servers.
  503. */
  504. function search_api_drush_get_server($server_id = NULL) {
  505. $ids = isset($server_id) ? array($server_id) : FALSE;
  506. $servers = search_api_server_load_multiple($ids);
  507. if (empty($servers)) {
  508. drush_set_error(dt('Invalid server_id or no servers present.'));
  509. drush_print();
  510. drush_search_api_server_list();
  511. }
  512. return $servers;
  513. }
  514. /**
  515. * Does a static lookup to prevent Drush 4 from running twice.
  516. *
  517. * @param string $function
  518. * The Drush function being called.
  519. *
  520. * @return bool
  521. * TRUE if the function was already called in this Drush execution, FALSE
  522. * otherwise.
  523. *
  524. * @see http://drupal.org/node/704848
  525. */
  526. function search_api_drush_static($function) {
  527. static $index = array();
  528. if (isset($index[$function])) {
  529. return TRUE;
  530. }
  531. $index[$function] = TRUE;
  532. return FALSE;
  533. }
  534. /**
  535. * Lists all search servers.
  536. */
  537. function drush_search_api_server_list() {
  538. if (search_api_drush_static(__FUNCTION__)) {
  539. return;
  540. }
  541. $servers = search_api_server_load_multiple(FALSE);
  542. if (empty($servers)) {
  543. drush_print(dt('There are no servers present.'));
  544. return;
  545. }
  546. $rows[] = array(
  547. dt('Machine name'),
  548. dt('Name'),
  549. dt('Status'),
  550. );
  551. foreach ($servers as $server) {
  552. $row = array(
  553. $server->machine_name,
  554. $server->name,
  555. $server->enabled ? dt('enabled') : dt('disabled'),
  556. );
  557. $rows[] = $row;
  558. }
  559. drush_print_table($rows);
  560. }
  561. /**
  562. * Enables a search server.
  563. *
  564. * @param int|string $server_id
  565. * The numeric ID or machine name of the server to enable.
  566. */
  567. function drush_search_api_server_enable($server_id = NULL) {
  568. if (!isset($server_id)) {
  569. drush_print(dt('Please provide a valid server id.'));
  570. return;
  571. }
  572. $server = search_api_server_load($server_id);
  573. if (empty($server)) {
  574. drush_print(dt('The server was not able to load.'));
  575. return;
  576. }
  577. else {
  578. $server->update(array('enabled' => 1));
  579. drush_print(dt('The server was enabled successfully.'));
  580. }
  581. }
  582. /**
  583. * Disables a search server.
  584. *
  585. * @param int|string $server_id
  586. * The numeric ID or machine name of the server to disable.
  587. */
  588. function drush_search_api_server_disable($server_id = NULL) {
  589. if (!isset($server_id)) {
  590. drush_print(dt('Please provide a valid server id.'));
  591. return;
  592. }
  593. $server = search_api_server_load($server_id);
  594. if (empty($server)) {
  595. drush_print(dt('The server was not able to load.'));
  596. return;
  597. }
  598. else {
  599. $server->update(array('enabled' => 0));
  600. drush_print(dt('The server was disabled successfully.'));
  601. }
  602. }