I deleted the old module, uninstalled it, and then installed beta 6.1 but now my http://exemple.com/sitemap.xml return a 404 error, I also ran cron.php but the result is still the same, as admin or as anonymous user!

I don't know what went wrong..

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

apaderno’s picture

Title: error 404 when testing the 6.1 beta! » 404 error accessing sitemap.xml
apaderno’s picture

Status: Active » Postponed (maintainer needs more info)

Did you clean the Drupal cache?
Do you see any files being created, in the directory you selected for the sitemap cache files?

I cannot reproduce this error on my site, which is probably caused by the files not being created, yet.

introfini’s picture

I have the same problem. The nodes are getting added to xmlsitemap_node table but the cache directory is empty.

introfini

apaderno’s picture

Version: 6.x-1.0-beta1 » 6.x-1.x-dev

Try with the development snapshot that will be generated between 11 hours.

apaderno’s picture

Component: Code » xmlsitemap.module
alliax’s picture

Yes I clean drupal cache and I also deleted the sitemap created by the previous xmlsitemap I had installed.
The folder is here /files/xmlsitemap but the file is not being created, on cron.

dropchew’s picture

for my case after 1 cron run, a file called xsm-bf1996bd.xml is created in /files/xmlsitemap. But example.com/sitemap.xml still return a 404 error.

Edit. My bad, its from a previous dev version. Pls ignore this.

apaderno’s picture

Status: Postponed (maintainer needs more info) » Active

I traced down the error, and it is caused from this code:

  if (variable_get('xmlsitemap_sitemap_needs_update', FALSE)) {
    variable_set('xmlsitemap_update_timestamp', REQUEST_TIME);
    module_invoke_all('xmlsitemap_links');
    variable_set('xmlsitemap_sitemap_needs_update', FALSE);
    $result = _xmlsitemap_create_cache_files();
    if (variable_get("xmlsitemap_create_cache_result_$id", -1) !== $result) {
      variable_set("xmlsitemap_create_cache_result_$id", $result);
    }
  }

When the Drupal variable checked is not initialized, the IF-statement doesn't execute the block of instructions, which contains the call to _xmlsitemap_create_cache_files(); this causes the 404 error being seen when trying to access the sitemap.
I would change any occurrence of variable_get('xmlsitemap_sitemap_needs_update', FALSE) in variable_get('xmlsitemap_sitemap_needs_update', TRUE).

apaderno’s picture

Status: Active » Needs review
Anonymous’s picture

I also ran cron.php but the result is still the same, as admin or as anonymous user!

You might need to execute cron.php more than once. If the cron.php runs more than 240 seconds (the maximum execution time for cron.php) not all hook_cron implementations will have been executed in that time frame. I've seen this error for this reason alone.

Anonymous’s picture

Re #8: I don't think changing the default from FALSE to TRUE helps any based on #10. I have seen this error right after a fresh install and executing cron.php for the first time. FeedAPI will take most of the 240 seconds pulling aggregate data and creating nodes on my test site. Visiting sitemap.xml will give a 404. However, after (a) subsequent execution(s) of cron.php the error clears and a visit to sitemap.xml produces results.

apaderno’s picture

I had this error on my test site, and I ran the cron tasks more than once. I resolved it by creating a Drupal page, and adding a line like module_invoke_all('xmlsitemap_links').

In a web site where the project modules have been uninstalled, and then the newer version of the files has been installed, it's more probable that the error is caused from the code I reported in #8, which uses FALSE as default value for the Drupal variable; this means that the first time xmlsitemap_output() is executed, that Drupal variable doesn't exist and the IF-statement (which should call the function to create the cache files) doesn't execute its block of instructions.

apaderno’s picture

