Quantcast
Channel: Issues for XML sitemap
Viewing all articles
Browse latest Browse all 1238

module_load_all_includes does not include xmlsitemap.xmlsitemap.inc

$
0
0

I think the fix in #1392710: Call to undefined function xmlsitemap_link_frontpage_settings() was not complete/correct.

Let me explain...

We currently call

<?php
module_load_all_includes
('inc', 'xmlsitemap');
?>

it loops all modules and eventually also works on xmlsitemap itself. It then calls
<?php
module_load_include
($type = 'inc', $module = 'xmlsitemap', $name = 'xmlsitemap');
?>

which calls:

<?php
$file
= DRUPAL_ROOT . '/'. drupal_get_path('module', $module = 'xmlsitemap') . "/$name.$type";
?>

Which in my opinion(mental PHP parser) evaluates to e.g. ==> '/var/www/sites/all/modules/contrib/xmlsitemap/xmlsitemap.inc

See below for the function definitions.
The issue #1316822: Move xmlsitemap.xmlsitemap.inc functions() to correct location which was closed as duplicate has some more background....

There is a 'xmlsitemap.inc' and an 'xmlsitemap.xmlsitemap.inc' in this module.
I guess that xmlsitemap_link_frontpage_settings() function can sometimes be loaded because the xmlsitemap.xmlsitemap.inc file also contains classes and is referenced in the .info file.

There are multiple ways to fix this.
* move the functions from If xmlsitemap.xmlsitemap.inc to xmlsitemap.inc as per my patch in http://drupal.org/node/1392710#comment-7276226
* adapt the include statement

<?php
function module_load_all_includes($type, $name = NULL) {
 
$modules = module_list();
  foreach (
$modules as $module) {
   
module_load_include($type, $module, $name);
  }
}
?>

From: http://api.drupal.org/api/drupal/includes!module.inc/function/module_load_all_includes/7

<?php
function module_load_include($type, $module, $name = NULL) {
  if (!isset(
$name)) {
   
$name = $module;
  }

  if (
function_exists('drupal_get_path')) {
   
$file = DRUPAL_ROOT . '/'. drupal_get_path('module', $module) . "/$name.$type";
    if (
is_file($file)) {
      require_once
$file;
      return
$file;
    }
  }
  return
FALSE;
}
?>

From: http://api.drupal.org/api/drupal/includes!module.inc/function/module_load_include/7

Viewing all articles
Browse latest Browse all 1238

Trending Articles