Skip to content

Commit

Permalink
Log a warning when headers have been sent.
Browse files Browse the repository at this point in the history
When headers have already been sent, we can be more helpful by logging
a warning. I've chosen warning as generally production systems I've
worked on have WARN+ enabled as those severity levels indicate issues
that need humans to fix them.

Refs #9159
  • Loading branch information
markstory committed Jul 28, 2016
1 parent adf7320 commit 5c8a0ce
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Network/Response.php
Expand Up @@ -16,6 +16,7 @@

use Cake\Core\Configure;
use Cake\Filesystem\File;
use Cake\Log\Log;
use Cake\Network\Exception\NotFoundException;
use DateTime;
use DateTimeZone;
Expand Down Expand Up @@ -446,7 +447,10 @@ public function send()
*/
public function sendHeaders()
{
if (headers_sent()) {
$file = $line = null;
if (headers_sent($file, $line)) {
Log::warning("Headers already sent in {$file}:{$line}");

return;
}

Expand Down

0 comments on commit 5c8a0ce

Please sign in to comment.