As the default value of a Drupal variable is used only when the variable is not found in the database table, making that change doesn't cost too much, and it doesn't have any collateral effects (if I don't need more coffee, indeed :-)).

EDIT: I tested the change I was proposing on my test site, but it doesn't resolve the issue. It is also true that causing the cron tasks to be executed many times doesn't resolve the issue.
The only way to resolve the issue (as I have found until now) is to invoke hook_xmlsitemap_links() for all the modules.

alliax’s picture

Creating a page with PHPCode input filter with this code:

<?php
module_invoke_all('xmlsitemap_links');
?>

didn't help create a file in /files/xmlsitemap

I used tools tabs and "flag the sitemap as requiring update" and also ran cron several times, but no file has ever been created.

What did I do wrong? Since you said that invoking hook_xmlsitemap_links() for all modules resolves the issue?
Note that I didn't do the change you suggested in #8 because you then seem to say that it doesn't solve the issue.

apaderno’s picture

the exact sequence it to first run cron.php at least twice, and then execute module_invoke_all('xmlsitemap_links').

alliax’s picture

I just tried one more time: I did execute cron.php several times (but all my nodes and terms are already in the db, because cron runs every 20 minutes and I have only a few hundreds) and then I displayed my page with module_invoke_all('xmlsitemap_links') in php, nothign has been created, i ran again cron, but still nothing.

I wonder how many people have the same error as I do, obviously the main developpers don't have this problem otherwise they wouldn't have released the beta yet.

dhwall’s picture

I'm having the exact same problem.

jackfoust’s picture

Also experiencing.

giorgio79’s picture

same here

green monkey’s picture

same here

could it be Global Redirect? ... Pathauto?

could the wrong version of this program been bundled for download?

Rush_iam’s picture

don't work for me too....
version 6.x-1.0-beta1 that marked as "Recommended"

stroker’s picture

Same for me using recommended version.
Drupal 6.11
PHP 4.3.11

edegro’s picture

I've also run cron a dozen or so times and still nothing is produced.

Giuseppe’s picture

same problem...

savvypatachonica’s picture

Version: 6.x-1.x-dev » 6.x-1.0-beta1

Me too... not working with 6.x-1.0-beta1. Tried just about everything on this thread, still "page not found" at www.foo.bar/sitemap.xml

apaderno’s picture

Version: 6.x-1.0-beta1 » 6.x-1.x-dev

The referring version is 6.x-1.x-dev because the code is first changed in the development snapshot; that is the way Drupal does it.

green monkey’s picture

you want a mysql database and list of modules to use for testing?

apaderno’s picture

Uhmmm... no; it should not depend from the presence of other modules.

green monkey’s picture

ok, just trying to offer support

does this matter?

sites/default/files/xmlsitemap/ (confirmed 775)
sites/default/ (confirmed 555) - no writes

apaderno’s picture

Title: 404 error accessing sitemap.xml » Cache files are not created

It's useless to ask if you see any files in the first directory, because I am sure you don't see any files there.

Just to be sure, does the xmlsitemap table contains any row?

I am changing the title to something that better describe the problem; the module could not return a 404 error message, but the problem could still be present.

Giuseppe’s picture

The xmlsitemap table of the db doesn't contain any row, whereas xmlsitemap_node and xmlsitemap_term does.
Cache files and sitemap.xml aren't created.

ak_dm’s picture

I can confirm that I have the same behaviour as Giuseppe (#31).

First install of xmlsitemap, the directory permissions all appear correct & the various modules are enabled.

The xmlsitemap table is empty, however xmlsitemap_node does contain some entries.

Have run cron a number of times with no errors being reported.

dropchew’s picture

Using the latest dev, after running cron 2-3 times, and creating a page after that with

module_invoke_all('xmlsitemap_links');

I can confirm example.com/sitemap.xml is generated. For my case I have over 10K+ nodes and it took a while. In sitemap.xml, there are 2 other links sitemap0.xml and sitemap1.xml, which I can also confirm the urls in them are generated.

Edit: After creating the page with the snippet, xmlsitemap table will be populated

giorgio79’s picture

it works for me as well.

First I tried it without calling cron.php, just executing invoke all on a page, and got this:
Parse error: syntax error, unexpected T_VARIABLE in /includes/common.inc(1654) : eval()'d code on line 14

But then I Called cron, and the next time I Called that page it executed for about 5 minutes for 30 000 nodes and terms, but it worked :)

sl27257’s picture

Subscribe

ak_dm’s picture

Creating a page with the above code to invoke the module manually did populate the xmlsitemap table for me, however the file itself still didn't get created.

giorgio79’s picture

Hmm, I checked as well, mysite/sitemap.xml and got this

Fatal error: Allowed memory size of 103809024 bytes exhausted (tried to allocate 19456 bytes) in /modules/acquia/filefield/filefield_field.inc on line 169

apaderno’s picture

Assigned: Unassigned » apaderno

I find out the problem, and I should be able to release a beta2 in 36 hours.

To make a summary, the issue is that the cache files are not created; this happens because

  • The xmlsitemap table is empty; this is normally true when the project modules are first installed, or when they are uninstalled, and reinstalled.
  • The xmlsitemap table gets populated when the sitemap content is requested from an anonymous, or an authenticated user; it gets populated from the data contained in the database tables used by the single modules, which are populated when a node is created/updated, a taxonomy term is created/updated, or when cron tasks are executed.
  • In the actual beta1 code, executing the cron tasks, and trying to visualize the sitemap doesn't cause the cache files to be generated. This happens because the implementation of hook_cron() of the single modules doesn't flag the sitemap as requiring update; the same flag is used from the code that verify if the cache files must be updated/generated. This explains also because the workaround to execute the cron tasks, and then execute code like module_invoke_all('xmlsitemap_links') really fix the problem.

I didn't have this issue because I didn't uninstall the modules from my test site; doing so, the central database table was already populated, and the cache files were regularly created.

apaderno’s picture

Status: Needs review » Active
green monkey’s picture

@Kiam

Thank you for your time and enegry to find the problem

there were two other things I found a bit odd

on a fresh install, Drupal wanted me to run "update.php" and did many tasks

also I noticed you have a xlmsitemap/xlmsitemap structure .. that might confuse some newbies - but then again I am sure you have a reason

apaderno’s picture

on a fresh install, Drupal wanted me to run "update.php" and did many tasks

I noticed that too. Maybe that is caused by the fact there is an update function named <module>_6000(); that function is required for updating from Drupal 5.
The executed queries don't cause any errors, and there isn't a way for the module to cause that. I don't know why Drupal forces you to execute update.php.

The directory structure is thought to make easier to create the template files used for the modules translation; other than for people helping with the translation, the directory structure should not be of interest for the end user, who should just use the project modules.

apaderno’s picture

Status: Active » Fixed

This should be fixed in CVS.
Take in mind that the sitemap will start to get populated after the cron tasks of the XML Sitemap project are executed. This means that the sitemap could appear empty for some time; it doesn't mean the code is still bugged.

Feel free to reopen it if you have evidences that the code is not correct.

green monkey’s picture

ok .. almost there

I now have data in the below and the counts match thier source

xmlsitemap_node
xmlsitemap_term

but the below is still empty

xmlsitemap

green monkey’s picture

forgot to reopen

also noticed "update.php" wants to rerun very time

green monkey’s picture

Status: Fixed » Active
apaderno’s picture

Status: Active » Postponed (maintainer needs more info)

After you noticed that the database tables have been populated, did you try to visualize the sitemap in your browser, and verify if the cache files are effectively created?

green monkey’s picture

yes I did that

I even FTP'ed in with a refresh and no file

Then with FTP, I looked in site.com/sites/default/files/xmlsitemap/

no files

apaderno’s picture

Do you see any Drupal reports that refers to that directory, or any other reports made from xmlsitemap?

green monkey’s picture

cron
2009-05-11 19:00
Cron run completed.
Anonymous

cron
2009-05-11 18:39
Cron run completed.
staff

cron
2009-05-11 18:38
Cron run completed.
staff

cron
2009-05-11 18:05
Cron run completed.
staff

cron
2009-05-11 18:00
Cron run completed.
Anonymous

cron
2009-05-11 18:00
Cron run completed.
staff

xmlsitemap
2009-05-11 18:00
The sitemap has been flagged as needing update.
staff

thats all I have

apaderno’s picture

Thanks for your answers.
Just to be sure, which version are you running?

green monkey’s picture

// $Id: xmlsitemap.module,v 1.1.2.113 2009/05/10 19:49:25 kiam Exp $

Drupal 6.11

apaderno’s picture

Status: Postponed (maintainer needs more info) » Fixed

The version you have is not the one that should fix the problem. The sitemap will not be created in seconds, anyway.

I am changing the status of the report; feel free to reopen it after you updated the project files installed, and you still noticing the problem.

The steps to follow to be able to see a sitemap being populated are:

  • Install the latest version.
  • Run update.php.
  • Run cron.php one, or more times.
  • Try to visualize the sitemap on your browser; there is no need to log out first.

EDIT: I noticed that the second parameter passed to fopen() was wrongly set to wb while it should be set to w+. You need to wait until the new archive gets generated, or change the code yourself.

green monkey’s picture

thank you

I'm confused now, what link should I be using and version should I check for?

apaderno’s picture

The version I am referring is 6.x-1.x-dev, which is reported in the project page.
You had the 6.x-1.x-dev version released two days ago; to be sure you have the latest development snapshot, you should check the release date as reported in the project page for each release.

green monkey’s picture

ok, a little better now and thanks for your help

this is what I have now

mysite.com/sitemap.xml

displays

<?xml version="1.0" encoding="UTF-8" ?> 
  <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9" />

and nothing else

using - xmlsitemap.module/1.1.2.114 xmlsitemap.install/1.1.2.56
// $Id: xmlsitemap.module,v 1.1.2.114 2009/05/12 00:05:26 kiam Exp $

cache and that same table are empty - but other two tables show correct counts

advice?

dropchew’s picture

Same issue here..

green monkey’s picture

I fogot to add

using FTP, still no file in the root - so I would assume the text I do see is coming from the module?

apaderno’s picture

I would assume the text I do see is coming from the module?

Yes. It's the output of the module; the module will never create a sitemap.xml file in the root directory.

Note also my previous comment (#52); what I meant is that you should wait until 12:00 PM GMT, to download the archive containing the code that fix an incorrect parameter passed to fopen(); the archive you downloaded doesn't contain the fixed code.

green monkey’s picture

ok - thanks

Anonymous’s picture

Status: Fixed » Needs work

EDIT: I noticed that the second parameter passed to fopen() was wrongly set to wb while it should be set to w+. You need to wait until the new archive gets generated, or change the code yourself.

Actually, wb+ would be the correct version. The b is a windows thingy. It opens the channel in ``binary'' mode versus ``text'' mode. Volumes have been expounded in numerous mail lists about text vs binary mode. You definitely want the b.

apaderno’s picture

Thanks for the suggestion, earnie. I right changed the code, hoping I am not late for the tarball re-generation.

introfini’s picture

Now the tables are getting populated and the cache files are also created. But when I call the sitemap.xml from the browser the request never ends and no file is loaded.

I'm using the latest code from CVS.

Thanks,
introfini

apaderno’s picture

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

How many nodes do you have in your web site?

introfini’s picture

80.000 (sorry I have meant to say that but I forgot)

grafik’s picture

6.x-1.0-beta0 : /sitemap.xml - error 404
6.x-1.x-dev : returns only:

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9">
</urlset>

Site: 300 nodes, 6 node types

apaderno’s picture

Status: Postponed (maintainer needs more info) » Fixed

The topic of the report is the cache files are not being created. From your report, I would guess they are created.

I am going to set this issue as fixed because I have been able to get back a sitemap in a test site with 20000 nodes, and 10000 taxonomy terms. The sitemap is still not complete, but it contains much of the links it should.

brett_miller’s picture

Hi, I got the new version to work by creating a page that contains the below:

module_invoke_all('xmlsitemap_links');

This was mentioned earlier in the thread :)

green monkey’s picture

// $Id: xmlsitemap.module,v 1.1.2.115 2009/05/12 20:35:27 kiam Exp $

with

#67 above .... works :-)

xmlsitemap 1,586
xmlsitemap_node 717
xmlsitemap_term 864

and reminder is users

keereel’s picture

Status: Fixed » Needs review

XML Sitemap: 6.x-1.0-beta3
Drupal: 6.11
Nodes: about 8500
Sitemap:

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9">
</urlset>

Any solutions?

apaderno’s picture

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

Do you see any file in the directory you set to be used like cache directory?

dropchew’s picture

Hi I have the same situation as keereel after 3-4 cron runs, the dir is there but no files are in it.

grafik’s picture

my cache file is empty

apaderno’s picture

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

Version: 6.x-1.x-dev » 6.x-1.0-beta3

No cache files being created with Beta3. Latest Drupal 6.11, unix. Cache dir gets created, but no files within. The xmlsitemap_node table has rows, all with a priority of -2. This was a clean install, not an upgrade. Thanks.

chrisschaub’s picture

Will the fix in #67 ...

<?php
module_invoke_all('xmlsitemap_links');
?>

be good from there on out? Will I have to run each time until this gets fixed? Or is this just a catch up step? Thanks.

apaderno’s picture

Version: 6.x-1.0-beta3 » 6.x-1.x-dev

What I suggested (the invocation of all hook_xmlsitemap_links() implementations) is a workaround that worked for me when I was not differently able to make the module produce a sitemap; it's something that is only temporary, until you are able to get a valid sitemap from the module.

The referring version is the development snapshot because it's where the code will be fixed. Please, don't change the referring version if you don't read the full thread.

keereel’s picture

no, it's empty

popetardo’s picture

xmlsitemap.module/1.1.2.117 xmlsitemap.install/1.1.2.58

I deinstalled the previous version of the module using admin/build/module/deinstall . Remove module directory, untar new dev version. Enabled the module, configure.

then I created a page in my theme directory page-xmlsitemaplinks.tpl.php whith

module_invoke_all('xmlsitemap_links');

enter in mysite.com/xmlsitemaplinks

then run cron.

The module created a sitemap index whith
...

<sitemap>
<loc>http://www.mysite.com/sitemap0.xml</loc>
<lastmod>2009-05-14T08:32:32+00:00</lastmod>
</sitemap>
−
<sitemap>
<loc>http://www.mysite.com/sitemap1.xml</loc>
<lastmod>2008-07-08T22:00:00+00:00</lastmod>
</sitemap>
</sitemapindex>

...

There are one thousand of urls in each one.
This site have thousands of nodes, eight thousand nodes, eight thousand users, a lot of terms, etc.

Good work.

Edit: there are 4 sitemaps in the index now. It works!

apaderno’s picture

I created a page in my theme directory page-xmlsitemaplinks.tpl.php

It would be simpler to create a node of type page, and use the PHP filter for its content; then you can insert

  module_invoke_all('xmlsitemap_links');

There is no need to create something in the theme directory for two reasons:

  • The file you created is supposed to be used to render an existing element (mainly a page) in a particular way.
  • The file should be created for each theme you use, and you must take particular care when you update the theme you are using to avoid to delete the file you added.

I would add that you are adding something that is logic tier in the presentation tier (see Multitier architecture). Said in other words, it's bad and it must be avoided.

green monkey’s picture

is there a way to move

<?php
  module_invoke_all('xmlsitemap_links');
?>

into a cron function? and delete the helper page I've created?

green monkey’s picture

head-up

Drupal is currently recommending Beta3 as the module to use.

anyone "not" following this thread is going to download the wrong version and also create more tickets and work for you

bstrange’s picture

jwells is correct, beta 3 is what I used and have the same problem as listed by jwells in #55 and made a seperate ticket for it. If possible, maybe that ticket could be merged with this one.

as a matter of clarification, is the 6.x-2.x-dev released today the version that we should be using or the 6.x-1.x-dev released yesterday?

apaderno’s picture

as a matter of clarification, is the 6.x-2.x-dev released today the version that we should be using or the 6.x-1.x-dev released yesterday?

That is your choice; take in mind that the 6.x-2 branch is still not complete, and it doesn't have xmlsitemap_taxonomy.module, i.e. Read well what reported in the project page about the 6.x-2 branch, and take your choice.

giorgio79’s picture

6.2 worked seamlessly for me for nodes, I kind of gave up on 6.1 :)

