The sitemap is not being submitted
nemsis - July 4, 2009 - 13:44
| Project: | XML sitemap |
| Version: | 6.x-1.0-rc1 |
| Component: | xmlsitemap.module |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
| Issue tags: | new translatable string |
Description
If the checkbox for "Submit the sitemap when content changes" is clicked the sitemap does send update notifications after every change and on cron runs, if it is NOT clicked it does not ever appear to be sent.
Am I missing a configuration option here?
I have tried with "Frequency" set for daily and hourly with no difference.
I had been using a patched dev version from sometime last fall and it seemed to be working and sending on cron if changes had occurred, this is the preferred option for my site.

#1
#2
The way this is coded only when the xmlsitemap_sitemap_is_changed is set TRUE will the submission happen.
<?phpfunction xmlsitemap_engines_cron() {
if (!variable_get('site_offline', 0) && variable_get('xmlsitemap_engines_cron_submit_frequency', 3600) > 0 && variable_get('xmlsitemap_sitemap_is_changed', FALSE)) {
if ((REQUEST_TIME - variable_get('xmlsitemap_engines_cron_timestamp_submit', REQUEST_TIME)) >= variable_get('xmlsitemap_engines_cron_submit_frequency', 3600)) {
xmlsitemap_engines_ping_sitemap();
variable_set('xmlsitemap_sitemap_is_changed', FALSE);
variable_set('xmlsitemap_engines_cron_timestamp_submit', REQUEST_TIME);
}
}
}
?>
This certainly isn't correct. Does changing the above to the following help? I changed the first if statement if you want to copy and paste.
<?phpfunction xmlsitemap_engines_cron() {
if (!variable_get('site_offline', 0) && (variable_get('xmlsitemap_engines_cron_submit_frequency', 3600) > 0 || variable_get('xmlsitemap_sitemap_is_changed', FALSE))) {
if ((REQUEST_TIME - variable_get('xmlsitemap_engines_cron_timestamp_submit', REQUEST_TIME)) >= variable_get('xmlsitemap_engines_cron_submit_frequency', 3600)) {
xmlsitemap_engines_ping_sitemap();
variable_set('xmlsitemap_sitemap_is_changed', FALSE);
variable_set('xmlsitemap_engines_cron_timestamp_submit', REQUEST_TIME);
}
}
}
?>
#3
The code should work, in the proposed change; the problem in the code was that && has a higher priority than ||. Without parenthesis, the code changes meaning.
#4
I have just applied the code you suggested, added some content and ran cron manually.
The notification was NOT sent.
#5
I have been trying to work with this a bit today, I'm afraid I have not found a solution. For a while I managed to break it completely so it would not output a sitemap at all, all I got then was a parse error. I have repaired that but I still can't find a way to make it send a ping to the search engines unless I allow it to send every time a change is made to the content, even a simple spelling correction sends a notification. If I turn that option off it never gets sent at all, even on a cron run. As soon as I turn it on and save it the submission is sent.
#6
#7
This issue has caused the attached patch to be committed. Along with the coding issue noted in #2 the variable xmlsitemap_engines_cron_timestamp_submit needs to be initialized to zero on the installation. I've created a hook_update_N to check for the presence of the variable and initialize it if it doesn't exist.
#8
FYI: There is a new translatable string in xmlsitemap_engines.install.
#9
Thanks!
I'll apply the patch and test this weekend.
Thanks Again.
#10
I have applied the patch and done some testing but I am afraid the results are basically the same.
If the option to "send on change" is active everything seems to work, the sitemap is generated and submitted as soon as I save the configuration changes. It is sent on every cron run and on every content update. I can open the sitemap with no problem.
If the "send on change" option is NOT set the sitemap is never submitted. On further checking it does not seem that the sitemap is even being created. When I attempt to open it there is a very long pause, 2 to 3 minutes, and then an internal server error. Seems like a timeout error.
If I try again to check the sitemap I get a parse error.
By the way, when I applied the patch and ran update.php the database was updated so I am sure that the patch was properly applied.
#11
What do you have your cron limit set to?
How many nodes do you have?
How many modules are executing a hook_cron?
If the send on change option is not set has the submission frequency been reached? Only when the submission frequency is reached will the search engine be pinged.
#12
I'll do my best to answer your questions.
What do you have your cron limit set to?
Cron limit is set to 500.
How many nodes do you have?
As of this moment 1032 nodes.
The address is www.beertaster.ca if that is of any help to you.
How many modules are executing a hook_cron?
Off hand I do not know. What is a good method of finding out?
If the send on change option is not set has the submission frequency been reached? Only when the submission frequency is reached will the search engine be pinged.
Submission Frequency is Daily. It was doubled (2 days) so I could make sure.
Hope some of this helps. If I can provide more information I would be glad too but sometimes you might have to tell me where to find it.
#13
cd sites/all/modulesgrep -rl _cron .
You are running cron.php in a crontab entry on the server correct?
The difference for when ``Submit the sitemap when content changes'' is checked or not is that when checked the sitemap ping happens in hook_init instead of hook_cron. The hook_init ignores the ``Frequency of sitemap submission'' altogether. My opinion is that hook_init needs moved to hook_cron. Pinging the search engines every time Drupal initializes is a bit much. The search engine will begin to block your IP address. Look for a patch later today.
#14
Ok, in the attached patch I blended the hook_init with the hook_cron leaving hook_cron. I simplified the conditioning in hopes of making the code easier to understand.
#15
The proposed patch uses temporary variables that are not necessary.
<?php
if (variable_get('xmlsitemap_engines_submit', FALSE) && variable_get('xmlsitemap_sitemap_is_changed', FALSE) ||
(
REQUEST_TIME - variable_get('xmlsitemap_engines_cron_timestamp_submit', 0) >=
variable_get('xmlsitemap_engines_cron_submit_frequency', 3600)
)) {
?>
&&has a higher precedence than||, and-has a higher precedence than>=; the parentheses are not necessary in both the cases.#16
Those variables make the code easier to read and understand. I had to go looking in other parts of the code to determine which variable was used for what. Yes, I could make the conditional as you suggest and even contemplated on doing so. Then I weighed the benefits of readability and chose to use the ``not necessary'' temporary variables. The result is the same and the cost is little to none.
#17
I have applied the patch and changed the frequency to hourly in order to try to speed up the results a bit.
I ran cron manually once, and it will run again from the cron tab on the host in a couple of hours.
I am currently running the grep command to find out how many hook_cron instances I have. Is it supposed to take this long? Been close to a half hour now with nothing but a blinking cursor in the ssh shell.
I will be glad to give any information which might help, I can't help with the code but I am more than willing to help test.
#18
That depends from how many modules you have installed. If then you CD-ed to the Drupal root directory, it will take a little more because the command is scanning all the files Drupal comes with; if you changed the current directory to the directory containing the Drupal modules, then it will take less.
I imagine that 30 minutes is a little too much, but I don't know how much files there are in the modules directory of your web site.
#19
After about an hour and a half in an ssh session with my host I cancelled it, I am running it locally on a very recent backup copy of the site.
It is still running but I will update this whenever it completes.
Thanks for the prompt response, it helped ease my mind.
#20
That seems to have fixed it. I will keep monitoring over the next several days but I seem to be getting sitemaps produced after several cron runs and the logs show that they have been submitted to the search engines.
I will be adding some more content and watching the logs to be sure.
Thanks for all your work and help.
By the way, for what it is worth there are 25 modules calling cron in sites/all/modules, plus 17 in the core modules.
#21
And unless one of those contrib modules is doing something with the time limit you have 240 seconds before the cron session times out. If a contrib module is modifying the time limit themselves then IMO it is a bug for that module. Thanks for testing nemsis I will apply the patch and create a RC2 release.
#22
I've committed the patch to CVS.
#23
Automatically closed -- issue fixed for 2 weeks with no activity.