Scenario:
- Set up XML sitemap including node content of type Basic page
- Create a basic page
- Configure cron to run nightly
- Leave the site for a 15 days without changing any pages
- Edit a page
This is a perfectly normal scenario for a site that changes fairly rarely. However there are now errors that stay until the next nightly cron run:
- On admin/config: One or more problems were detected with your Drupal installation. Check the status report for more information.
- On /admin/reports/status: The XML cached files are out of date and need to be regenerated.
False alarms can waste time and should be avoided. It's particularly a problem for people (like me) who are responsible for a fairly large number of sites that all change fairly rarely. In such cases, it makes sense to have mechanisms to gather status reports from all the sites and flag up errors. With many sites, the false alarms can become a nuisance.
In terms of a fix, the simplest thing might be to change xmlsitemap_cron to set xmlsitemap_generated_last if xmlsitemap_regenerate_needed is FALSE. I.e. make the variable to mean "last time we successfully generated whatever needed doing". This seems very simple to code, and I am happy to provide a patch.
Or as an alternative, store a timestamp when xmlsitemap_regenerate_needed was set, and only flag an error based on time elapsed from that time.
Comment | File | Size | Author |
---|---|---|---|
#25 | 2461505-fix-requirement-false-alarms.patch | 6.51 KB | Dave Reid |
| |||
#12 | xmlsitemap.false-alarm-2461505-12.patch | 3.91 KB | AdamPS |
| |||
#10 | xmlsitemap.false-alarm-2461505-10.patch | 2.99 KB | AdamPS |
#8 | xmlsitemap.false-alarm-2461505-8.patch | 2.74 KB | AdamPS |
#1 | xmlsitemap.false-alarm-2461505-1.patch | 524 bytes | AdamPS |
Comments
Comment #1
AdamPS CreditAttribution: AdamPS commentedSimple patch as per suggestion in original post.
Comment #2
Dave ReidMaybe it would be easier to change xmlsitemap_regenerate_needed to a timestamp for when that value was set, and compare the time difference between now and that instead of when it was last generated. I'd rather not be saving 'fake' data for when the files were actually generated.
Comment #3
AdamPS CreditAttribution: AdamPS commented@Dave Reid Thanks for the reply.
Yes I agree that approach would be better. Although presumably it would need care when reading the value that it might not actually be a timestamp, but a bool written by the old code. Or perhaps there could be a hook_update function to correct the bool to a timestamp? Or perhaps keep the bool, and add another variable that is the timestamp?
This improved fix seems more complex and requires more careful testing - and for me a bit more learning. Unfortunately I don't have time right now. I hope that someone else might come along and take up coding the improved fix. In the meantime, my patch does seem to work for anyone else who doesn't mind "fake" data.
Comment #5
darrell_ulm CreditAttribution: darrell_ulm as a volunteer commentedThis could still be an issue. Updated the sitemap, still getting the message. Perhaps the patch was not applied or no good solution found yet? Thanks!
Comment #6
Dave ReidFYI for Drupal 8 you can manually set the cron_threshold_error and cron_threshold_warning values in your xmlsitemap.settings config to make this go away for longer. For Drupal 7 you would edit the cron_threshold_error and cron_threshold_warning variables.
Comment #7
AdamPS CreditAttribution: AdamPS commentedThanks for the suggestion. However I'm not sure that it really solves the problem as people do still want to receive timely alarms if the sitemaps need regenerating and for several days running that fails.
Comment #8
AdamPS CreditAttribution: AdamPS commentedHere is patch for D8 that doesn't save 'fake' data
Comment #10
AdamPS CreditAttribution: AdamPS commentedReroll for dev. #8 applies to stable.
Comment #12
AdamPS CreditAttribution: AdamPS commentedFix the failing test
Comment #13
Dave ReidI'm still confused about why this needs to be changed, because you'd only see this as a warning or error, if you're also getting an error about cron not being run in a long time. For example, my last cron run was 10 hours ago on my local. I have edited a bunch of content, and the xmlsitemap_regenerate_needed flag is TRUE. But I don't see any warning message until I exceed the cron_threshold_warning value. Are you also using a minimum lifetime setting in the XML sitemap settings? Could you take a screenshot of your status report page showing that there is not a cron warning, but there is an XML sitemap warning?
Comment #14
AdamPS CreditAttribution: AdamPS commented@Dave Reid Thanks for taking your time to follow this issue.
The scenario is
Hopefully that makes it clear without the need for any screenshots.
Comment #15
Dave Reid@AdamPS: Oh thank you, that helps explain it a bit more.
Comment #16
Dave ReidI think this should resolve it without needing to set anything else. This also takes into account if cron regeneration is disabled, and re-uses the system settings as intended (using our own settings shouldn't have happened in the D8 porting process).
Comment #18
Dave ReidAdding test coverage.
Comment #19
Dave ReidLeft in a test debugging line, try this one.
Comment #22
Dave ReidThis time using the correct setting in the test.
Comment #23
Dave ReidComment #25
Dave ReidOne more incorrect state variable, should correct the tests.
Comment #26
AdamPS CreditAttribution: AdamPS commentedThanks for making a new patch. I think your idea will solve my scenario and so I would be happy to see it committed.
However there may be some potential complications in certain cases, so I'm just going to run through some scenarios and ask questions in case it helps. Feel free to ignore me:-)
disable_cron_regeneration is FALSE
disable_cron_regeneration is TRUE
I guess this option is a minority, so it less important, but I'll mention it anyway. xmlsitemap needs to generate warnings/errors as needed. However
Non back-compatible change?
The patch retires two existing settings. What about sites that have carefully set the existing settings for a particular reason?
Alternative approach
To cut back to simplicity, you had a good idea in #2 that we could track the time of xmlsitemap_generated_last, i.e. when a change was last made, and generate warnings/errors if it becomes too long ago.
Comment #27
Dave ReidI think we should definitely continue following up with making the regenerate_needed flag a timestamp instead of a boolean, so we can accurately use that. It's going to require more changes, so I think this is a good fix for now and we can continue to iterate on it.
Yeah this is an interesting case, the user would continue to see that the last generated time gets further and further away, and we should be logging errors or exceptions that happen with the regeneration process, so hopefully they are reviewing logs. Making the regenerate_needed a timestamp would also solve this.
Well frankly the module is still in alpha for this reason, I'm noticing a lot of changes like this which went the wrong direction with the module port. This was a regression from the Drupal 7.x-2.x version. If a site administrator has the ability to manually set those configuration values (because they are not exposed in the UI) then I would think that they would have the ability to update the system.cron settings if desired. For site administrators inconvenienced for this change, I offer my apologies and hope they can understand I don't want to be storing additional settings.
Comment #28
AdamPS CreditAttribution: AdamPS commentedThanks for the explanation
Comment #30
Dave ReidI've filed #3007153: Store xmlsitemap_regenerate_needed flag as a timestamp instead of a boolean as a follow-up. Committed #25 to 8.x-1.x. Moving this for consideration for 7.x-2.x now.
Comment #31
AdamPS CreditAttribution: AdamPS commentedGreat many thanks