xmlsitemap.install 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586
  1. <?php
  2. /**
  3. * @file
  4. * Install, update and uninstall functions for the xmlsitemap module.
  5. *
  6. * @ingroup xmlsitemap
  7. */
  8. /**
  9. * Implements hook_requirements().
  10. */
  11. function xmlsitemap_requirements($phase) {
  12. $requirements = array();
  13. $t = get_t();
  14. // Check that required PHP extensions are enabled.
  15. // Note: Drupal 7 already requires the 'xml' extension.
  16. $required_extensions = array('xmlwriter');
  17. $missing_extensions = array_diff($required_extensions, array_filter($required_extensions, 'extension_loaded'));
  18. if (!empty($missing_extensions)) {
  19. $requirements['xmlsitemap_php_extensions'] = array(
  20. 'title' => $t('XML sitemap PHP extensions'),
  21. 'value' => $t('Disabled'),
  22. 'severity' => REQUIREMENT_ERROR,
  23. 'description' => $t("The XML sitemap module requires you to enable the PHP extensions in the following list (see the <a href=\"@xmlsitemap_requirements\">module's system requirements page</a> for more information):", array(
  24. '@xmlsitemap_requirements' => 'https://www.drupal.org/documentation/modules/xmlsitemap/requirements',
  25. )) . theme('item_list', array('items' => $missing_extensions)),
  26. );
  27. }
  28. if ($phase == 'runtime') {
  29. // If clean URLs are disabled there must not be an actual sitemap.xml in
  30. // the root directory.
  31. if (variable_get('clean_url', 0) && file_exists(DRUPAL_ROOT . '/sitemap.xml')) {
  32. $requirements['xmlsitemap_file'] = array(
  33. 'title' => $t('XML sitemap'),
  34. 'value' => $t('Existing sitemap.xml file found.'),
  35. 'severity' => REQUIREMENT_ERROR,
  36. 'description' => $t('The XML sitemap module cannot display its XML output if there is an existing sitemap.xml file in your website root.'),
  37. );
  38. }
  39. // Check that the base directory and all its subdirectories are writable.
  40. $requirements['xmlsitemap_directory'] = array(
  41. 'title' => $t('XML sitemap cache directory'),
  42. 'value' => $t('Writable'),
  43. );
  44. if (!xmlsitemap_check_directory()) {
  45. $requirements['xmlsitemap_directory']['value'] = $t('Not found or not writable');
  46. $requirements['xmlsitemap_directory']['severity'] = REQUIREMENT_ERROR;
  47. $requirements['xmlsitemap_directory']['description'] = $t('The directory %directory was not found or is not writable by the server. See <a href="@docpage">@docpage</a> for more information.', array('%directory' => xmlsitemap_get_directory(), '@docpage' => 'https://www.drupal.org/node/244924'));
  48. }
  49. else {
  50. $directories = xmlsitemap_check_all_directories();
  51. foreach ($directories as $directory => $writable) {
  52. if ($writable) {
  53. unset($directories[$directory]);
  54. }
  55. }
  56. if (!empty($directories)) {
  57. $requirements['xmlsitemap_directory']['value'] = $t('Not found or not writable');
  58. $requirements['xmlsitemap_directory']['severity'] = REQUIREMENT_ERROR;
  59. $requirements['xmlsitemap_directory']['description'] = $t('The following directories were not found or are not writable by the server. See <a href="@docpage">@docpage</a> for more information. !directories', array(
  60. '!directories' => theme('item_list', array(
  61. 'items' => array_keys($directories),
  62. )), '@docpage' => 'https://www.drupal.org/node/244924',
  63. ));
  64. }
  65. }
  66. // The maximum number of links in a sitemap.
  67. $max_links = db_query("SELECT MAX(links) FROM {xmlsitemap_sitemap}")->fetchField();
  68. $max_links_limit = XMLSITEMAP_MAX_SITEMAP_LINKS * XMLSITEMAP_MAX_SITEMAP_LINKS;
  69. if ($max_links > $max_links_limit) {
  70. $requirements['xmlsitemap_link_count'] = array(
  71. 'title' => $t('XML sitemap link count'),
  72. 'value' => $max_links,
  73. 'description' => $t('You have exceeded the number of links that your sitemap can contain (@num).', array('@num' => number_format($max_links))),
  74. 'severity' => REQUIREMENT_ERROR,
  75. );
  76. }
  77. // The maximum number of chunks in a sitemap.
  78. $max_chunks = db_query("SELECT MAX(chunks) FROM {xmlsitemap_sitemap}")->fetchField();
  79. if ($max_chunks > XMLSITEMAP_MAX_SITEMAP_LINKS) {
  80. $requirements['xmlsitemap_chunk_count'] = array(
  81. 'title' => $t('XML sitemap page count'),
  82. 'value' => $max_chunks,
  83. 'description' => $t('You have exceeded the number of sitemap pages (@number).', array('@number' => number_format(XMLSITEMAP_MAX_SITEMAP_LINKS))),
  84. 'severity' => REQUIREMENT_ERROR,
  85. );
  86. if (!in_array(xmlsitemap_get_chunk_size(), array(50000, 'auto'))) {
  87. $requirements['xmlsitemap_chunk_count']['description'] .= ' ' . t('Please increase the number of links per page.');
  88. }
  89. }
  90. // Check maximum file size.
  91. $max_filesize = db_query("SELECT MAX(max_filesize) FROM {xmlsitemap_sitemap}")->fetchField();
  92. $requirements['xmlsitemap_file_size'] = array(
  93. 'title' => $t('XML sitemap maximum file size'),
  94. 'value' => format_size($max_filesize),
  95. );
  96. if ($max_filesize > XMLSITEMAP_MAX_SITEMAP_FILESIZE) {
  97. $requirements['xmlsitemap_file_size']['description'] = $t('You have exceeded the maximum sitemap file size of @size. If possible, decrease the number of links per sitemap page.', array('@size' => format_size(XMLSITEMAP_MAX_SITEMAP_FILESIZE)));
  98. $requirements['xmlsitemap_file_size']['severity'] = REQUIREMENT_ERROR;
  99. }
  100. elseif (!variable_get('xmlsitemap_developer_mode', 0)) {
  101. unset($requirements['xmlsitemap_file_size']);
  102. }
  103. // Check when the cached files were last generated.
  104. $generated_last = variable_get('xmlsitemap_generated_last', 0);
  105. $generated_ago = REQUEST_TIME - $generated_last;
  106. $requirements['xmlsitemap_generated'] = array(
  107. 'title' => $t('XML sitemap'),
  108. 'value' => $generated_last ? $t('Last attempted generation on !date (!interval ago).', array(
  109. '!date' => format_date($generated_last, 'small'),
  110. '!interval' => format_interval($generated_ago),
  111. )) : $t('Cached files have not been generated yet.'),
  112. 'severity' => REQUIREMENT_OK,
  113. );
  114. if (variable_get('xmlsitemap_rebuild_needed', FALSE) && _xmlsitemap_rebuild_form_access()) {
  115. $requirements['xmlsitemap_generated']['severity'] = REQUIREMENT_ERROR;
  116. $requirements['xmlsitemap_generated']['description'] = $t('The XML sitemap data is out of sync and needs to be <a href="@link-rebuild">completely rebuilt<a>.', array('@link-rebuild' => url('admin/config/search/xmlsitemap/rebuild')));
  117. }
  118. elseif (variable_get('xmlsitemap_regenerate_needed', FALSE)) {
  119. if ($max_filesize == 0) {
  120. // A maximum sitemap file size of 0 indicates an error in generation.
  121. $requirements['xmlsitemap_generated']['severity'] = REQUIREMENT_ERROR;
  122. }
  123. elseif ($generated_ago >= variable_get('cron_threshold_error', 1209600)) {
  124. $requirements['xmlsitemap_generated']['severity'] = REQUIREMENT_ERROR;
  125. }
  126. elseif ($generated_ago >= variable_get('cron_threshold_warning', 172800)) {
  127. $requirements['xmlsitemap_generated']['severity'] = REQUIREMENT_WARNING;
  128. }
  129. if ($requirements['xmlsitemap_generated']['severity']) {
  130. $requirements['xmlsitemap_generated']['description'] = $t('The XML cached files are out of date and need to be regenerated. You can <a href="@link-cron">run cron manually</a> to regenerate the sitemap files.', array('@link-cron' => url('admin/reports/status/run-cron', array('query' => drupal_get_destination()))));
  131. }
  132. }
  133. }
  134. return $requirements;
  135. }
  136. /**
  137. * Implements hook_schema().
  138. */
  139. function xmlsitemap_schema() {
  140. // @todo Rename to xmlsitemap_link
  141. $schema['xmlsitemap'] = array(
  142. 'description' => 'The base table for xmlsitemap links.',
  143. 'fields' => array(
  144. 'id' => array(
  145. 'description' => 'Primary key with type; a unique id for the item.',
  146. 'type' => 'int',
  147. 'not null' => TRUE,
  148. 'unsigned' => TRUE,
  149. 'default' => 0,
  150. ),
  151. 'type' => array(
  152. 'description' => 'Primary key with id; the type of item (e.g. node, user, etc.).',
  153. 'type' => 'varchar',
  154. 'length' => 32,
  155. 'not null' => TRUE,
  156. 'default' => '',
  157. ),
  158. 'subtype' => array(
  159. 'description' => 'A sub-type identifier for the link (node type, menu name, term VID, etc.).',
  160. 'type' => 'varchar',
  161. 'length' => 128,
  162. 'not null' => TRUE,
  163. 'default' => '',
  164. ),
  165. 'loc' => array(
  166. 'description' => 'The URL to the item relative to the Drupal path.',
  167. 'type' => 'varchar',
  168. 'length' => 255,
  169. 'not null' => TRUE,
  170. 'default' => '',
  171. ),
  172. 'language' => array(
  173. 'description' => 'The {languages}.language of this link or an empty string if it is language-neutral.',
  174. 'type' => 'varchar',
  175. 'length' => 12,
  176. 'not null' => TRUE,
  177. 'default' => '',
  178. ),
  179. 'access' => array(
  180. 'description' => 'A boolean that represents if the item is viewable by the anonymous user. This field is useful to store the result of node_access() so we can retain changefreq and priority_override information.',
  181. 'type' => 'int',
  182. 'size' => 'tiny',
  183. 'not null' => TRUE,
  184. 'default' => 1,
  185. ),
  186. 'status' => array(
  187. 'description' => 'An integer that represents if the item is included in the sitemap.',
  188. 'type' => 'int',
  189. 'size' => 'tiny',
  190. 'not null' => TRUE,
  191. 'default' => 1,
  192. ),
  193. 'status_override' => array(
  194. 'description' => 'A boolean that if TRUE means that the status field has been overridden from its default value.',
  195. 'type' => 'int',
  196. 'size' => 'tiny',
  197. 'not null' => TRUE,
  198. 'default' => 0,
  199. ),
  200. 'lastmod' => array(
  201. 'description' => 'The UNIX timestamp of last modification of the item.',
  202. 'type' => 'int',
  203. 'unsigned' => TRUE,
  204. 'not null' => TRUE,
  205. 'default' => 0,
  206. ),
  207. 'priority' => array(
  208. 'description' => 'The priority of this URL relative to other URLs on your site. Valid values range from 0.0 to 1.0.',
  209. 'type' => 'float',
  210. 'default' => NULL,
  211. // @todo Convert this field to non-nullable.
  212. // 'default' => 0.5,
  213. // 'not null' => NULL,
  214. ),
  215. 'priority_override' => array(
  216. 'description' => 'A boolean that if TRUE means that the priority field has been overridden from its default value.',
  217. 'type' => 'int',
  218. 'size' => 'tiny',
  219. 'not null' => TRUE,
  220. 'default' => 0,
  221. ),
  222. 'changefreq' => array(
  223. 'description' => 'The average time in seconds between changes of this item.',
  224. 'type' => 'int',
  225. 'unsigned' => TRUE,
  226. 'not null' => TRUE,
  227. 'default' => 0,
  228. ),
  229. 'changecount' => array(
  230. 'description' => 'The number of times this item has been changed. Used to help calculate the next changefreq value.',
  231. 'type' => 'int',
  232. 'unsigned' => TRUE,
  233. 'not null' => TRUE,
  234. 'default' => 0,
  235. ),
  236. ),
  237. 'primary key' => array('id', 'type'),
  238. 'indexes' => array(
  239. 'loc' => array('loc'),
  240. 'access_status_loc' => array('access', 'status', 'loc'),
  241. 'type_subtype' => array('type', 'subtype'),
  242. 'language' => array('language'),
  243. ),
  244. );
  245. $schema['xmlsitemap_sitemap'] = array(
  246. 'fields' => array(
  247. 'smid' => array(
  248. 'description' => 'The sitemap ID (the hashed value of {xmlsitemap}.context.',
  249. 'type' => 'varchar',
  250. 'length' => 64,
  251. 'not null' => TRUE,
  252. ),
  253. 'context' => array(
  254. 'description' => 'Serialized array with the sitemaps context',
  255. 'type' => 'text',
  256. 'not null' => TRUE,
  257. 'serialize' => TRUE,
  258. ),
  259. 'updated' => array(
  260. 'type' => 'int',
  261. 'unsigned' => TRUE,
  262. 'not null' => TRUE,
  263. 'default' => 0,
  264. ),
  265. 'links' => array(
  266. 'type' => 'int',
  267. 'unsigned' => TRUE,
  268. 'not null' => TRUE,
  269. 'default' => 0,
  270. ),
  271. 'chunks' => array(
  272. 'type' => 'int',
  273. 'unsigned' => TRUE,
  274. 'not null' => TRUE,
  275. 'default' => 0,
  276. ),
  277. 'max_filesize' => array(
  278. 'type' => 'int',
  279. 'unsigned' => TRUE,
  280. 'not null' => TRUE,
  281. 'default' => 0,
  282. ),
  283. // @codingStandardsIgnoreStart
  284. // 'queued' => array(
  285. // 'type' => 'int',
  286. // 'unsigned' => TRUE,
  287. // 'not null' => TRUE,
  288. // 'default' => 0,
  289. // 'description' => 'Time when this sitemap was queued for regeneration, 0 if not queued.',
  290. // ),.
  291. // @codingStandardsIgnoreEnd
  292. ),
  293. 'primary key' => array('smid'),
  294. );
  295. return $schema;
  296. }
  297. /**
  298. * Implements hook_install().
  299. */
  300. function xmlsitemap_install() {
  301. // Set this module's weight to 1 so xmlsitemap_cron() runs after all other
  302. // xmlsitemap_x_cron() runs.
  303. db_update('system')
  304. ->fields(array('weight' => 1))
  305. ->condition('type', 'module')
  306. ->condition('name', 'xmlsitemap')
  307. ->execute();
  308. // Load the module.
  309. drupal_load('module', 'xmlsitemap');
  310. // Insert the homepage link into the {xmlsitemap} table so we do not show an
  311. // empty sitemap after install.
  312. db_insert('xmlsitemap')
  313. ->fields(array(
  314. 'type' => 'frontpage',
  315. 'id' => 0,
  316. 'loc' => '',
  317. 'priority' => variable_get('xmlsitemap_frontpage_priority', 1.0),
  318. 'changefreq' => variable_get('xmlsitemap_frontpage_changefreq', XMLSITEMAP_FREQUENCY_DAILY),
  319. 'language' => LANGUAGE_NONE,
  320. ))
  321. ->execute();
  322. // Insert the default context sitemap.
  323. $context = array();
  324. db_insert('xmlsitemap_sitemap')
  325. ->fields(array(
  326. 'smid' => xmlsitemap_sitemap_get_context_hash($context),
  327. 'context' => serialize($context),
  328. ))
  329. ->execute();
  330. // @todo Does the sitemap show up on first install or is it a 404 page?
  331. // Create the link process the queue.
  332. /** @var DrupalReliableQueueInterface $queue */
  333. $queue = DrupalQueue::get('xmlsitemap_link_process', TRUE);
  334. $queue->createQueue();
  335. }
  336. /**
  337. * Implements hook_enable().
  338. */
  339. function xmlsitemap_enable() {
  340. // Ensure the file cache directory is available and ready.
  341. xmlsitemap_check_directory();
  342. variable_set('xmlsitemap_regenerate_needed', TRUE);
  343. }
  344. /**
  345. * Implements hook_uninstall().
  346. */
  347. function xmlsitemap_uninstall() {
  348. // Remove variables.
  349. drupal_load('module', 'xmlsitemap');
  350. $variables = array_keys(xmlsitemap_variables());
  351. foreach ($variables as $variable) {
  352. variable_del($variable);
  353. }
  354. // Remove the file cache directory.
  355. xmlsitemap_clear_directory(NULL, TRUE);
  356. // Remove the queue.
  357. /** @var DrupalReliableQueueInterface $queue */
  358. $queue = DrupalQueue::get('xmlsitemap_link_process', TRUE);
  359. $queue->deleteQueue();
  360. }
  361. /**
  362. * Implements hook_update_last_removed().
  363. */
  364. function xmlsitemap_update_last_removed() {
  365. return 6201;
  366. }
  367. /**
  368. * Create the {xmlsitemap_sitemap} table and add the sitemap context data.
  369. */
  370. function xmlsitemap_update_6202() {
  371. if (!db_table_exists('xmlsitemap_sitemap')) {
  372. $schema['xmlsitemap_sitemap'] = array(
  373. 'fields' => array(
  374. 'smid' => array(
  375. 'description' => 'Sitemap ID',
  376. 'type' => 'serial',
  377. 'unsigned' => TRUE,
  378. 'not null' => TRUE,
  379. ),
  380. 'context_hash' => array(
  381. 'description' => 'The MD5 hash of the context field.',
  382. 'type' => 'varchar',
  383. 'length' => 32,
  384. 'not null' => TRUE,
  385. 'default' => '',
  386. ),
  387. 'context' => array(
  388. 'description' => 'Serialized array with the sitemaps context',
  389. 'type' => 'text',
  390. 'not null' => TRUE,
  391. ),
  392. 'updated' => array(
  393. 'type' => 'int',
  394. 'unsigned' => TRUE,
  395. 'not null' => TRUE,
  396. 'default' => 0,
  397. ),
  398. 'links' => array(
  399. 'type' => 'int',
  400. 'unsigned' => TRUE,
  401. 'not null' => TRUE,
  402. 'default' => 0,
  403. ),
  404. 'chunks' => array(
  405. 'type' => 'int',
  406. 'unsigned' => TRUE,
  407. 'not null' => TRUE,
  408. 'default' => 0,
  409. ),
  410. ),
  411. 'primary key' => array('smid'),
  412. 'unique keys' => array(
  413. 'context_hash' => array('context_hash'),
  414. ),
  415. );
  416. db_create_table('xmlsitemap_sitemap', $schema['xmlsitemap_sitemap']);
  417. }
  418. // Add the default sitemap(s) and use language contexts if possible.
  419. if (!db_query_range("SELECT 1 FROM {xmlsitemap_sitemap}", 0, 1)->fetchField()) {
  420. // Refresh the schema and load the module if it's disabled.
  421. drupal_get_schema(NULL, TRUE);
  422. drupal_load('module', 'xmlsitemap');
  423. if (module_exists('xmlsitemap_i18n') && $languages = variable_get('xmlsitemap_languages', array())) {
  424. foreach ($languages as $language) {
  425. $sitemap = new stdClass();
  426. $sitemap->context = array('language' => $language);
  427. xmlsitemap_sitemap_save($sitemap);
  428. }
  429. }
  430. else {
  431. $sitemap = new stdClass();
  432. $sitemap->context = array();
  433. xmlsitemap_sitemap_save($sitemap);
  434. }
  435. }
  436. // Language variable is no longer needed, so go ahead and delete it.
  437. variable_del('xmlsitemap_languages');
  438. // Ensure that the sitemaps will be refreshed on next cron.
  439. variable_set('xmlsitemap_generated_last', 0);
  440. variable_set('xmlsitemap_regenerate_needed', TRUE);
  441. }
  442. /**
  443. * Implements hook_update_N().
  444. *
  445. * Convert the xmlsitemap_max_filesize variable to a max_filesize column
  446. * per-sitemap.
  447. */
  448. function xmlsitemap_update_6203() {
  449. if (db_field_exists('xmlsitemap_sitemap', 'max_filesize')) {
  450. return;
  451. }
  452. // Add the max_filesize column.
  453. $field = array(
  454. 'type' => 'int',
  455. 'unsigned' => TRUE,
  456. 'not null' => TRUE,
  457. 'default' => 0,
  458. );
  459. db_add_field('xmlsitemap_sitemap', 'max_filesize', $field);
  460. // Scan each sitemap directory for the largest file.
  461. drupal_load('module', 'xmlsitemap');
  462. $sitemaps = xmlsitemap_sitemap_load_multiple(FALSE);
  463. foreach ($sitemaps as $sitemap) {
  464. xmlsitemap_sitemap_get_max_filesize($sitemap);
  465. db_update('xmlsitemap_sitemap')
  466. ->fields(array('max_filesize' => $sitemap->max_filesize))
  467. ->condition('smid', $sitemap->smid)
  468. ->execute();
  469. }
  470. variable_del('xmlsitemap_max_filesize');
  471. variable_del('xmlsitemap_max_chunks');
  472. }
  473. /**
  474. * Convert {xmlsitemap}.context_hash to replace {xmlsitemap}.smid.
  475. */
  476. function xmlsitemap_update_6204() {
  477. if (db_field_exists('xmlsitemap_sitemap', 'context_hash')) {
  478. db_drop_unique_key('xmlsitemap_sitemap', 'context_hash');
  479. db_drop_field('xmlsitemap_sitemap', 'smid');
  480. // Rename context_hash to the new smid column.
  481. $smid_field = array(
  482. 'description' => 'The sitemap ID (the hashed value of {xmlsitemap}.context.',
  483. 'type' => 'varchar',
  484. 'length' => 64,
  485. 'not null' => TRUE,
  486. );
  487. db_change_field('xmlsitemap_sitemap', 'context_hash', 'smid', $smid_field);
  488. // Re-add the primary key now that the smid field is changed.
  489. // We don't need to drop the primary key since we already dropped the field
  490. // that was the primary key.
  491. db_add_primary_key('xmlsitemap_sitemap', array('smid'));
  492. }
  493. _xmlsitemap_sitemap_rehash_all();
  494. }
  495. /**
  496. * Update empty string languages to LANGUAGE_NONE.
  497. */
  498. function xmlsitemap_update_7200() {
  499. db_update('xmlsitemap')
  500. ->fields(array('language' => LANGUAGE_NONE))
  501. ->condition('language', '')
  502. ->execute();
  503. }
  504. /**
  505. * Re-run xmlsitemap_update_6202() to ensure sitemap data has been added.
  506. */
  507. function xmlsitemap_update_7201() {
  508. xmlsitemap_update_6202();
  509. }
  510. /**
  511. * Implements hook_update_N().
  512. *
  513. * Convert the xmlsitemap_max_filesize variable to a max_filesize column
  514. * per-sitemap.
  515. */
  516. function xmlsitemap_update_7202() {
  517. xmlsitemap_update_6203();
  518. }
  519. /**
  520. * Convert {xmlsitemap}.context_hash to replace {xmlsitemap}.smid.
  521. */
  522. function xmlsitemap_update_7203() {
  523. xmlsitemap_update_6204();
  524. _xmlsitemap_sitemap_rehash_all();
  525. }
  526. /**
  527. * Rehash all.
  528. */
  529. function _xmlsitemap_sitemap_rehash_all() {
  530. // Reload the schema cache and reprocess all sitemap hashes into smids.
  531. drupal_load('module', 'xmlsitemap');
  532. drupal_get_schema(NULL, TRUE);
  533. // Force a rehash of all sitemaps.
  534. $sitemaps = xmlsitemap_sitemap_load_multiple(FALSE);
  535. foreach ($sitemaps as $sitemap) {
  536. $hash = xmlsitemap_sitemap_get_context_hash($sitemap->context);
  537. if ($hash != $sitemap->smid) {
  538. xmlsitemap_sitemap_save($sitemap);
  539. }
  540. }
  541. }