We have been having trouble getting the xmlsitemap to work in a WAMP setup. We were trying the latest beta version but it was hanging on cron so I tried the most recent dev version (as of yesterday).
I ran xmlsitemap with just one content type included to see if it would generate the sitemap. The cron no longer timed out, but I found errors like those below in the watchdog logs. The key one is the openUri error as all the other errors stem from that one.
I updated the code in xmlsitemap.xmlsitemap.inc to change:
$this->uri = xmlsitemap_sitemap_get_file($sitemap, $page);
to
$this->uri = $_SERVER['DOCUMENT_ROOT'].'/'.xmlsitemap_sitemap_get_file($sitemap, $page);
and then I no longer got the openUri error and the sitemap was generated properly.
Perhaps there is some system setting that needs to be set for the xmlwriter to be able to find the file properly? I do not normally develop on Windows but this site was put on Windows on the request of the client. Please let me know if you have any idea of how to update the server/settings so as to get the xmlwriter code to understand where the xmlsitemap files live.
Btw, the only post I found that may be related is: http://bugs.php.net/bug.php?id=49051
Thanks in advance for any help you may be able to provide!
Kristen
=====
Errors:
=====
XMLWriter::openUri(): Unable to resolve file path in C:\cv-svnroot\trunk\src\www-drupal\sites\all\modules\xmlsitemap\xmlsitemap.xmlsitemap.inc on line 37.
Could not open file sites/default/files/xmlsitemap/NXhscRe0440PFpI5dSznEVgmauL25KojD7u4e9aZwOM/1.xml for writing. in C:\cv-svnroot\trunk\src\www-drupal\sites\all\modules\xmlsitemap\xmlsitemap.xmlsitemap.inc
XMLWriter::setIndent(): Invalid or unitialized XMLWriter object in C:\cv-svnroot\trunk\src\www-drupal\sites\all\modules\xmlsitemap\xmlsitemap.xmlsitemap.inc
Comment | File | Size | Author |
---|---|---|---|
#53 | 920062.patch | 697 bytes | antiorario |
#33 | 920062-6.x-2.x.patch | 689 bytes | antiorario |
#21 | 920062-generation-realpath-throw-exceptions.patch | 3.14 KB | Dave Reid |
#16 | xmlsitemap.module.php_.patch | 735 bytes | alveoten |
#8 | xmlsitemap.xmlsitemap.inc_920062.patch | 518 bytes | Anonymous (not verified) |
Comments
Comment #1
Kristen PolI've attached a patch file that we are using to get around this issue for now.
Comment #2
sludwig CreditAttribution: sludwig commentedThanks for the patch.
We had the same error on a Windows / Multisite-Installation with the latest dev-Version and with 6.x-2.0-beta2
Comment #3
Anonymous (not verified) CreditAttribution: Anonymous commentedI'm guessing that since this is Windows related the issue has to do with multiple drives and which drive contains the httpd/php binaries and which contains the DOCUMENT_ROOT. No one says here whether Apache or some other brand of httpd is being used. Also shouldn't the fix go to xmlsitemap_sitemap_get_file() instead of prefixing its current result?
Comment #4
sludwig CreditAttribution: sludwig commentedWe have the problem on a installation with the apache / php binaries and DOCUMENT_ROOT on one drive.
Comment #5
Anonymous (not verified) CreditAttribution: Anonymous commentedSo, based on the php bug report listed by the OP this is related to PHP 5.3 and higher. It appears to be related to relative paths in the openURI() function.
Comment #6
sludwig CreditAttribution: sludwig commentedWe get the error with PHP 5.2.13, but i'll try 5.2.9 and give you a feedback
Comment #7
akhmirem CreditAttribution: akhmirem commentedthank you very much! it helped solve my problem. the links were generating, but cache file was empty, now it's working ok.
Comment #8
Anonymous (not verified) CreditAttribution: Anonymous commentedI confirm the error on a Windows 2008 box. I don't tested the patch that uses the $_SERVER variable since the values of this superglobal are not entirely safe to use.
My patch uses the getcwd() function. Tested in Windows 2008 (PHP 5.2), Mac OS X (PHP 5.2) and Ubuntu 10.10 (PHP 5.3).
Comment #10
Anonymous (not verified) CreditAttribution: Anonymous commentedAside from the testbot issue which has nothing to do with this patch in particular, the resolution needs to go in xmlsitemap_sitemap_get_file() and not as a prefix of the return value so that anyone else deciding to use the function gets the correct results without needing to worry about it.
Is the use of getcwd correct here? The getcwd function can return false. Not to mention the fact that the CWD could change unbeknownst to xmlsitemap and cause the file to not be found.
Comment #11
Anonymous (not verified) CreditAttribution: Anonymous commentedIt could be in xmlsitemap_sitemap_get_file() but since just XMLWriter::openUri() needs the full path it's ok to be in the return value (fopen() in xmlsitemap_output_file() works with the relative path correctly in Windows and *Nix).
A check in the return of getcwd() is better than using directly. You're right, Drupal never changes the CWD but a contrib or custom code can change it. We can't use base_path() and (seems) Drupal does not have this data anywhere. Thoughts?
Comment #12
aenw CreditAttribution: aenw commentedsubscribing (And FYI: had this problem on my dev machine: Win 7, Aquia DAMP stack, PHP 5.2.17) Patch fixed it. Yay!
Comment #13
g.paluch CreditAttribution: g.paluch commentedsubscribed
Comment #14
yhhh9 CreditAttribution: yhhh9 commentedthis patch on #8 works and fix my xmlsitemap problem on my win7pro system. many thanks.
Comment #15
Anonymous (not verified) CreditAttribution: Anonymous commentedMade #1168456: openUri doesn't understand the path returned from xmlsitemap_sitemap_get_file. a duplicate of this issue.
Changed title to better suit both issues.
Comment #16
alveoten CreditAttribution: alveoten commentedThis is my patch.
That code replace the drupal "public://" special string with the drupal_real_path()
Comment #17
Anonymous (not verified) CreditAttribution: Anonymous commentedSetting for testbot review.
Comment #18
perusio CreditAttribution: perusio commentedIt works on Debian testing/unstable with PHP 5.3.6. My only beef with this is a stylistic one. Why the need to create a variable? You can do this without any variable using a functional style:
there's no need to create a variable. Just nest the calls and concatenate before calling the outer function.
Comment #19
Anonymous (not verified) CreditAttribution: Anonymous commentedI agree that the variable usage is unnecessary; marking "needs work" for that reason.
Comment #20
alveoten CreditAttribution: alveoten commentedOk, you'll can change the style.
Was for a better debugging.
Comment #21
Dave ReidTook a look at this and discovered that I'm using trigger_error() on failure which *does not* actually stop operation of the process even though I thought ahead and added a try/catch block to generation process using XMLWriter.
Further, the only time we have to use drupal_realpath() is with XMLWriter. All other Drupal functionality should be able to handle it just fine so it doesn't make a lot of sense to have to do it from the API function.
Please test the following patch for 7.x-2.x which uses exceptions proper.
Comment #22
Anonymous (not verified) CreditAttribution: Anonymous commentedI like throwing exceptions because it helps narrow where the issue really is with the call stack display. I haven't tested it since I don't have a xmlsitemap on D7 yet but this patch looks good to me.
Comment #23
antiorario CreditAttribution: antiorario commentedYesterday's 6.x-2.x-dev still throws the same error, and the sitemaps are not generated (returns a 404, as per #789026: sitemap.xml returns "page not found"). I'm using it with the latest domain_xmlsitemap dev, but it still throws the error even with domain_xmlsitemap disabled.
Comment #24
miaoulafrite CreditAttribution: miaoulafrite commented+1
Comment #25
antiorario CreditAttribution: antiorario commentedThe patch at #21 does in fact eliminate the error in 7.x-2.x, and the sitemaps do not return a 404.
However, the sitemaps contain only one URL (the front page in the default language).Comment #26
Anonymous (not verified) CreditAttribution: Anonymous commented#25: Did you enable xmlsitemap for any content types? See the admin/structure/types and edit each content type you want to include in sitemap.xml to enable it.
Comment #27
antiorario CreditAttribution: antiorario commentedYikes. Thanks earnie—I've installed and uninstalled the module so many times I'm surprised I forgot that part.
Comment #28
antiorario CreditAttribution: antiorario commentedNow… any chance for this fix to be backported to 6.x-2.x?
Comment #29
Dave ReidFix committed to 7.x-2.x and 6.x-2.x:
http://drupalcode.org/project/xmlsitemap.git/commit/fc45a5c
http://drupalcode.org/project/xmlsitemap.git/commit/77632d8
Everyone please give this a test if you can in about 24 hours.
Comment #30
antiorario CreditAttribution: antiorario commentedProblem still present in 6.x-2.x (both in beta 3 and the latest dev, which I assume are the same). When I do a sitemap regeneration, first I get
then the old
Comment #32
antiorario CreditAttribution: antiorario commented7.x-2.x-beta3 works like a charm.
Comment #33
antiorario CreditAttribution: antiorario commentedI worked a bit on 6.x-2.x, and realized that realpath() was still returning FALSE with download method set to 'public', since the file system path is relative to the Drupal root folder. On the other hand, it works well with the download method set to 'private'.
So I added a condition by which, in case of public download method, the $uri is appended to the absolute path of the Drupal root. Maybe it's just a workaround and it can be done more elegantly (plus, I've tested it only on LAMP, thus have no idea if it would work on other kinds of servers), but it works on my side.
Comment #34
tomsm CreditAttribution: tomsm commentedThis patch solved my problem. The sitemap could not be found. I use IIS.
Comment #35
antiorario CreditAttribution: antiorario commentedSince this isn't really fixed for 6.x-2.x, and no one has given feedback about my patch, I'll change the version number to this issue.
Comment #36
ferrum CreditAttribution: ferrum commentedI'm using version 6.x-2.0-beta3 in combination with patch #33 and it's working fine for xampp and windows. Without the patch I got exceptions and cron did not end correctly.
Thanks
Comment #37
carusen CreditAttribution: carusen commentedHi,
I have 7.x-2.0-beta 3 and it doesn't generate a sitemap even if file permissions are double-checked and set correctly. I had the same problem when was on version 6.x-2.0-beta 3. I had to downgrade to 6.x-1.2 to have it work properly.
Both 6.x-2.0-beta 3 (on drupal 6) and 7.x-2.0-beta 3 (after I migrated to drupal 7) do not work. They both return the same error:
"Warning: XMLWriter::openUri() [xmlwriter.openuri]: SAFE MODE Restriction in effect. The script whose uid is 10003 is not allowed to access /var/www/vhosts/taxibusteni.ro/httpdocs/sites/default/files/xmlsitemap/NXhscRe0440PFpI5dSznEVgmauL25KojD7u4e9aZwOM owned by uid 48 in XMLSitemapWriter->openUri() (line 40 of /var/www/vhosts/taxibusteni.ro/httpdocs/modules/xmlsitemap/xmlsitemap.xmlsitemap.inc).
Warning: XMLWriter::openUri(/var/www/vhosts/taxibusteni.ro/httpdocs/sites/default/files/xmlsitemap/NXhscRe0440PFpI5dSznEVgmauL25KojD7u4e9aZwOM/1.xml) [xmlwriter.openuri]: failed to open stream: Success in XMLSitemapWriter->openUri() (line 40 of /var/www/vhosts/taxibusteni.ro/httpdocs/modules/xmlsitemap/xmlsitemap.xmlsitemap.inc).
Warning: XMLWriter::openUri() [xmlwriter.openuri]: xmlNewTextWriterFilename : out of memory! in XMLSitemapWriter->openUri() (line 40 of /var/www/vhosts/taxibusteni.ro/httpdocs/modules/xmlsitemap/xmlsitemap.xmlsitemap.inc).
XMLSitemapGenerationException: Could not open file public://xmlsitemap/NXhscRe0440PFpI5dSznEVgmauL25KojD7u4e9aZwOM/1.xml for writing. in XMLSitemapWriter->openUri() (line 42 of /var/www/vhosts/taxibusteni.ro/httpdocs/modules/xmlsitemap/xmlsitemap.xmlsitemap.inc)."
Comment #38
Anonymous (not verified) CreditAttribution: Anonymous commented@carusen: This message is coming from your server. See http://php.net/manual/en/features.safe-mode.php and the links contained in the page for more information. This is not an issue with xmlsitemap. It also has nothing to do with the entitled subject so please in the future, if you have an issue that doesn't match exactly the subject then open a new issue. If it is a duplicate, someone will let you know. Hijacking an issue is worse than having a duplicate, IMO.
Comment #39
carusen CreditAttribution: carusen commentedThen how come older versions of the same module work? Also, I did not make any settings on the server to have it working in safe mode.
Comment #40
carusen CreditAttribution: carusen commentedI edited .htaccess to make sure php safe mode is set to turn off. Now the error message is:
Warning: XMLWriter::openUri() [xmlwriter.openuri]: Empty string as source in XMLSitemapWriter->openUri() (line 40 of /var/www/vhosts/taxibusteni.ro/httpdocs/modules/xmlsitemap/xmlsitemap.xmlsitemap.inc).
XMLSitemapGenerationException: Could not open file /var/www/vhosts/taxibusteni.ro/httpdocs/sites/default/files/xmlsitemap/NXhscRe0440PFpI5dSznEVgmauL25KojD7u4e9aZwOM/1.xml for writing. in XMLSitemapWriter->openUri() (line 42 of /var/www/vhosts/taxibusteni.ro/httpdocs/modules/xmlsitemap/xmlsitemap.xmlsitemap.inc).
Comment #41
Anonymous (not verified) CreditAttribution: Anonymous commentedDoes admin/reports/status give you a clue?
Comment #42
carusen CreditAttribution: carusen commentedIt just says:
"XML sitemap Cached files have not been generated yet.
The XML cached files are out of date and need to be regenerated. You can run cron manually to regenerate the sitemap files."
If i try to run cron, it crashes with the error shared in the previous post.
Comment #43
antiorario CreditAttribution: antiorario commentedMaybe you've done all this, but have you tried disabling and uninstalling the module(s)? If you haven't, I recommend doing that, then restarting by deleting the xmlsitemap directory and redownloading 6.x-2.x-dev and repatching it. Sometimes using a fresh copy helps.
Comment #44
mandreato CreditAttribution: mandreato commentedI had this issue after upgrading to 6.x-2.0-beta3 (on a test environment).
Tried patch #33 and it solved the problem --> hope this will be commited soon.
Thank you antiorario !
Comment #45
carusen CreditAttribution: carusen commented@antiorario - i tried that multiple times. Unfortunately i now migrated to drupal 7. I cannot revert back to 6. On Drupal 6, patch #33 fixes things. Can't someone take a look at what that patch fixes and submit it to the drupal 7 release too?
This module is vital to any website. It is a pity it doesn't work. It must cause issues to many webmasters. :(
Comment #46
antiorario CreditAttribution: antiorario commented@carusen I assume it's too late now to advise you never to upgrade a website without making a copy of the database and all the files first.
In any case, 7.x-2.x-beta3 and 7.x-2.x-dev already work as expected. My patch to 6.x-2.x-dev provides the necessary changes to make the D6 version work like the D7 version. The fact that you're still getting the error makes me think that something else is wrong on your installation.
I suggest you try with a clean install and see for yourself.
Comment #47
antiorario CreditAttribution: antiorario commented@earnie I (and others too, I imagine) would really appreciate it if my patch were properly tested and, possibly, committed.
Comment #48
Anonymous (not verified) CreditAttribution: Anonymous commented@antiorario: Dave Reid will need to make the commit and the final decision for the properness of the patch. The comment though is a bit long and needs to be broken into multiple lines, IMO.
Comment #49
rukaya CreditAttribution: rukaya commentedPatch in #33 worked for me, thanks antiorario
Comment #50
Anonymous (not verified) CreditAttribution: Anonymous commentedDave the patch in #33 has been tested by community members. You need to review it and apply, please.
Comment #51
Dave ReidWhy do we need realpath() to run twice? Can't we just prepend './'? Also the comment is too long and needs to be wrapped at 80 characters.
Comment #52
antiorario CreditAttribution: antiorario commentedIf I do
it returns FALSE, which makes my patch useless. As far as I understand, the only way to make it work is to find the real path of the Drupal root first, then find the real path of the whole directory. We could avoid running realpath() the second time for public downloads, but then we wouldn't be sure that the path is symlink-free.
Comment #53
antiorario CreditAttribution: antiorario commentedI stand by my patch. Here's a new one with the comment broken in two lines.
Comment #54
antiorario CreditAttribution: antiorario commentedAny updates?
Comment #55
RobertOak CreditAttribution: RobertOak commentedThis patch worked for me on 6.x2.0-beta3. I had no idea this was crashing my production server previously every time cron was called, so thanks for the fast fix.
Also, when enabling the node piece, I can "file not found". I looked through the bug reports and see a lot of "blow off" on this error, even though everyone's rewrites are working fine and so on.
Comment #56
Anonymous (not verified) CreditAttribution: Anonymous commentedLeave the Version alone.
Comment #57
marktheshark CreditAttribution: marktheshark commentedWill this be committed to dev and main soon? Thank you
Comment #58
carvalhar CreditAttribution: carvalhar commented#53 works.
At first, only home was at sitemap, i noticed that this beta adds a "include/exclude" option, so all already created nodes need to be saved again and the content type needs to be updated also.
Comment #59
Bartezz CreditAttribution: Bartezz commented#53 works for me!
Cheers
Comment #60
ZeiP CreditAttribution: ZeiP commented#53 worked for me too on 6.x-2.0-beta3.
Comment #61
chefarov CreditAttribution: chefarov commented#53 Doesn't work for me... :(
I still get:
line 56 of my xmlsitemap.xmlsitemap.inc file is:
in the known openUri function...
Comment #62
polskikrol CreditAttribution: polskikrol commented#53 worked for me.
Comment #63
Dave ReidComment #64
tomsm CreditAttribution: tomsm commentedThis issue still exists in 6.x-2.0-rc1.
After applying the patch of #53 it is fixed.
Comment #65
mattcasey CreditAttribution: mattcasey commented#53 also works for me, using 6.x-2.0-rc1
Comment #66
infines CreditAttribution: infines commentedThe issue still exists in 7.x-2.0-rc1
Comment #67
monil-dupe CreditAttribution: monil-dupe commentedIf the problem exists in 7.x-2.0-rc1 version which is released on 2011-Dec-16 , when can we expect the new fixed version?
Comment #68
infines CreditAttribution: infines commentedComment #69
Anonymous (not verified) CreditAttribution: Anonymous commented@gridbitlabs: #53 has been reviewed and tested for version 6.x-2.x let's get that committed to the repository.
Comment #70
manxian CreditAttribution: manxian commented#53 worked for me. Please can you release the patched module?
Windows XP, Apache (Wamp) server, PHP 5.3 (I know, 5.2 preferred)
Thanks.
Comment #71
Anonymous (not verified) CreditAttribution: Anonymous commentedLEAVE THE META DATA ALONE. The patch is for 6.x-2.x-dev.
Comment #72
manxian CreditAttribution: manxian commented@earnie: Not sure if your comment was aimed at me - but since it followed mine I assume so.
1. My post was polite and, as we were asked to respond with our test results, I did so.
2. You may be an old hand at this - I am not. There is no need to SHOUT.
3. I had no idea I was changing the META - how have I done that?
4. When I applied the patch I did what others before me had done with success (see #65, #64). If you go back further it was applied to various versions by various people (perhaps because it does not state which version it is for - unless you view the 'details')
5. I have tried to find our what is different between 6.x-2.x-dev and 6.x-2.0-rc1 (since they were released only 2 days apart) and cannot find the information. I'm not saying it isn't there - I just cannot find it.
Since it worked for others and because the patch 'fits' into 6.x-2.0-rc1 (this is currently the 'stable' version - see the project page) I don't want to introduce other instabilities if I can avoid it - hence using rc1.
If I could find out what had changed to between 6.x-2.0-rc1 and 6.x-2.x-dev I would be happier about using it and applying the patch to it. Perhaps you would advise and educate on how one goes about finding out?
Finally, my thanks to whoever is working on this. Are we any nearer to getting a released module which includes #53?
Comment #73
Anonymous (not verified) CreditAttribution: Anonymous commentedI must have had to revert more than one or other parts of my life had me frustrated to the point of shouting, I do not apologize for doing so though since you'll tend to remember it now. You changed the "Version" which is a piece of meta data for the issue. The 2.0-rc1 version is a tagged and released code set based on a state of the code in VCS at the time of the release. The 2.x-dev version is an untagged code set based on the current state of the code in VCS for the branch. As for Dave's time to commit patches, he'll need to answer that.
Comment #74
bwinett CreditAttribution: bwinett commented#53 worked for me, running 6.x-2.0-rc1, Windows 7, XAMPP, PHP 5.3.5.
Comment #75
zany CreditAttribution: zany commentedPatch #53 Reviewed and tested with 6.x-2.0-rc1. This is broken in 6.x-2.0-rc1 and will stop cron from working properly. It is a major problem if cron can't run.
Comment #76
marco.difresco CreditAttribution: marco.difresco commentedI confirm the problem for the version 7.x-2.0-rc1.
Any news?
Comment #77
Anonymous (not verified) CreditAttribution: Anonymous commentedThe patch is reviewed and tested for 6.x-2.x-dev.
Comment #78
marco.difresco CreditAttribution: marco.difresco commentedEarnie,
you mention that the patch is reviewed and tested for 6.x-2.x-dev and I guess it is for Drupal 6.x (as I learnt so far for Drupal modules version names scheme, but I admit I am using Drupal for just about a month), but what about those who are using Drupal 7.x?
Should we open a separate bug (I would happily do it if you say so, but I will have time only this evening CET)?
Comment #79
Anonymous (not verified) CreditAttribution: Anonymous commentedNormally I would say no but in this case I'm going to say yes.
Comment #80
marco.difresco CreditAttribution: marco.difresco commentedOk, I will.
Thank.
Comment #81
8perezm CreditAttribution: 8perezm commentedI have the latest 7.x-2.0-rc2 installed and it still has the problem. Interestingly the problem doesn't occur on my local development windows copy but does on the production LAMP server.
My cron tasks won't fully complete because of the issue and the XML sitemap doesn't create any sitemaps on the server.
Here's my log:
Comment #82
serkan.arikusu CreditAttribution: serkan.arikusu commentedI confirm #81
Using latest 7.x-2.0-rc2 and getting
Warning: XMLWriter::openUri() [xmlwriter.openuri]: Empty string as source in XMLSitemapWriter->openUri() (line 40 of /home/barisder/public_html/sites/all/modules/xmlsitemap/xmlsitemap.xmlsitemap.inc).
PHP Version => 5.2.17
Comment #83
Anonymous (not verified) CreditAttribution: Anonymous commentedSee comment #79.
Comment #84
derjochenmeyer CreditAttribution: derjochenmeyer commented#53 worked for me, running version 6.x-2.0-rc2
Comment #85
rondp CreditAttribution: rondp commentedConfirming that #53 worked for me with 6.x-2.0-rc2.
I'd also like to add that without that patch, it's actually impossible to generate a sitemap in the first place—I only just installed the module and it took me a while to figure out what was going on and get it to work (after eventually getting here and applying #53).
Perhaps a note on the project page might be in order?
Comment #86
armyofda12mnkeys CreditAttribution: armyofda12mnkeys commentedI updating my drupal from 6.22 to 6.28 (and a few modules including this one) and also upgraded from php5.2 to 5.3...
Ran into this issue... (not sure which one of the upgrades above caused it though, also moved the site locally on Windows to test so could be one of above upgrades in combo with running on Windows... seems like based on above comments its prob 5.3 issue )...
Anyway above #53 works... Why not include in the old 2012 release candidate (if its the recommended download for 6) if it breaks Drupal latest 6 builds?
Comment #87
Grabby CreditAttribution: Grabby commented#53 needed for my site to work as well
6.x-2.0-rc2
PHP 5.3.10
Comment #88
CodeChaser CreditAttribution: CodeChaser commentedcomment #53 worked for me thank you!
Comment #89
Grabby CreditAttribution: Grabby commentedAny reason #53 was apparently not included in 6.x-2.0?
Comment #90
Harry Slaughter21: 920062-generation-realpath-throw-exceptions.patch queued for re-testing.
Comment #92
pifagor