You are here

function xmlsitemap_get_chunk_size in XML sitemap 2.x

Same name and namespace in other branches
  1. 8 xmlsitemap.module \xmlsitemap_get_chunk_size()
  2. 6.2 xmlsitemap.module \xmlsitemap_get_chunk_size()
  3. 7.2 xmlsitemap.module \xmlsitemap_get_chunk_size()

Get the sitemap chunk size.

This function is useful with the chunk size is set to automatic as it will calculate the appropriate value. Use this function instead of

xmlsitemap_var('chunk_size');

when the actual value is needed.

Parameters

bool $reset: A boolean to reset the saved, static result. Defaults to FALSE.

Return value

int An integer with the number of links in each sitemap page.

4 calls to xmlsitemap_get_chunk_size()
XmlSitemapGenerator::generateChunk in src/XmlSitemapGenerator.php
Generates one chunk of the sitemap.
XmlSitemapGenerator::getOptimalMemoryLimit in src/XmlSitemapGenerator.php
Calculate the optimal PHP memory limit for sitemap generation.
xmlsitemap_get_chunk_count in ./xmlsitemap.module
Get the current number of sitemap chunks.
xmlsitemap_requirements in ./xmlsitemap.install
Implements hook_requirements().

File

./xmlsitemap.module, line 1063
xmlsitemap XML sitemap

Code

function xmlsitemap_get_chunk_size($reset = FALSE) {
  static $size;
  if (!isset($size) || $reset) {
    $size = xmlsitemap_var('chunk_size');
    if ($size === 'auto') {

      // Prevent divide by zero.
      $count = max(xmlsitemap_get_link_count($reset), 1);
      $size = min(ceil($count / 10000) * 5000, XMLSITEMAP_MAX_SITEMAP_LINKS);
    }
  }
  return $size;
}