You are here

function drush_xmlsitemap_rebuild in XML sitemap 7.2

Same name and namespace in other branches
  1. 8 xmlsitemap.drush.inc \drush_xmlsitemap_rebuild()
  2. 6.2 xmlsitemap.drush.inc \drush_xmlsitemap_rebuild()

Dump and rebuild all the sitemap data, then regenerate the files.

1 string reference to 'drush_xmlsitemap_rebuild'
xmlsitemap_drush_command in ./xmlsitemap.drush.inc
Implements hook_drush_command().

File

./xmlsitemap.drush.inc, line 71
Drush integration functions for the xmlsitemap module.

Code

function drush_xmlsitemap_rebuild() {
  module_load_include('generate.inc', 'xmlsitemap');

  // Build a list of rebuildable link types.
  $types = xmlsitemap_get_rebuildable_link_types();
  if ($option_types = drush_get_option('types', '')) {
    $option_types = explode(',', $option_types);
    if ($invalid_types = array_diff($option_types, $types)) {
      drush_set_error(dt('The following link types are invalid: @types', array(
        '@types' => implode(', ', $invalid_types),
      )));
    }
    $types = array_intersect($types, $option_types);
  }
  if (empty($types)) {
    return drush_log(dt('No link types are rebuildable.'), 'warning');
  }

  // Run the batch process.
  timer_start('xmlsitemap_rebuild');
  xmlsitemap_run_unprogressive_batch('xmlsitemap_rebuild_batch', $types, TRUE);
  $vars = array(
    '@timer' => timer_read('xmlsitemap_rebuild'),
    '@memory-peak' => format_size(memory_get_peak_usage(TRUE)),
  );
  drush_print(dt('XML sitemap files rebuilt in @timer ms. Peak memory usage: @memory-peak.', $vars));
}