hello

i get this bug when running the cron.php

Fatal error: Call to undefined function xmlsitemap_update_sitemap() in /.../xmlsitemap_node.module on line 157

thanks momper

Comments

avpaderno’s picture

Category: bug » support
Priority: Critical » Normal

xmlsitemap_update_sitemap() is defined in xmlsitemap.module, on line 434.
As xmlsitemap.module is always loaded from Drupal (because the presence of hook_exit()), and as cron.php always does a full Drupal bootstrap (it executes a call to drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL)), you should not receive such error message.

Check that the project files are intact, and are all updated to the latest version.
xmlsitemap.module has been moved to a sub-directory of xmlsitemap; therefore, you now find it in the xmlsitemap/xmlsitemap directory.

avpaderno’s picture

Title: Fatal error: Call to undefined function xmlsitemap_update_sitemap() in /.../xmlsitemap_node.module on line 157 » Call to undefined function xmlsitemap_update_sitemap()
Issue tags: +Hook implementations, +Drupal core hooks

I also find strange that you get an error about a not defined function being called from a hook_nodeapi() implementation at cron time.
At line 157 of xmlsitemap_node.module there is the xmlsitemap_node_nodeapi() function, which should not normally be called during the execution of cron maintenance tasks (correct me if I am wrong).

avpaderno’s picture

Status: Active » Postponed (maintainer needs more info)
smulkey’s picture

I am having this same issue using the DRUPAL-6--2 version of xmlsitemap and calling update.php on upgrade from 5.x. Should the function be declared at the same file position in that branch?

Here is the code I see starting at line 434 in xmlsitemap.module:

/**
 * Get an array of site map priority options.
 * @param $option
 *  If not given, the array will include priority values from 0.0 to 1.0.
 * - exclude: Add option to exclude item from site map.
 * - default: Add option to use default priority. Only for cases where a
 *   default priority exists.
 * - both: Add both the default and exclude options.
 * @return
 *  An array of priority options.
 */