grafik’s picture

no change after upgrading to 6.x-2.x
content of sitemap.xml not contains nodes:

<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> 
</sitemapindex>
dropchew’s picture

grafik - There is no upgrade path from 1.x, you have to uninstall 1.x completely and install 2.x (click on rebuild).

apaderno’s picture

There is not update path for the 6.x-2, so far.

ad6’s picture

The version 6.x-2.x-dev is the only that worked and is working for me, BUT every time I must click REBUILD to include new created articles.

2xe’s picture

EDIT: I discovered I had a few old XML Sitemap API functions in my code; disabled them, and now it seems to be generating the site map! Sorry for the inconveniance it may have caused you...

I did however get a memory exhaustion error. Maybe you should add an advanced setting that allows (users who are in control of their servers...) to set the php memory_limit? With my current limit of 60Mb it manages to fill approx 10 000 rows in the xmlsitemap table on each run.

----

I am having the same issue;

- Started with a system with no previous installations of xml sitemap
- Using current snapshot of -dev version (installed beta 3 first, but then i got to this post......)
- drupal 6.12 on linux
- cron'ed tens of times
- executed module_invoke_all('xmlsitemap_links') several times
- tested viewing sitemap.xml

Result:
- xmlsitemap_taxonomy table contains about 800 records
- xmlsitemap_node table contains around 24000 records (and counting....)
- xmlsitemap table isn't populated
- no files created in files/xmlsitemap (but directory exists)
- sitemap is empty like #69

