Skip to content

Commit

Permalink
Merge pull request #151 from ryanathasoffers/prevent_erroneosly_sent_…
Browse files Browse the repository at this point in the history
…FirePHP_and_ChromePHP_header_logs

Fix issue where ChromePHP and FirePHP handlers sent logs to ineligible browsers when >1 handler is instantiated
  • Loading branch information
Seldaek committed Jan 22, 2013
2 parents 47eb599 + e0d18f4 commit d8d5f96
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/Monolog/Handler/ChromePHPHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class ChromePHPHandler extends AbstractProcessingHandler
'rows' => array(),
);

protected $sendHeaders = true;
protected static $sendHeaders = true;

/**
* {@inheritdoc}
Expand Down Expand Up @@ -91,7 +91,7 @@ protected function write(array $record)
protected function send()
{
if (!self::$initialized) {
$this->sendHeaders = $this->headersAccepted();
self::$sendHeaders = $this->headersAccepted();
self::$json['request_uri'] = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';

self::$initialized = true;
Expand All @@ -108,7 +108,7 @@ protected function send()
*/
protected function sendHeader($header, $content)
{
if (!headers_sent() && $this->sendHeaders) {
if (!headers_sent() && self::$sendHeaders) {
header(sprintf('%s: %s', $header, $content));
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/Monolog/Handler/FirePHPHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class FirePHPHandler extends AbstractProcessingHandler
*/
protected static $messageIndex = 1;

protected $sendHeaders = true;
protected static $sendHeaders = true;

/**
* Base header creation function used by init headers & record headers
Expand Down Expand Up @@ -117,7 +117,7 @@ protected function getInitHeaders()
*/
protected function sendHeader($header, $content)
{
if (!headers_sent() && $this->sendHeaders) {
if (!headers_sent() && self::$sendHeaders) {
header(sprintf('%s: %s', $header, $content));
}
}
Expand All @@ -133,7 +133,7 @@ protected function write(array $record)
{
// WildFire-specific headers must be sent prior to any messages
if (!self::$initialized) {
$this->sendHeaders = $this->headersAccepted();
self::$sendHeaders = $this->headersAccepted();

foreach ($this->getInitHeaders() as $header => $content) {
$this->sendHeader($header, $content);
Expand Down

1 comment on commit d8d5f96

@tristanbes
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit/merge is responsible of #152

Please sign in to comment.