Hey!

Whenever i clear cache with drush cc all or run cron, I get the following error message:

Warning: Invalid argument supplied for foreach() in xmlsitemap_get_link_type_enabled_bundles() (line 966 of /public_html/sites/all/modules/contrib/xmlsitemap/xmlsitemap.module).

What could be the reason for this?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

farald’s picture

If

xmlsitemap_get_link_info($entity_type);

returns null, we have this error.
First of all, can this happen in normal circumstances?

If yes, wrapping xmlsitemap_get_link_type_enabled_bundles()'s foreach in if(empty($info)){}
would remove it.

farald’s picture

Issue summary: View changes

Minor change

killtheliterate’s picture

I made a little patch for this, if it's not already take care of — just checking that $info isn't null before doing the loop.

kenorb’s picture

Version: 7.x-2.0-beta3 » 7.x-2.2
Status: Active » Needs review
thechanceg’s picture

While I was not able to reproduce your error; I do see how that function could possibly return NULL. Seems sensible to have the check in place, I just made it one line. If not for that I would have just set it to R&TBC.

Chris Matthews’s picture

Version: 7.x-2.2 » 7.x-2.x-dev
Status: Needs review » Needs work
Issue tags: +Needs reroll

The 3 year old patch in #4 to xmlsitemap.module does not apply to the latest xmlsitemap 7.x-2.x-dev and if still applicable needs a reroll.

Checking patch xmlsitemap.module...
error: while searching for:

function xmlsitemap_get_link_type_enabled_bundles($entity_type) {
  $bundles = array();
  $info = xmlsitemap_get_link_info($entity_type);
  foreach ($info['bundles'] as $bundle => $bundle_info) {
    $settings = xmlsitemap_link_bundle_load($entity_type, $bundle);
    if (!empty($settings['status'])) {
    //if (!empty($bundle_info['xmlsitemap']['status'])) {
      $bundles[] = $bundle;
    }
  }
  return $bundles;

error: patch failed: xmlsitemap.module:981
error: xmlsitemap.module: patch does not apply