grafik’s picture

dropchew - Thanks, it works

apaderno’s picture

@#89: The code is being rewritten, and it will not try to populate all the links in one time anymore.

How the code is being changed is shown in #465734: Use sitemap chunks per module to prevent the rebuilt of all the cached files. The actual referring version for that report is 6.x-2, but it describes the changes I am going to make to the 6.x-1 branch.

apaderno’s picture

I set #467278: Nothing Created as duplicate of this report.

apaderno’s picture

nrackleff’s picture

Subscribing. I have the same issue. Nodes are in the table, but nothing in cache directory even with 775 permissions.

apaderno’s picture

I set #464998: XML Sitemap doesn't work as duplicate of this report.

eazy87’s picture

Version: 6.x-1.x-dev » 6.x-1.0-beta3

Same here, I experience this issue with the stable and development versions from Drupal 6.x (xmlsitemap_nodes has data, but xmlsitemap table is empty).

Which is the status of this request? Is it being worked on, or the workaround from 'popetardo' is the only way round this?

apaderno’s picture

Version: 6.x-1.0-beta3 » 6.x-1.x-dev

See #458546-76: Cache files are not created to understand why the referring version is the one I set.
If you don't read all the comments, then please avoid changing the issue metadata. Thank you.

Dave Reid’s picture