function xmlsitemap_priority_options($option = '') {
  $options = array(

Thanks for your help.

-Shawn

avpaderno’s picture

The position of the function in the file is not something important; PHP uses the function wherever the function is placed in the file. You can move the function inside that file, and PHP will always find it.

smulkey’s picture

Yes, I bypassed the install error by adding an empty function of the same name but the root problem continues to be that this function doesn't appear defined anywhere in the DRUPAL-6--2 tag of the xmlsitemap module. In mentioning the file position, I was more looking to verify that I had right version of the module as a whole although I downloaded the code direcly from CVS so I'm relatively confident that I have the correct version.

Do you have any thoughts as to why this function would appear to be missing in the 6--2 branch (or the original branch referred to in this posting)?

Thanks for your help.

avpaderno’s picture

The DRUPAL-6--2 branch doesn't have any public release associated, and it should not used as it is code still being implemented. It exists only in the CVS because is not thought to be used on ANY site; it's not even ready for testing.

avpaderno’s picture

The function is declared, as I already replied, and as you can see it's present in CVS.

The module has been moved from modules/xmlsitemap/xmlsitemap.module to modules/xmlsitemap/xmlsitemap/xmlsitemap.module (the path is relative to the archive root folder).

The function exist from before I started to co-maintain the project modules, and I have never removed it.

avpaderno’s picture

This is very similar to what somebody else reported about a different function; in both the cases, the error should not be given, as the function exists, and it's defined in a file that is loaded from Drupal (or from the module needing it).

If anybody can explain why this happens, I will be thankful for the help given with this kind of issues.

kong’s picture

Just as Kiam suggested, the XML Sitemap module was moved to a sub directory. If you have installed the module prior to this change, the path to the module in system table will be no longer valid.

One solution is to disable every modules in XML Sitemap group, then reload the module page, and re-enable the modules again. If that's still not do the trick, try uninstalling and reinstalling the modules.

Edited:

Actually you have to uninstall the module from Drupal and also delete the directory because if you just copied over the xmlsitemap directory then there will be two xmlsitemap.module files -- in the sites/all/modules/xmlsitemap/xmlsitemap.module and sites/all/modules/xmlsitemap/xmlsitemap/xmlsitemap.module and I think Drupal will just pick the first file instead of the one in xmlsitemap sub directory.

avpaderno’s picture

Thanks, kong; what you said gave me an idea about a workaround I could implement when I move a file to a different directory.
I don't know how to exactly implement it (if I would directly change the Drupal core table, or to use a Drupal function), but maybe I could update the path saved in the Drupal core table, and be sure it is correctly updated (or be sure Drupal doesn't use the value it stored in cache).

Thanks again.

smulkey’s picture

Thanks both Kiam and Kong.

I understand what is going on now and should be able to get past the issue we were having.

Regards.

-Shawn

avpaderno’s picture

Status: Postponed (maintainer needs more info) » Fixed

This should be fixed as result of splitting the code into two different modules.
The code has been changed, and submitted to CVS.

Feel free to reopen the report if you still have the problem.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

tahiticlic’s picture

This function is not present in the 6.x-1.0-beta6 version.

This is not very important if you don't have xmlsitemap_term enabled, cause it's deprecated and replaced by xmlsitemap_taxonomy, but if you do the update process ends on an error, and more important, you can't disable xmlsitemap_term.

Adding it manually works.

dave reid’s picture

@cfab I think you probably have some old module code somewhere. Try deleting the module folder and redownloading & extracting the beta6.

dave@StudioXPS1340 ~/Projects/contrib/DRUPAL-6--1/modules/xmlsitemap $ grep -Rni 'xmlsitemap_update_sitemap' .
./CHANGELOG.txt:340:#383890: Change the arguments for hook_xmlsitemap_links() and xmlsitemap_update_sitemap().
./CHANGELOG.txt:355:#367251: xmlsitemap_update_sitemap() is not called.
./xmlsitemap.install:461:  $ret[] = update_sql("DELETE FROM {variable} WHERE name = 'xmlsitemap_update_sitemap_request'");

There is no call to xmlsitemap_update_sitemap() in the 6.x-1.x-beta6 or 6.x-1.x-dev code.

tahiticlic’s picture

You're right and, as I wrote just above, that is the problem if you still have the deprecated xmlsitemap_term module.

I don't have problem here, I only give an explanation of this error, related to xmlsitemap_term module. By the way, when you do an update, it's always from an old module...

dave reid’s picture

Version: 5.x-2.x-dev » 6.x-1.x-dev
Status: Closed (fixed) » Fixed

@cfab It's always best practice when updating/upgrading your modules, that you delete the old files then copy over the new module files so that old files aren't left over. You should always be doing the same thing when you update Drupal core. See the comments on the updating modules handbook page at http://drupal.org/node/250790.

Marking this issue back as fixed just incase others need to find this information.

kenorb’s picture

I get into the same problem as in this thread.
It's good practice to remove all files before you update it when you are working on non-repository file sources.
If you have something under version, you can't just remove all files and add them again, it will cause a conflict and other svn issues.
So you need to remove it via SVN delete command, but first you need to know which files do you want to remove.
In this case, sorry, but I don't know which files should I remove:

D    contributions/[seo]/xmlsitemap/docs
A    contributions/[seo]/xmlsitemap/xmlsitemap_user/translations
A    contributions/[seo]/xmlsitemap/xmlsitemap_user/translations/xmlsitemap_user.pot
A    contributions/[seo]/xmlsitemap/xmlsitemap_user/translations/xmlsitemap_user.fr.po
A    contributions/[seo]/xmlsitemap/xmlsitemap_user/translations/xmlsitemap_user.de.po
U    contributions/[seo]/xmlsitemap/xmlsitemap_user/xmlsitemap_user.module
U    contributions/[seo]/xmlsitemap/xmlsitemap_user/xmlsitemap_user.install
U    contributions/[seo]/xmlsitemap/xmlsitemap_user/xmlsitemap_user.info
A    contributions/[seo]/xmlsitemap/xmlsitemap_taxonomy
A    contributions/[seo]/xmlsitemap/xmlsitemap_taxonomy/translations
A    contributions/[seo]/xmlsitemap/xmlsitemap_taxonomy/translations/xmlsitemap_taxonomy.pot
A    contributions/[seo]/xmlsitemap/xmlsitemap_taxonomy/translations/xmlsitemap_taxonomy.de.po
A    contributions/[seo]/xmlsitemap/xmlsitemap_taxonomy/xmlsitemap_taxonomy.module
A    contributions/[seo]/xmlsitemap/xmlsitemap_taxonomy/xmlsitemap_taxonomy.install
A    contributions/[seo]/xmlsitemap/xmlsitemap_taxonomy/xmlsitemap_taxonomy.info
A    contributions/[seo]/xmlsitemap/translations/general.de.po
U    contributions/[seo]/xmlsitemap/translations/xmlsitemap.pot
A    contributions/[seo]/xmlsitemap/translations/xmlsitemap.de.po
A    contributions/[seo]/xmlsitemap/translations/general.pot
A    contributions/[seo]/xmlsitemap/xmlsitemap.admin.inc
U    contributions/[seo]/xmlsitemap/INSTALL.txt
A    contributions/[seo]/xmlsitemap/xmlsitemap_node/translations
A    contributions/[seo]/xmlsitemap/xmlsitemap_node/translations/xmlsitemap_node.pot
A    contributions/[seo]/xmlsitemap/xmlsitemap_node/translations/xmlsitemap_node.fr.po
A    contributions/[seo]/xmlsitemap/xmlsitemap_node/translations/xmlsitemap_node.de.po
U    contributions/[seo]/xmlsitemap/xmlsitemap_node/xmlsitemap_node.info
U    contributions/[seo]/xmlsitemap/xmlsitemap_node/xmlsitemap_node.module
U    contributions/[seo]/xmlsitemap/xmlsitemap_node/xmlsitemap_node.install
U    contributions/[seo]/xmlsitemap/xmlsitemap.install
A    contributions/[seo]/xmlsitemap/xmlsitemap.pages.inc
U    contributions/[seo]/xmlsitemap/xmlsitemap_engines/xmlsitemap_engines.module
U    contributions/[seo]/xmlsitemap/xmlsitemap_engines/xmlsitemap_engines.install
A    contributions/[seo]/xmlsitemap/xmlsitemap_engines/translations
A    contributions/[seo]/xmlsitemap/xmlsitemap_engines/translations/xmlsitemap_engines.de.po
A    contributions/[seo]/xmlsitemap/xmlsitemap_engines/translations/xmlsitemap_engines.pot
A    contributions/[seo]/xmlsitemap/xmlsitemap_engines/translations/xmlsitemap_engines.fr.po
A    contributions/[seo]/xmlsitemap/xmlsitemap_engines/xmlsitemap_engines.pages.inc
U    contributions/[seo]/xmlsitemap/xmlsitemap_engines/xmlsitemap_engines.info
A    contributions/[seo]/xmlsitemap/xmlsitemap_engines/xmlsitemap_engines.admin.inc
U    contributions/[seo]/xmlsitemap/gss/gss.xsl
U    contributions/[seo]/xmlsitemap/gss/gss.css
U    contributions/[seo]/xmlsitemap/gss/gss.js
A    contributions/[seo]/xmlsitemap/CHANGELOG.txt
U    contributions/[seo]/xmlsitemap/xmlsitemap.module
U    contributions/[seo]/xmlsitemap/README.txt
U    contributions/[seo]/xmlsitemap/xmlsitemap.info

Is good to inform users on update that some files has been removed and could cause conflict.

kenorb’s picture

Ok, I found.
svn del xmlsitemap_term
Thanks.

UPDATE:
Duplicate of this: #340743: Call to undefined function xmlsitemap_update_sitemap()

kenorb’s picture

It's very bad programming to put the same names of function in different modules and copy them over and over again.
In this case my whole update process failed.

avpaderno’s picture

Which function has been placed in different modules, exactly?

dave reid’s picture

We have tried to make it clear in the module's included documentation and in the release notes for every release that you should not be copying over the new files. You have to clear out the old ones first. This is a standard that should be done every time you update a module, but in reality, most people don't. And it can lead to problems with stale, abandoned files.

kenorb’s picture

Sorry, I though that xmlsitemap_update_sitemap() was defined twice, but it was undefined.

In my opinion update process should then disable xmlsitemap_term module which was abandoned in hook_update

if (module_exists('xmlsitemap_term')) {
module_disable('xmlsitemap_term');
drupal_set_message(t('Please remove xmlsitemap_term dir manually, because it\'s not used anymore.'), 'error');
}
avpaderno’s picture

I think that is already done.

/**
 * Implementation of hook_update_N().
 */
function xmlsitemap_update_6140() {
  $ret = array();
  if (module_exists('xmlsitemap_term')) {
    module_disable(array('xmlsitemap_term'));
    drupal_set_message(t('XML sitemap term has been deprecated in favor of XML sitemap taxonomy; enable it in the <a href="@modules">modules page</a>.', array('@modules' => url('admin/build/modules'))), 'status', FALSE);
    $ret[] = array(
      'success' => TRUE,
      'query' => 'Disabled the XML sitemap term module successfully.',
    );
  }
  // ...
  return $ret;
}
kenorb’s picture

hmm, nice.
So it's weird that it broke with this code during update.php
Maybe after disable it was still in memory somehow.
I'll not check it anymore, anyway, many thanks for help.

Anonymous’s picture

It's good practice to remove all files before you update it when you are working on non-repository file sources.
If you have something under version, you can't just remove all files and add them again, it will cause a conflict and other svn issues.
So you need to remove it via SVN delete command, but first you need to know which files do you want to remove.

Then you need to change your practice of how you implement the SVN imports and use a ``diff -upN'' between the new module and your existing working store. Then apply the difference to your SVN (yes you may need to manually add or delete).

I haven't looked but there maybe tools to help with this type of thing.

kenorb’s picture

Mostly I'm on Windows with TortoiseSVN and Totalcmd. I'm downloading new version, replacing and commiting to repository.
I don't know if there is some workaround to commit and remove non-existing at once.
Workaround is to delete whole folder and commit, and add again new folder and commit again.
You can use Shift-F2 to compare actual directory in totalcmd, what I do every time, but it doesn't compare sub-directories.
I'd like to learn some better practise, but I don't see here any better practise to use.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

sun.core’s picture