If you are receiving this error then please ensure that your files directory has write permissions for the httpd service. The most secure setting would be to ensure the group for the files directory is the same as the httpd service owner and give the group on the files directory read, write and execute permissions. If you have the correct permissions and still receive this error then please tell us in a comment below.

ORIGINAL SUMMARY:
I have set up a Drupal 7.12 on a local LAMP running on Debian for a restailying of a site of mine.

Trying to use XML sitemap 7.x-2.0-rc1 and I get the following error while trying to generate the sitemap:
Warning: XMLWriter::openUri(): Empty string as source in XMLSitemapWriter->openUri() (line 40 of /srv/www/silicongadget.com/public_html/modules/xmlsitemap/xmlsitemap.xmlsitemap.inc).

Please tell me if you need any particular info.

CommentFileSizeAuthor
#19 remove_deprecated_realpath-1554488-5.patch519 bytesDr Jay
#18 s3-open-uri-1554488-18.patch972 bytesAnonymous (not verified)
#14 xmlsitemap-s3-open-uri-1554488-14.patch795 bytesAnonymous (not verified)
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Anonymous’s picture

Version: 7.x-2.0-rc1 » 7.x-2.x-dev
Priority: Major » Normal
davidcsonka’s picture

I get the same error. Running Drupal 7.14, 7.x-2.0-rc1, on a Centos multi-site installation.

mgifford’s picture

Version: 7.x-2.x-dev » 7.x-2.0-rc1

I got the same issue on CentOS as well.

Anonymous’s picture

Version: 7.x-2.0-rc1 » 7.x-2.x-dev

Please do not change the Version parameter.

jampsi’s picture

I got the same error message just after enabling the module:
Warning: XMLWriter::openUri(): Empty string as source in XMLSitemapWriter->openUri() (line 40 of /var/www/drupal/sites/all/modules/xmlsitemap/xmlsitemap.xmlsitemap.inc).

kaidjohnson’s picture

I was also getting this error when enabling the module. It turns out that my public:// directory (usually sites/default/files, but may differ based on your site settings) did not have the proper permissions and wasn't writable, so the xmlsitemap directory that needs to get created does not get created so the argument passed through XMLSitemapWriter->openUri() path doesn't exist.

I resolved this simply by setting the permissions of my public:// directory to be writable by the web server user (www-data in my case).

Hope it helps!

Anonymous’s picture

@kaidjohnson: Thanks for the update. Based on your resolution I updated the issue summary.

vanvemden’s picture

Having this issue on Drupal 7.15 install with XML Sitemap 7.x-2.0-rc2 and with the sites default download method set to 'Amazon Simple Storage Service'. When dumping the $uri variable used in public function openUri($uri) in xmlsitemap.xmlsitemap.inc, this is set to 's3://xmlsitemap/NXhscRe04…..'. In the xmlsitemap admin settings the sitemap cache directory is set to s3://xmlsitemap, where the S3// cannot be changed.

Could this be the problem? Should the path not be set to the public file system path, default 'sites/default/files'? Unfortunately I don't have enough knowledge to come up with a patch, but hopefully this will help finding a speedy solution.

Happy New Year, by the way.

Anonymous’s picture

@vanvemden: What is the owner:group and permissions for sites/SITE/files or sites/default/files?

vanvemden’s picture

@earnie: Permissions for sites/default/files is set to 755. Owner and group are set to the account name used to do the Drupal install on the server (which is also the same owner/group for all the other directories). As other modules (e.g. Ctools and CSS injector) had no trouble adding subdirectories in the sites/default/files/ folder, I thought this could not be the problem. Thanks for any help you can provide.

borgenk’s picture

Seems to be an issue when default stream is s3:// as @vanvemden pointed out. Not sure if the problem lies with the xmlsitemap or amazon s3 module though.

Resolved with this hack for now:

function xmlsitemap_file_build_uri($path) {
  $uri = 'public://' . $path;
  return file_stream_wrapper_uri_normalize($uri);
}

/**
 * @} End of "defgroup xmlsitemap_api"
 */
function xmlsitemap_get_directory(stdClass $sitemap = NULL) {
  $directory = &drupal_static(__FUNCTION__);

  if (!isset($directory)) {
    $directory = variable_get('xmlsitemap_path', 'xmlsitemap');
  }

  if (!empty($sitemap->smid)) {
    return xmlsitemap_file_build_uri($directory . '/' . $sitemap->smid);
  }
  else {
    return xmlsitemap_file_build_uri($directory);
  }
}
vanvemden’s picture

@borgenk: Thank you, thank you! It worked!

Anonymous’s picture

Can you work that into a proper patch, please? Also what are the timing differences before and after the patch with http://?

Anonymous’s picture

created a patch based on #11

greggles’s picture

Status: Active » Needs review

Patches "need review".

Thanks, @r_smylski!

Status: Needs review » Needs work

The last submitted patch, xmlsitemap-s3-open-uri-1554488-14.patch, failed testing.

Anonymous’s picture

You need to use ``git diff'' in order to for the test environment to be happier.

Anonymous’s picture

FileSize
972 bytes

re-worked patch

Dr Jay’s picture

I think this approach may be too specific. The answer is more likely to be in the drupal_realpath call in the method as the function is deprecated:

This function was originally written to ease the conversion of 6.x code to use 7.x stream wrappers. However, it assumes that every URI may be resolved to an absolute local filesystem path, and this assumption fails when stream wrappers are used to support remote file storage.

As an alternative, we can use file_create_url to accomplish the same end without the assumptions of drupal_realpath. Submitting a patch for this solution:

haysuess’s picture

#18 worked for me, #19 did not.

With #19 I got these messages:

XMLSitemapGenerationException: Could not open file s3://xmlsitemap/NXhscRe0440PFpI5dSznEVgmauL25KojD7u4e9aZwOM/1.xml for writing. in XMLSitemapWriter->openUri() (line 42 of /home1/graphie0/public_html/pvadrupal/sites/all/modules/xmlsitemap/xmlsitemap.xmlsitemap.inc).

XMLSitemapGenerationException: Could not open file s3://xmlsitemap/NXhscRe0440PFpI5dSznEVgmauL25KojD7u4e9aZwOM/1.xml for writing. in XMLSitemapWriter->openUri() (line 42 of /home1/graphie0/public_html/pvadrupal/sites/all/modules/xmlsitemap/xmlsitemap.xmlsitemap.inc).
bkonetzny’s picture

Can confirm that patch from #18 works (despite the fact that my file now is not on s3) whereas #19 produces the same s3 error message as in #20.

Anonymous’s picture

Getting the same error when running Drupal multisite. "Site 1" running from sites/default is fine but "Site 2" running from folder sites/example.com produces:

"Warning: XMLWriter::openUri(): Empty string as source in XMLSitemapWriter->openUri() (line 40 of /var/www/html/sites/all/modules/xmlsitemap/xmlsitemap.xmlsitemap.inc)."

ressa’s picture

Thanks @kaidjohnson (#6). The newly created xmlsitemap folder owners were MY_USER_NAME:MY_USER_NAME

Updating it to MY_USER_NAME:www-data with sudo chown -R MY_USER_NAME:www-data . fixed it.

ressa’s picture

Issue summary: View changes

Add potential resolution to issue summary.