XF 1.5 Getting "invalid sitemap file" and related server errors

Solari

Active member
Initially I referenced this thread, thinking it was a permissions issue but our server techs looked at it and determined it's not. We're also getting server errors as shown below:

Code:
ErrorException: fopen(/home/gators/public_html/swampgas/internal_data/sitemaps/sitemap-1522993044-1.xml): failed to open stream: Permission denied - library/XenForo/Deferred/Sitemap.php:210
Generated By: Unknown Account, Today at 1:37 AM
Stack Trace
#0 [internal function]: XenForo_Application::handlePhpError(2, 'fopen(/home/gat...', '/home/gators/pu...', 210, Array)
#1 /home/gators/public_html/swampgas/library/XenForo/Deferred/Sitemap.php(210): fopen('/home/gators/pu...', 'a')
#2 /home/gators/public_html/swampgas/library/XenForo/Deferred/Sitemap.php(230): XenForo_Deferred_Sitemap->_openFile()
#3 /home/gators/public_html/swampgas/library/XenForo/Deferred/Sitemap.php(202): XenForo_Deferred_Sitemap->_writeSitemapString('\t<url><loc>http...')
#4 /home/gators/public_html/swampgas/library/XenForo/Deferred/Sitemap.php(165): XenForo_Deferred_Sitemap->_writeResult(Array)
#5 /home/gators/public_html/swampgas/library/XenForo/Deferred/Sitemap.php(90): XenForo_Deferred_Sitemap->_buildSitemap(Object(XenForo_SitemapHandler_Core), 0, 7.99999904633)
#6 /home/gators/public_html/swampgas/library/XenForo/Model/Deferred.php(295): XenForo_Deferred_Sitemap->execute(Array, Array, 7.99999904633, '')
#7 /home/gators/public_html/swampgas/library/XenForo/Model/Deferred.php(429): XenForo_Model_Deferred->runDeferred(Array, 7.99999904633, '', false)
#8 /home/gators/public_html/swampgas/library/XenForo/Model/Deferred.php(374): XenForo_Model_Deferred->_runInternal(Array, NULL, '', false)
#9 /home/gators/public_html/swampgas/deferred.php(23): XenForo_Model_Deferred->run(false)
#10 {main}
Request State
array(3) {
  ["url"] => string(49) "http://www.gatorcountry.com/swampgas/deferred.php"
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(4) {
    ["_xfRequestUri"] => string(69) "/swampgas/threads/science-proves-liberals-are-psychotic.393217/page-2"
    ["_xfNoRedirect"] => string(1) "1"
    ["_xfToken"] => string(8) "********"
    ["_xfResponseType"] => string(4) "json"
  }
}

And here are the server tech's responses:

Unfortunately, it does not look like this issue is a problem with permissions, as the permissions with the files in /home/gators/public_html/swampgas/internal_data/sitemaps are correct. Adjusting this to the Apache user nobody does not resolve this, since PHP scripts would be running as the gators cPanel user.

Have you attempted to rebuild the sitemap file via Xenforo's interface on this site yet? As Xenforo is not software that we normally support, I can only guess that the issue is with an inappropriately generated sitemap file that is preventing sitemap.php from running as expected, or a recent update making existing sitemap files invalid.

..and in a follow-up:

Like my colleague, I am not seeing any obvious issues with ownership or permissions on the site files. From the command line I tried to perform a trace on running the sitemap.php file that is accessible from the web. Using the php-cgi binary, I just get an error about an "unexpected error". Using the php-cli binary I do get the same error as on the web about the invalid sitemap file, but I am still unsure what would be causing that.

Code:
strace -yrTfs 1024 -e trace=sendto,connect,open,write -u gators -- /usr/bin/php-cli -f /home/gators/public_html/swampgas/sitemap.php

