mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-05 12:47:39 +02:00
Fix unique_id in WebProcessor not being disableable, fixes #1470
This commit is contained in:
@@ -52,6 +52,10 @@ class WebProcessor implements ProcessorInterface
|
|||||||
throw new \UnexpectedValueException('$serverData must be an array or object implementing ArrayAccess.');
|
throw new \UnexpectedValueException('$serverData must be an array or object implementing ArrayAccess.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($this->serverData['UNIQUE_ID'])) {
|
||||||
|
$this->extraFields['unique_id'] = 'UNIQUE_ID';
|
||||||
|
}
|
||||||
|
|
||||||
if (null !== $extraFields) {
|
if (null !== $extraFields) {
|
||||||
if (isset($extraFields[0])) {
|
if (isset($extraFields[0])) {
|
||||||
foreach (array_keys($this->extraFields) as $fieldName) {
|
foreach (array_keys($this->extraFields) as $fieldName) {
|
||||||
@@ -104,10 +108,6 @@ class WebProcessor implements ProcessorInterface
|
|||||||
$extra[$extraName] = isset($this->serverData[$serverName]) ? $this->serverData[$serverName] : null;
|
$extra[$extraName] = isset($this->serverData[$serverName]) ? $this->serverData[$serverName] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($this->serverData['UNIQUE_ID'])) {
|
|
||||||
$extra['unique_id'] = $this->serverData['UNIQUE_ID'];
|
|
||||||
}
|
|
||||||
|
|
||||||
return $extra;
|
return $extra;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -88,6 +88,19 @@ class WebProcessorTest extends TestCase
|
|||||||
$this->assertSame(array('url' => 'A', 'http_method' => 'C'), $record['extra']);
|
$this->assertSame(array('url' => 'A', 'http_method' => 'C'), $record['extra']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testProcessorAddsOnlyRequestedExtraFieldsIncludingOptionalFields()
|
||||||
|
{
|
||||||
|
$server = array(
|
||||||
|
'REQUEST_URI' => 'A',
|
||||||
|
'UNIQUE_ID' => 'X',
|
||||||
|
);
|
||||||
|
|
||||||
|
$processor = new WebProcessor($server, array('url'));
|
||||||
|
$record = $processor($this->getRecord());
|
||||||
|
|
||||||
|
$this->assertSame(array('url' => 'A'), $record['extra']);
|
||||||
|
}
|
||||||
|
|
||||||
public function testProcessorConfiguringOfExtraFields()
|
public function testProcessorConfiguringOfExtraFields()
|
||||||
{
|
{
|
||||||
$server = array(
|
$server = array(
|
||||||
|
Reference in New Issue
Block a user