Priority: Normal » Critical

Almost 100 comments and we still haven't gotten this fixed. This is a critical issue before we can get a beta4 released. Kiam or earnie, do you need help debugging this?

apaderno’s picture

I am working on that, but I had to completely change the code, to get it work as it should.

In the code I am developing, when the cache files are not present, or are not created for any reasons, the code will ask to the single modules the first 100 links that are part of the chunk being requested. This is because the cache files are not generated when a sitemap chunk is requested, but in a different moment.

The code will assign a specific set of chunks to each modules, and in a sitemap chunk will not shared between two different modules.

Until now, the code I am developing works correctly in the test site I have. I am optimizing a little this code, then I will write the part that should create the cache files.

apaderno’s picture

Status: Active » Needs review

The latest commits done in CVS adds a way to create the cache files using a script that must be invoked in the same way cron.php is invoked.
The next step will be to add an option in the tools page that allows to create the cache files.

The last committed code, in the case the cache files are not present, outputs the first 100 links present in each sitemap chunks.

FiNeX’s picture

I hope this will be fixed soon too. Thanks for your efforts!

2createwdrupal’s picture

Same.

I tried everything, spent hours updating, deleting, uninstalling, installing, all versions. Nothing worked. Worse - I had saved a version that did work and had been working, up until the betas came out (after which point nothing worked) - I reinstalled that older version and, even after deleting every new xmlsitemap file and uninstalling and updating the database, running cron, it wouldn't work.

