In issue #920062 drupal_realpath() was introduced into the openUri call in xmlsitemap.xmlsitemap.inc

You should *not* be using this function as it completely breaks support for using stream wrappers on remote file systems.

Take a look at the API documention http://api.drupal.org/api/drupal/includes%21file.inc/function/drupal_rea...

Returns the absolute local filesystem path of a stream URI.

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. Remote stream wrappers may implement the realpath method by always returning FALSE. The use of drupal_realpath() is discouraged, and is slowly being removed from core functions where possible.

Only use this function if you know that the stream wrapper in the URI uses the local file system, and you need to pass an absolute path to a function that is incompatible with stream URIs.

@todo: This function is deprecated, and should be removed wherever possible.

My system works perfectly fine to merely remove drupal_realpath($uri) and replace with just $uri for that call, though I'm not sure exactly what you were trying to accomplish by adding it before. Please use something that is portable and not reliant on a local filesystem/deprecated.

CommentFileSizeAuthor
#5 remove_drupal_realpath-1460594.patch502 bytestripper54

Comments

coderintherye’s picture

To further clarify, users using remote filesystems will experience the same errors as some people reported in http://drupal.org/node/920062 which are of the form: WD xmlsitemap: XMLSitemapGenerationException: Could not open file ..../1.xml for writing. in XMLSitemapWriter->openUri()

heathclifff’s picture

Has there been any movement on this? I am having this exact problem and am very interested in having a version of this module which will work locally even if I am using remote file storage (such as amazon s3). Do you have a patch file I could use to get started? Thanks.

coderintherye’s picture

Well, I haven't made a patch since I doubt that will be accepted, but basically just change line 40 of xmlsitemap.xmlsitemap.inc from

$return = parent::OpenUri(drupal_realpath($uri));

to instead be

$return = parent::OpenUri($uri);
Anonymous’s picture

Title: use of drupal_realpath() breaks support for remote filesystems such as amazon s3 » Remove use of deprecated function drupal_realpath()
Priority: Major » Normal
tripper54’s picture

Status: Active » Needs review
StatusFileSize
new502 bytes

Patch attached for review - simply made the changes in #3.

Thanks @coderintherye.

This fixed the errors on my site, which uses s3 as its default storage location.

Anonymous’s picture

Status: Needs review » Reviewed & tested by the community
coderintherye’s picture

Nice, thanks for patching & reviewing, I hope to see this make it in.

sealionking’s picture

thanks very much

it works for mine with s3

dave reid’s picture

So if this works for remote file systems, how does this work on systems where using $uri natively was an issue, like Windows? Does this cause a regression?

coderintherye’s picture

Possibly, is there a test case for that? Or a windows test machine we can throw a potential test case at if we were to create a simpletest for it?

Anonymous’s picture

I'm testing this on my WAMP. So far so good. Where would one expect to see an issue? There is none going to sitemap.xml.

coderintherye’s picture

I believe any issue here would be that the file itself would not be generated properly, so if it works to delete the file and the module recreates it, and updates it when you add a new node, and in addition you can open the sitemap.xml via a browser, then it should be all good.

bkonetzny’s picture

Patch from #5 solves my problems with xmlsitemap and s3, thanks! :)

mgifford’s picture

Would be great to get this in. It's blocking Amazon S3 #2195943: XMLSitemap Fails to Load with AmazonS3 Enabled

The RTBC patch is from 2012. Can we get it in?

dave reid’s picture

Status: Reviewed & tested by the community » Fixed

Committed #5 to 7.x-2.x. Thanks everyone and apologies this was left for so long.
http://drupalcode.org/project/xmlsitemap.git/commit/f1a56a9

mgifford’s picture

Thanks Dave!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.