bug #11711 [DoctrineBridge] Fix empty parameter logging in the dbal logger (jakzal)
This PR was squashed before being merged into the 2.3 branch (closes #11711).
Discussion
----------
[DoctrineBridge] Fix empty parameter logging in the dbal logger
| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #11710
| License | MIT
| Doc PR | -
Commits
-------
ef23f02
[DoctrineBridge] Fix empty parameter logging in the dbal logger
This commit is contained in:
commit
0233da8fd7
@ -56,15 +56,15 @@ class DbalLogger implements SQLLogger
|
|||||||
}
|
}
|
||||||
|
|
||||||
// non utf-8 strings break json encoding
|
// non utf-8 strings break json encoding
|
||||||
if (!preg_match('#[\p{L}\p{N} ]#u', $params[$index])) {
|
if (!preg_match('//u', $params[$index])) {
|
||||||
$params[$index] = self::BINARY_DATA_VALUE;
|
$params[$index] = self::BINARY_DATA_VALUE;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// detect if the too long string must be shorten
|
// detect if the too long string must be shorten
|
||||||
if (function_exists('mb_detect_encoding') && false !== $encoding = mb_detect_encoding($params[$index])) {
|
if (function_exists('mb_strlen')) {
|
||||||
if (self::MAX_STRING_LENGTH < mb_strlen($params[$index], $encoding)) {
|
if (self::MAX_STRING_LENGTH < mb_strlen($params[$index], 'UTF-8')) {
|
||||||
$params[$index] = mb_substr($params[$index], 0, self::MAX_STRING_LENGTH - 6, $encoding).' [...]';
|
$params[$index] = mb_substr($params[$index], 0, self::MAX_STRING_LENGTH - 6, 'UTF-8').' [...]';
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -43,7 +43,10 @@ class DbalLoggerTest extends \PHPUnit_Framework_TestCase
|
|||||||
return array(
|
return array(
|
||||||
array('SQL', null, array()),
|
array('SQL', null, array()),
|
||||||
array('SQL', array(), array()),
|
array('SQL', array(), array()),
|
||||||
array('SQL', array('foo' => 'bar'), array('foo' => 'bar'))
|
array('SQL', array('foo' => 'bar'), array('foo' => 'bar')),
|
||||||
|
array('SQL', array('foo' => "\x7F\xFF"), array('foo' => DbalLogger::BINARY_DATA_VALUE)),
|
||||||
|
array('SQL', array('foo' => "bar\x7F\xFF"), array('foo' => DbalLogger::BINARY_DATA_VALUE)),
|
||||||
|
array('SQL', array('foo' => ''), array('foo' => '')),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user