On the plus side, after all that, I tried a free online service for a sitemap. I inspected the resulting file and found many errors in taxonomy and a few other areas. I manually corrected many of the errors in the file and I'm using that while hoping for a new xmlsitemap module that works. Thanks to Dave Reid for his blog post about the module; it helped to understand the situation. Meanwhile, I'm fixing some of the odd taxonomy issues on my site which were never the fault of xmlsitemap.

:)

alex.k’s picture

Hope this is not derailing the discussion... My symptoms upon a fresh install of beta3 were similar to reports above: xmlsitemap_* tables were populated on cron, but downloading the sitemap returned just an empty one. No cache files were created. xmlsitemap table was never populated. Looking at function xmlsitemap_output() it goes something like this:

...
$link_count = xmlsitemap_link_count(); //load count of existing links (it's zero to start with)
...
//if count is zero, print an empty sitemap
if (!$link_count || (isset($chunk) && !preg_match('/[0-9]+/', $chunk))) {
  $user = $original_user;
  session_save_session(TRUE);
  _xmlsitemap_print_empty_sitemap();
}
...
module_invoke_all('xmlsitemap_links') // - this actually populates the xmlsitemap table.

The check for an empty map causes hook_ xmlsitemap_links never to be invoked. Commenting out this check makes everything work. Seems like if the table is truly empty, the function will go on and check for new links anyway, and still return correctly an empty sitemap, so checking the count early on is not a must.

