Posted by jarrodirwin on October 21, 2011 at 11:14am
9 followers
| Project: | XML sitemap |
| Version: | 7.x-2.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (duplicate) |
Issue Summary
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
Comments
#1
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.
#2
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.
#3
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.incThis 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
#4
Improved title
#5
Verified that the patch posted by jarrodirwin is effective: I no longer suffer fatal error with settings tab. I too have memcache module.
#6
Moved the public functions from xmlsitemap.xmlsitemap.inc to xmlsitemap.module. Memcache guys please check if this works for you.
#7
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.
#8
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.
#9
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.
#10
@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.
#11
@#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.
#12
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.
#13
Why in the heck do we have hook_hook_info() then?
#14
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.
#15
Duplicate of #1392710: Call to undefined function xmlsitemap_link_frontpage_settings(). Turns out it was a problem with XML Sitemap itself.