You are here

function xmlsitemap_update_6203 in XML sitemap 7.2

Same name and namespace in other branches
  1. 6.2 xmlsitemap.install \xmlsitemap_update_6203()

Implements hook_update_N().

Convert the xmlsitemap_max_filesize variable to a max_filesize column per-sitemap.

1 call to xmlsitemap_update_6203()
xmlsitemap_update_7202 in ./xmlsitemap.install
Implements hook_update_N().

File

./xmlsitemap.install, line 481
Install, update and uninstall functions for the xmlsitemap module.

Code

function xmlsitemap_update_6203() {
  if (db_field_exists('xmlsitemap_sitemap', 'max_filesize')) {
    return;
  }

  // Add the max_filesize column.
  $field = array(
    'type' => 'int',
    'unsigned' => TRUE,
    'not null' => TRUE,
    'default' => 0,
  );
  db_add_field('xmlsitemap_sitemap', 'max_filesize', $field);

  // Scan each sitemap directory for the largest file.
  drupal_load('module', 'xmlsitemap');
  $sitemaps = xmlsitemap_sitemap_load_multiple(FALSE);
  foreach ($sitemaps as $sitemap) {
    xmlsitemap_sitemap_get_max_filesize($sitemap);
    db_update('xmlsitemap_sitemap')
      ->fields(array(
      'max_filesize' => $sitemap->max_filesize,
    ))
      ->condition('smid', $sitemap->smid)
      ->execute();
  }
  variable_del('xmlsitemap_max_filesize');
  variable_del('xmlsitemap_max_chunks');
}