Quote Originally Posted by wsworx View Post
Hi Lat9. yes its me again
Excuse me for sticking my oar in, I'm not even in my work environment so can't really investigate, but I note the timestamp of your logs is 6 seconds after 5am, which leads me to guess it's a cron job that's running the sitemapxml script at 5am, so your $_SERVER variables may be impacted by the environment the script was run in, differently to the usual browser invocation. I agree with @cartwhat, editing core files is unlikely to be a good idea, unless you've uncovered a genuine bug. From a cursory read of the documentation at https://www.php.net/manual/en/reserv...les.server.php I can't see why SCRIPT_NAME would be null. Can you give us any details of the exact command line that invoked PHP to run the cgi-bin/sitemapxml.php script? Is there something funky going on with the environment? (try `crontab -l | grep sitemap` to see if any cron commands invoke sitemapxml, your environment may vary)

Personally, I might experiment with logging variables to a file to figure out why your variables are null, though Zen Cart has never had a decent logging framework that I've seen. I built Monolog into mine, with file and Graylog handlers.

By the way, you suggested replacing `dirname($_SERVER['SCRIPT_NAME'])` with `dirname($_SERVER ?? ''['SCRIPT_NAME'])`, which would imply that `$_SERVER` may undefined, which is unlikely. I'd suggest `dirname($_SERVER['SCRIPT_NAME'] ?? '')` at the very least, as a more sensible use of the null coalescing operator ??, but still a bad idea as @cartwhat said, find the root cause of the error rather than modifying core files.