When I updated my company's quote form I was also instructed to setup a cron job with our host to query the database and gather any data for the people that didn't complete the quote process. It's a three step process and people usually bail when they are asked for an approximate budget (final step). Always kinda made me chuckle.
Anyway, I have a PHP file that is run by the cron job. It simply queries the database, pulls any quotes that match the criteria (a couple flags are set during the process) and then packages up everything and emails it to my manager. It's been in place since early July and works - he receives the emails and is quite pleased with the whole process.
Yesterday we noticed the Instagram feed on our site stopped working abruptly, so I was tasked with looking into fixing it. When I logged into the FTP I noticed our PHP error log had quite a few entries. In fact it was huge, at over 100MB. I pulled it down and noticed many of the errors were due to the Instagram feed, but also over half of them were being caused by 'headers already sent' regarding when a session starts. At first I thought it was related to our small admin area since the person who developed it put the require() to the config.php file under the doctype...
Upon further inspection though I noticed that the timestamps of the errors matched up exactly with our cron job's schedule, so I took a look at that. But I am unable to figure out what is causing the warning. The very first line in the config.php file is the opening <?php tag, and the immediate next line is the session_start() call. This file does include a bunch of other files that do in fact create output, but that's much further down the file.
The file that is being run by the cron job has the opening <?php tag, a bunch of multiline comments explaining what it does, and then a require_once() to the config.php file. The rest is just querying the database, packaging it all up into an email, and sending it off. This of course all happens after the session starts.
I looked into BOM. According to some random answers on the PhpStorm forums, PhpStorm does not add a BOM to files, but also does not remove them if they were already there. I found a keybinding to remove a BOM, so I used it on the files and reuploaded them, but still have the issue. The files are encoded in UTF-8.
Below is what is being logged:
[18-Aug-2015 09:30:00 America/Toronto] PHP Warning: session_start(): Cannot send session cookie - headers already sent in [WEBSITE]/config.php on line 2
[18-Aug-2015 09:30:00 America/Toronto] PHP Warning: session_start(): Cannot send session cache limiter - headers already sent in [WEBSITE]/config.php on line 2
It should be noted that this warning does not appear during normal operation of the website (clicking around, accessing pages, etc.), and no other entries are in the error log.
Any ideas? Anything obscure that may be causing this or something I have overlooked?
Thanks!