The function check if the table exists, before to count the number of links present in it; it would be useful if it would write a log message in that case.

Comments

avpaderno’s picture

StatusFileSize
new715 bytes
avpaderno’s picture

Status: Active » Fixed

This has been changed in CVS.

Anonymous’s picture

Status: Fixed » Needs work

I don't agree with the message. The reason the table doesn't exist is due to the fact that the hook_menu implementation of xmlsitemap.module uses the function and hook_menu is called before the table exists. The only time the table doesn't exist is on a fresh install which isn't an error.

avpaderno’s picture

Title: xmlsitemap_link_count() should log an error message when it doesn't find the database table » Add more calls to watchdog()
Component: xmlsitemap.module » Code

That is not true; the table could not exist for many other reasons, including the fact the table has been accidentally dropped. A fresh install must have the table installed, otherwise an error occurred during the installation of the module.

The message can be shorted to The xmlsitemap table has not been found; in this way, the message would not implicate anything wrong happened with the installation of the modules.

There are many other functions that could report a message in the Drupal log; I am changing the report title to reflect the extended task.

avpaderno’s picture

StatusFileSize
new1009 bytes

This is the patch that changes the previously added call to watchdog(); it also simplify the code by assigning a default to the static variable, which allows the IF-statement to be changed from

  if (empty($link_count)) {
    // ...
  }

to

  if (!$link_count) {
    // ...
  }

.

avpaderno’s picture

StatusFileSize
new1.48 KB

This is the complete patch for xmlsitemap.module.

avpaderno’s picture

Status: Needs work » Active

xmlsitemap_092397.patch has been applied, and the changes committed in CVS. The final code is a little different from that because it has been slightly optimized.

xmlsitemap_delete_cache_files() is now defined as

function xmlsitemap_delete_cache_files() {
  file_scan_directory(
    variable_get('xmlsitemap_cache_directory', file_directory_path() .'/xmlsitemap'),
    'xsm-.*\.xml', array('.', '..', 'CVS'), 'unlink', FALSE
  );
  xmlsitemap_flag_sitemap();
  watchdog('xmlsitemap', 'The sitemap cache files have been deleted.');
}
Anonymous’s picture

Status: Active » Postponed

I'm considering to mark this as won't fix. We don't need to SPAM the watchdog table.

dave reid’s picture

Agreed with won't fix. This is unnecessary.

Anonymous’s picture

Status: Postponed » Closed (won't fix)