apaderno’s picture

Thanks for your report, alex.k. I think your comment helps who has the beta3 version.

For the benefit of who is using the beta3 version, may you report the complete code of the function as you modified it?

alex.k’s picture

Attaching a patch against the beta3 release, and the complete function xmlsitemap_output() after the patch has been applied.

apaderno’s picture

Thanks for sharing your code. This could surely help who is using the beta3 version.
That part of the code has been completely changed in the development snapshot, and it will be changed as well in the next beta4 version.

I have only a doubt about the fact the function doesn't check the parameter it gets; what should happen if you pass a string to the menu callback? The condition in the statement if ($chunk < ... ) would be verified.

apaderno’s picture

With the development snapshot that Drupal.org will make available in the new tarball archive, the code outputs the sitemap content using the data contained in the XML sitemap database tables, when the cache files are not found, or it's not possible to open them.
The cache files are now created in a different time from when the sitemap content is being viewed.

I am working to the code that allows to update/create the cache files from the tools menu, or from a file that must be invoked in a similar way cron.php is invoked. That code doesn't actually work, and I am changing it.

ReinVelt’s picture

module_invoke_all('xmlsitemap_links') solved my problems. The cache and the sitemap are now generated properly.

nocte’s picture

Subscribe - having the same problem :(

fatfish’s picture

+1

apaderno’s picture

The sitemap tools menu already allows to update/create the cache files.

apaderno’s picture

The sitemap tools menu already allows to update/create the cache files.

apaderno’s picture

Status: Needs review » Fixed

As the sitemap cache files are not created when the sitemap is being viewed, and the module offers two different ways for generating them, I am setting this issue as fixed.

Take in mind that, in absence of cache files, the code will output the sitemap chunks content directly from the database tables content.

apaderno’s picture

In the next 12 hours I will create a beta4 version.

green monkey’s picture

Hi guys,

this thread is getting confusing and a bit long #119

what ya say we take some of #118 and add in what is required to explain output / cache files properly then add it to the module hearder info and prehaps the readme as well.

I'm thinking dev 2 and dev 1 and beta need a line or two of yack yack, as it stands now a new person would download the beta version, is that correct?

I'd be happy to, but I have no access to this area

apaderno’s picture

The new beta version has already created; it's available for download from the project page.

Rhino’s picture

Subscribe (Have an empty sitemap after upgrading to beta3 last night, now switching to beta5)

apaderno’s picture

Issue tags: +beta3

I am adding an issue tag.

sandino’s picture

Thank you for this great module!

as well as for many other users here 6.x-2.x-dev is the only version that is working for me and working excellent

i have a multilanguage site with path prefix for different languages and sitemap is created only for main site without prefixes
how can i add to sitemap all links with prefixes, e.g. www.example.com/de/ ?

Dave Reid’s picture

@sandino: Multilingual support is planned, but not yet implemented. See #470602: Support for multilingual sites.

apaderno’s picture

Assigned: apaderno » Unassigned
Xallum’s picture

Hi,

I hope, you can help me. The creation of my sitemap.xml takes a lot of time (I have thousands of nodes and users). Unfortunately there is also a timeout of the server. I increased the timeout limit, so it works now. But I think that Google & Co. would not wait for such a long time. That's why I have copied the functions for building the sitemap in a new php-file and start it with a single cronjob every night.

I thought that when I have created the cache otherwise, the call of sitemap.xml would not create files again. For the first minutes I have the effect that I want to, but after a few minutes / hours the cache will be created new when I call the sitemap.xml.

What do I have to change (maybe in xmlsitemap.pages.inc?) to only show the cache files (or print an empty sitemap if there are now ones) when calling sitemap.xml?

Thanks for help!

apaderno’s picture

You don't say which version you are using, and it's not possible to answer you without to know that.

The code should not return an empty sitemap (without data for even a link) because Google would report that the sitemap format is not known.

Xallum’s picture

Thanks for your fast answer. I'm using Version 6.x-1.0-beta3. I meant with "or print an empty sitemap if there are now ones" that at least something happens (function print_empty_sitemap) or there is a response. But this is only an option, normally there are cache files, created by the script file executed by the cronjob.

apaderno’s picture

But this is only an option, normally there are cache files, created by the script file executed by the cronjob.

The code I developed doesn't create cache files during cron tasks. During cron task the modules simply populate their database tables.
It's not clear if by script file executed by the cronjob you mean xmlsitemap.cron.php; if that is the case, that file works only of beta4, or beta5. That could explain the problems you reported.

Xallum’s picture

I think you have misunderstood me. I created an own php file, in which I copied the relevant functions of your module to create the cache files. I call this file with an own cronjob (not drupal based). The problem is, that if I call the sitemap.xml hours later, the cache files will be created new. I want that if I call sitemap.xml only the cache files, created by my task, will displayed. There should not be created new ones, because this progress takes several minutes.

Summarizing: What do I have to change to only show the cache files (and not to generate new ones) if I call sitemap.xml.
The generation of the cache files should only be done by the script composed by myself (already works).

apaderno’s picture

The module contains a xmlsitemap.cron.php that is thought to be invoked by a cronjob to create the cache files; that is the reason I was not understanding your question.

I cannot reply about your code because I don't know it; I can only answer you about code present in the XML sitemap project.

Xallum’s picture

Yeah, that's what I want to. I want to know, what I have to comment out in your module to stop producing cache files when calling "sitemap.xml" - it should only show the cache files like yet, as though it has produced them by itself. As I sad, I had to outsource the production because of performance.

Thanks for help!

apaderno’s picture

Now I understand better; thanks for explaining me what you were asking.

In that case, I cannot give you any answers because I don't have anymore the code I have developed. I can answer to any doubt you have about the code I developed, but I don't remember in the specific any single lines of code.

Anonymous’s picture

@Xallum: I understand what you're asking. I will need time to review the code which for the moment isn't happening because of a dire family emergency. I barely have time to be online responding here. Please open a support request with an appropriate title since this one is fixed.

Status: Fixed » Closed (fixed)
Issue tags: -beta3

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