Problem/Motivation

This is both a bug fix and an improvement.

For the bug fix, the _xmlsitemap_delete_recursive function is a backport of what D7 does for file_unmanaged_delete_recursive. I'm assuming this must have been copied a long time ago, because it references the function as having two parameters, when it currently only has one. Have removed the second parameter.

For the improvement, have modified the return function to check if $path value is empty. We were regularly seeing warning messages in watchdog from xmlsitemap cron runs that "The file was not deleted, because it does not exist.".

Granted, core's file_unmanaged_delete_recursive function will render this warning in watchdog if the $path is empty. However, the xmlsitemap version of this function has already been edited to check if $delete_root exists when running the return drupal_rmdir($path) line.

I think a similar change should be made for the file_unmanaged_delete step to eliminate the extraneous watchdog messages.

Steps to reproduce

Rebuild xmlsitemap for a site that will return an empty path during regeneration.

Proposed resolution

See attached patch.

Remaining tasks

Review patch and provide feedback. Will modify as necessary. Thanks.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ron_s created an issue.

douggreen’s picture

I've seen a similar error in my logs, but I'm on Drupal 10.2.x (not 7.x as this issue is against), so this is not the right fix. And I don't think the problem is passing an empty path to the delete, because my log shows the 1.xml in the path not being deleted.