merged branch vicb/doctrine_logger_2.1 (PR #5162)
Commits -------6097c80
[DoctrineBridge] Fix log of non utf8 data Discussion ---------- [DoctrineBridge] Fix log of non utf8 data relates to #5139 (fix #5115 for 2.1) --------------------------------------------------------------------------- by travisbot at 2012-08-03T08:34:14Z This pull request [passes](http://travis-ci.org/symfony/symfony/builds/2026546) (merged6097c804
into6f32078b
).
This commit is contained in:
commit
48e384b6e0
@ -10,3 +10,5 @@ CHANGELOG
|
|||||||
* DoctrineType now caches its choice lists in order to improve performance
|
* DoctrineType now caches its choice lists in order to improve performance
|
||||||
* DoctrineType now uses ManagerRegistry::getManagerForClass() if the option "em" is not set
|
* DoctrineType now uses ManagerRegistry::getManagerForClass() if the option "em" is not set
|
||||||
* UniqueEntity validation constraint now accepts a "repositoryMethod" option that will be used to check for uniqueness instead of the default "findBy"
|
* UniqueEntity validation constraint now accepts a "repositoryMethod" option that will be used to check for uniqueness instead of the default "findBy"
|
||||||
|
* [BC BREAK] the DbalLogger::log() visibility has been changed from public to
|
||||||
|
protected
|
||||||
|
@ -47,7 +47,7 @@ class DbalLogger implements SQLLogger
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (null !== $this->logger) {
|
if (null !== $this->logger) {
|
||||||
$this->log($sql.' ('.@json_encode($params).')');
|
$this->log($sql, null === $params ? array() : $params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,9 +65,10 @@ class DbalLogger implements SQLLogger
|
|||||||
* Logs a message.
|
* Logs a message.
|
||||||
*
|
*
|
||||||
* @param string $message A message to log
|
* @param string $message A message to log
|
||||||
|
* @param array $params The context
|
||||||
*/
|
*/
|
||||||
public function log($message)
|
protected function log($message, array $params)
|
||||||
{
|
{
|
||||||
$this->logger->debug($message);
|
$this->logger->debug($message, $params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
48
src/Symfony/Bridge/Doctrine/Tests/Logger/DbalLoggerTest.php
Normal file
48
src/Symfony/Bridge/Doctrine/Tests/Logger/DbalLoggerTest.php
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Bridge\Doctrine\Tests\Logger;
|
||||||
|
|
||||||
|
|
||||||
|
class DbalLoggerTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @dataProvider getLogFixtures
|
||||||
|
*/
|
||||||
|
public function testLog($sql, $params, $logParams)
|
||||||
|
{
|
||||||
|
$logger = $this->getMock('Symfony\\Component\\HttpKernel\\Log\\LoggerInterface');
|
||||||
|
|
||||||
|
$dbalLogger = $this
|
||||||
|
->getMockBuilder('Symfony\\Bridge\\Doctrine\\Logger\\DbalLogger')
|
||||||
|
->setConstructorArgs(array($logger, null))
|
||||||
|
->setMethods(array('log'))
|
||||||
|
->getMock()
|
||||||
|
;
|
||||||
|
|
||||||
|
$dbalLogger
|
||||||
|
->expects($this->once())
|
||||||
|
->method('log')
|
||||||
|
->with($sql, $logParams)
|
||||||
|
;
|
||||||
|
|
||||||
|
$dbalLogger->startQuery($sql, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getLogFixtures()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
array('SQL', null, array()),
|
||||||
|
array('SQL', array(), array()),
|
||||||
|
array('SQL', array('foo' => 'bar'), array('foo' => 'bar'))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user