I am getting the following error when trying to go to the settings admin page (admin/config/search/xmlsitemap/settings) while memcache is enabled. Disable it and it works fine.

Fatal error: Call to undefined function xmlsitemap_link_frontpage_settings() in /vagrant/repos/dennis_distro_7/profiles/dennis_distro/modules/contrib/xmlsitemap/xmlsitemap.admin.inc on line 378

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jarrodirwin’s picture

Status: Active » Needs work
FileSize
404 bytes

Due to time constraints and lack of knowledge of this module I have put in a temp fix that simply includes the xmlsitemap.xmlsitemap.inc file in the xmlsitemap.admin.inc file so that the function is always available.

This is less then ideal and the bigger issue should really be address and a proper fix added.

Anonymous’s picture

Status: Needs work » Closed (won't fix)

So the issue then becomes a Drupal core issue or perhaps a memcache user issue. In either case this issue does not belong to xmlsitemap.

Anonymous’s picture

Version: 7.x-2.0-beta3 » 7.x-2.x-dev
Status: Closed (won't fix) » Active

No, I disagree. This is an issue with XML Sitemap code.

The xmlsitemap.xmlsitemap.inc file is only mentioned in xmlsitemap.info
files[] = xmlsitemap.xmlsitemap.inc

This only works for including Classes and Interfaces, *not* functions:

Drupal now supports a dynamic-loading code registry. To support it, all modules must now declare any code files containing class or interface declarations in the .info file, like so:
files[] = example.test

See: http://drupal.org/node/542202

But the function xmlsitemap_link_frontpage_settings() is not a class or interface, just a stand-alone function. This is why Drupal cannot "find" it in case of caching/Memcached or anything.

The real fix is to move the stand-alone functions() in xmlsitemap.xmlsitemap.inc to xmlsitemap.module or xmlsitemap.admin.inc

Anonymous’s picture

Title: Error loading settings page if memcache is enabled » Move xmlsitemap.xmlsitemap.inc functions() to correct location

Improved title

shrikeh’s picture

Verified that the patch posted by jarrodirwin is effective: I no longer suffer fatal error with settings tab. I too have memcache module.

makangus’s picture

Status: Active » Needs review
FileSize
7.37 KB

Moved the public functions from xmlsitemap.xmlsitemap.inc to xmlsitemap.module. Memcache guys please check if this works for you.

Anonymous’s picture

Status: Needs review » Postponed (maintainer needs more info)

Why are we moving these functions?

I don't know that the title is improved. I set this to "won't fix" once already. Give me good reason to leave it open.

makangus’s picture

Don't shoot the messenger, I am just helping out to create some patches, heehee.

@morningtime please correct me if I am wrong, I think the issue is memcache not taking the public functions into memory for the inc files, unless you do a include before you need to call the functions in the inc file.

Anyway, @earnie it's totally your call as a maintainer of what is and is not an issue worth fixing.

Anonymous’s picture

So can http://drupal.org/project/memcache help here? We will not be moving functions from xmlsitemap.xmlsitemap.inc to xmlsitemap.module unless there is a good reason which I don't see yet.

Anonymous’s picture

@makangus

No it's not memcached doing anything wrong. You must either do a include_once/require_once, or move the functions to the .module file (like #6). Because the .module file is always loaded. Drupal .inc files for clases that are included only through the .info file, only read the classes, not the functions. So if you never do a include_once/require_once, then obviously those functions are never read unless Drupal loads the class file, which you can't depend on in this case.

So #6 is the fix.

Anonymous’s picture

Status: Postponed (maintainer needs more info) » Reviewed & tested by the community

@#9 You definitely need to roll patch #6.

Let me explain again:

You load xmlsitemap.sitemap.inc file ONLY through the module.info file. Which only loads if the specified Class is required (lazy loading).

Since the Class is not called, the file is not read, and the funtions are not in memory.

Solution: move functions to .module file (patch #6) OR do a specific require_once/include_once where needed.

Anonymous’s picture

Long story short: you can't mix regular functions with Drupal Class files (they are lazy-loaded). You need to move them to .module, or use module_load_include() to deliberately load the .inc file.

Dave Reid’s picture

Why in the heck do we have hook_hook_info() then?

Anonymous’s picture

Status: Reviewed & tested by the community » Postponed (maintainer needs more info)

And why does the module work without memcache in the way? To say it isn't a memcache issue when the module works just fine without memcache is a bogus answer unless you can explain the differences of with and without memcache.

girishmuraly’s picture

Status: Postponed (maintainer needs more info) » Closed (duplicate)

Duplicate of #1392710: Call to undefined function xmlsitemap_link_frontpage_settings(). Turns out it was a problem with XML Sitemap itself.