0.000259 open("/home/gators/public_html/swampgas/library/XenForo/Model/Sitemap.php", O_RDONLY) = 6</home/gators/public_html/swampgas/library/XenForo/Model/Sitemap.php> <0.000061>
0.001147 sendto(5<socket:[132166630]>, "\5\0\0\0\31\2\0\0\0", 9, MSG_DONTWAIT, NULL, 0) = 9 <0.000079>
0.000189 sendto(5<socket:[132166630]>, "a\0\0\0\26\n\t\t\tSELECT *\n\t\t\tFROM xf_sitemap\n\t\t\tWHERE is_active = 1\n\t\t\tORDER BY sitemap_id DESC\n\t\t\tLIMIT 1\n\t\t", 101, MSG_DONTWAIT, NULL, 0) = 101 <0.000065>
0.004812 sendto(5<socket:[132166630]>, "\v\0\0\0\27\3\0\0\0\0\1\0\0\0\0", 15, MSG_DONTWAIT, NULL, 0) = 15 <0.000030>
0.000827 open("/home/gators/public_html/swampgas/library/XenForo/Helper/File.php", O_RDONLY) = 6</home/gators/public_html/swampgas/library/XenForo/Helper/File.php> <0.000033>
0.000181 open("/home/gators/public_html/swampgas/library/XenForo/Helper/File.php", O_RDONLY) = 6</home/gators/public_html/swampgas/library/XenForo/Helper/File.php> <0.000021>
0.001142 write(1</dev/pts/0>, "invalid sitemap file", 20invalid sitemap file) = 20 <0.000021>
0.001455 sendto(5<socket:[132166630]>, "\5\0\0\0\31\3\0\0\0", 9, MSG_DONTWAIT, NULL, 0) = 9 <0.000031>
0.000083 sendto(5<socket:[132166630]>, "\1\0\0\0\1", 5, MSG_DONTWAIT, NULL, 0) = 5 <0.000023>
0.005965 +++ exited with 0 +++

strace -yrTfs 1024 -e trace=sendto,connect,open,write -u gators -- php -f /home/gators/public_html/swampgas/sitemap.php

0.000164 open("/home/gators/public_html/swampgas/library/XenForo/Phrase.php", O_RDONLY) = 5</home/gators/public_html/swampgas/library/XenForo/Phrase.php> <0.000019>
0.000962 sendto(4<socket:[132168404]>, "\5\0\0\0\31\3\0\0\0", 9, MSG_DONTWAIT, NULL, 0) = 9 <0.000038>
0.000105 sendto(4<socket:[132168404]>, "\204\0\0\0\26\n\t\t\tSELECT title, phrase_text\n\t\t\tFROM xf_phrase_compiled\n\t\t\tWHERE language_id = ?\n\t\t\t\tAND title IN ('unexpected_error_occurred')\n\t\t", 136, MSG_DONTWAIT, NULL, 0) = 136 <0.000029>
0.000418 sendto(4<socket:[132168404]>, "\20\0\0\0\27\4\0\0\0\0\1\0\0\0\0\1\375\0\0010", 20, MSG_DONTWAIT, NULL, 0) = 20 <0.000041>
0.000489 sendto(4<socket:[132168404]>, "\5\0\0\0\32\4\0\0\0", 9, MSG_DONTWAIT, NULL, 0) = 9 <0.000041>
0.000381 write(1</dev/pts/0>, "An unexpected error occurred. Please try again later.", 53An unexpected error occurred. Please try again later.) = 53 <0.000019>
0.001534 sendto(4<socket:[132168404]>, "\5\0\0\0\31\4\0\0\0", 9, MSG_DONTWAIT, NULL, 0) = 9 <0.000031>
0.000077 sendto(4<socket:[132168404]>, "\1\0\0\0\1", 5, MSG_DONTWAIT, NULL, 0) = 5 <0.000022>
0.006021 +++ exited with 0 +++

Permissions and ownership look correct on these files, and all the other directories up the directory tree.
ls -lah /home/gators/public_html/swampgas/internal_data/sitemaps/

Code:
drwxr-xr-x  2 gators gators 4.0K Mar 30 01:38 .
drwxr-xr-x 11 gators gators 4.0K Mar 23 15:10 ..
-rw-r--r--  1 gators gators    1 Mar  9 11:37 index.html
-rw-r--r--  1 gators gators 209K Mar 12 01:37 sitemap-1520833065-1.xml
-rw-r--r--  1 gators gators 2.6M Mar 14 01:38 sitemap-1521005869-1.xml
-rw-r--r--  1 gators gators 3.5M Mar 16 01:38 sitemap-1521178671-1.xml
-rw-r--r--  1 gators gators 679K Mar 23 01:39 sitemap-1521783561-1.xml
-rw-r--r--  1 gators gators 578K Mar 30 01:38 sitemap-1522388258-1.xml.gz

I also see that php is running as the gators user, so the processes should be able to read/write as necessary.

Code:
ps aux | grep [p]hp

gators    32814 13.5  0.3 214332 102604 ?       S    11:53   0:10 /usr/bin/php
gators    32970 14.5  0.3 206460 93744 ?        S    11:54   0:01 /usr/bin/php

Here's a screenshot of our sitemap log:

Screen Shot 2018-04-06 at 12.47.54 PM.webp
...any suggestions as to what we can do to sort this out?

Thanks!
Ray
 
Top Bottom