How to convert hook_xmlsitemap_links to xmlsitemap 6.x-2.x API? While writing a test harness for a module I wrote, I discovered my implementation of hook_xmlsitemap_links wasn't actually called anymore.

The module doesn't work with nodes but gets data from sources other than Drupal and themes that. It implemented hook_xmlsitemap_links to add its urls to the sitemap.

Is there some documentation on how to replace a hook implementation with its equivalent(s) in the new 6.x-2.x API, that breaks my search-fu style?

I found it is "kinda hard to explain" and was reading the code like suggested.
There doesn't seem to be hook anymore to return links for further processing, but
 adding and deleting links is done with calls to xmlsitemap_link_save and xmlsitemap_link_delete(_multiple)

I implemented a hook_xmlsitemap_index_links, which normally is only called when the command drush xmlsitemap-index is issued:

function my_xmlsitemap_index_links($limit) {
  $sql = "SELECT x.id FROM {xmlsitemap} x WHERE x.type = 'my'";
  $query = db_query($sql);
  $indexed = xmlsitemap_db_fetch_col($query);
  //there isn't a lot of stuff, it fits in memory, but fetching it is costly.
  $indexed = array_flip($indexed);
  $mystuff = __my_get_stuff();
  $i = 0;
  foreach ( $mystuff as $thing ) {
    if ( !isset($indexed[$thing-&gt;id]) ) {
      # new thing
      xmlsitemap_link_save(__my_make_xmlsitemap_link($thing), $thing-&gt;id);
      $i++;
    }
    unset($indexed[$thing-&gt;id]);
    if ( $i == $limit )
      return;
  }
  #Done indexing new stuff;
  if ( $indexed ) {
    $deleted = array_flip($indexed);
    xmlsitemap_link_delete_multiple(array('type'=&gt;'my', 'id'=&gt;$deleted));
  }
}


I'm still puzzling on what to return from my hook_xmlsitemap_link_info. It's not at all clear when those callbacks are called. 


The process callback is useless for this usecase; xmlsitemap has no way of knowing any foreign IDs.
The rebuild callback is afaik only called by drush and manual action, not a means of keeping the links up to date, but it remains unclear if such a callback is required or optional (although xmlsitemap_custom seems to manage without one)
The settings callback is still a mistery to me, but it's used for the admin.


This hook_xmlsitemap_link_info with my_xmlsitemap_index_links as rebuild callback, makes my module reindex when I issue a rebuild command from the admin.

function my_xmlsitemap_link_info() {
  return array(
    'my' =&gt; array(
      'label' =&gt; t('My Stuff'),
      'xmlsitemap' =&gt; array(
        'rebuild callback' =&gt; 'my_xmlsitemap_index_links',
        ),
      )
    );
}


I ended up implementing a hook_cron that periodically calls my_xmlsitemap_index_links, to keep it in sync.

I might update my hook_load, to issue a xmlsitemap_link_delete on failed loads (404's).