Merge branch '3.0'
* 3.0: Fix merge [Form] fix BC break introduced with prototype_data option [Ldap] Escape carriage returns in LDAP DNs. Upgrade for 2.8: ContainerAware was deprecated in favour of ContainerAwareTrait [ci skip] simplify debug error_reporting levels given php version > 5.3 Fix wrong method name mapping in UPGRADE-3.0.md Use correct height for clearer [Validator] fixed raising violations to a maximum of one
This commit is contained in:
commit
1509ec9d53
@ -11,7 +11,7 @@ UPGRADE FROM 2.x to 3.0
|
||||
| `registerNamespaces()` | `addPrefixes()`
|
||||
| `registerPrefixes()` | `addPrefixes()`
|
||||
| `registerNamespaces()` | `addPrefix()`
|
||||
| `registerPrefixes()` | `addPrefix()`
|
||||
| `registerPrefix()` | `addPrefix()`
|
||||
| `getNamespaces()` | `getPrefixes()`
|
||||
| `getNamespaceFallbacks()` | `getFallbackDirs()`
|
||||
| `getPrefixFallbacks()` | `getFallbackDirs()`
|
||||
|
@ -603,7 +603,7 @@ class EntityTypeTest extends TypeTestCase
|
||||
|
||||
$this->persist(array($entity1, $entity2));
|
||||
|
||||
$field = $this->factory->createNamed('name', 'entity', null, array(
|
||||
$field = $this->factory->createNamed('name', EntityType::class, null, array(
|
||||
'multiple' => false,
|
||||
'expanded' => false,
|
||||
'em' => 'default',
|
||||
@ -625,7 +625,7 @@ class EntityTypeTest extends TypeTestCase
|
||||
|
||||
$this->persist(array($entity1, $entity2));
|
||||
|
||||
$field = $this->factory->createNamed('name', 'entity', null, array(
|
||||
$field = $this->factory->createNamed('name', EntityType::class, null, array(
|
||||
'multiple' => false,
|
||||
'expanded' => true,
|
||||
'em' => 'default',
|
||||
@ -651,7 +651,7 @@ class EntityTypeTest extends TypeTestCase
|
||||
|
||||
$this->persist(array($entity1, $entity2, $entity3));
|
||||
|
||||
$field = $this->factory->createNamed('name', 'entity', null, array(
|
||||
$field = $this->factory->createNamed('name', EntityType::class, null, array(
|
||||
'multiple' => true,
|
||||
'expanded' => false,
|
||||
'em' => 'default',
|
||||
@ -682,7 +682,7 @@ class EntityTypeTest extends TypeTestCase
|
||||
|
||||
$this->persist(array($entity1, $entity2, $entity3));
|
||||
|
||||
$field = $this->factory->createNamed('name', 'entity', null, array(
|
||||
$field = $this->factory->createNamed('name', EntityType::class, null, array(
|
||||
'multiple' => true,
|
||||
'expanded' => false,
|
||||
'em' => 'default',
|
||||
@ -707,7 +707,7 @@ class EntityTypeTest extends TypeTestCase
|
||||
|
||||
$this->persist(array($entity1, $entity2, $entity3));
|
||||
|
||||
$field = $this->factory->createNamed('name', 'entity', null, array(
|
||||
$field = $this->factory->createNamed('name', EntityType::class, null, array(
|
||||
'multiple' => true,
|
||||
'expanded' => true,
|
||||
'em' => 'default',
|
||||
|
@ -21,7 +21,7 @@
|
||||
<style>
|
||||
{{ include('@WebProfiler/Profiler/toolbar.css.twig', { 'position': position, 'floatable': true }) }}
|
||||
</style>
|
||||
<div id="sfToolbarClearer-{{ token }}" style="clear: both; height: 38px;"></div>
|
||||
<div id="sfToolbarClearer-{{ token }}" style="clear: both; height: 36px;"></div>
|
||||
{% endif %}
|
||||
|
||||
<div id="sfToolbarMainContent-{{ token }}" class="sf-toolbarreset clear-fix" data-no-turbolink>
|
||||
|
@ -31,7 +31,7 @@ class Debug
|
||||
* @param int $errorReportingLevel The level of error reporting you want
|
||||
* @param bool $displayErrors Whether to display errors (for development) or just log them (for production)
|
||||
*/
|
||||
public static function enable($errorReportingLevel = null, $displayErrors = true)
|
||||
public static function enable($errorReportingLevel = E_ALL, $displayErrors = true)
|
||||
{
|
||||
if (static::$enabled) {
|
||||
return;
|
||||
@ -42,7 +42,7 @@ class Debug
|
||||
if (null !== $errorReportingLevel) {
|
||||
error_reporting($errorReportingLevel);
|
||||
} else {
|
||||
error_reporting(-1);
|
||||
error_reporting(E_ALL);
|
||||
}
|
||||
|
||||
if ('cli' !== php_sapi_name()) {
|
||||
|
@ -113,8 +113,6 @@ class ErrorHandler
|
||||
register_shutdown_function(__CLASS__.'::handleFatalError');
|
||||
}
|
||||
|
||||
$levels = -1;
|
||||
|
||||
if ($handlerIsNew = null === $handler) {
|
||||
$handler = new static();
|
||||
}
|
||||
@ -131,7 +129,7 @@ class ErrorHandler
|
||||
restore_error_handler();
|
||||
}
|
||||
|
||||
$handler->throwAt($levels & $handler->thrownErrors, true);
|
||||
$handler->throwAt(E_ALL & $handler->thrownErrors, true);
|
||||
|
||||
return $handler;
|
||||
}
|
||||
@ -151,7 +149,7 @@ class ErrorHandler
|
||||
* @param array|int $levels An array map of E_* to LogLevel::* or an integer bit field of E_* constants
|
||||
* @param bool $replace Whether to replace or not any existing logger
|
||||
*/
|
||||
public function setDefaultLogger(LoggerInterface $logger, $levels = null, $replace = false)
|
||||
public function setDefaultLogger(LoggerInterface $logger, $levels = E_ALL, $replace = false)
|
||||
{
|
||||
$loggers = array();
|
||||
|
||||
@ -163,7 +161,7 @@ class ErrorHandler
|
||||
}
|
||||
} else {
|
||||
if (null === $levels) {
|
||||
$levels = E_ALL | E_STRICT;
|
||||
$levels = E_ALL;
|
||||
}
|
||||
foreach ($this->loggers as $type => $log) {
|
||||
if (($type & $levels) && (empty($log[0]) || $replace || $log[0] === $this->bootstrappingLogger)) {
|
||||
@ -255,7 +253,7 @@ class ErrorHandler
|
||||
public function throwAt($levels, $replace = false)
|
||||
{
|
||||
$prev = $this->thrownErrors;
|
||||
$this->thrownErrors = (E_ALL | E_STRICT) & ($levels | E_RECOVERABLE_ERROR | E_USER_ERROR) & ~E_USER_DEPRECATED & ~E_DEPRECATED;
|
||||
$this->thrownErrors = E_ALL & ($levels | E_RECOVERABLE_ERROR | E_USER_ERROR) & ~E_USER_DEPRECATED & ~E_DEPRECATED;
|
||||
if (!$replace) {
|
||||
$this->thrownErrors |= $prev;
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ class DebugClassLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->errorReporting = error_reporting(E_ALL | E_STRICT);
|
||||
$this->errorReporting = error_reporting(E_ALL);
|
||||
$this->loader = new ClassLoader();
|
||||
spl_autoload_register(array($this->loader, 'loadClass'), true, true);
|
||||
DebugClassLoader::enable();
|
||||
|
@ -27,11 +27,15 @@ class CollectionType extends AbstractType
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
if ($options['allow_add'] && $options['prototype']) {
|
||||
$prototype = $builder->create($options['prototype_name'], $options['entry_type'], array_replace(array(
|
||||
$prototypeOptions = array_replace(array(
|
||||
'label' => $options['prototype_name'].'label__',
|
||||
), $options['entry_options'], array(
|
||||
'data' => $options['prototype_data'],
|
||||
)));
|
||||
), $options['options']);
|
||||
|
||||
if (null !== $options['prototype_data']) {
|
||||
$prototypeOptions['data'] = $options['prototype_data'];
|
||||
}
|
||||
|
||||
$prototype = $builder->create($options['prototype_name'], $options['entry_type'], $prototypeOptions);
|
||||
$builder->setAttribute('prototype', $prototype->getForm());
|
||||
}
|
||||
|
||||
|
@ -288,4 +288,20 @@ class CollectionTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
||||
|
||||
$this->assertSame('foo', $form->createView()->vars['prototype']->vars['value']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testLegacyPrototypeData()
|
||||
{
|
||||
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', array(), array(
|
||||
'allow_add' => true,
|
||||
'prototype' => true,
|
||||
'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType',
|
||||
'options' => array(
|
||||
'data' => 'bar',
|
||||
),
|
||||
));
|
||||
$this->assertSame('bar', $form->createView()->vars['prototype']->vars['value']);
|
||||
}
|
||||
}
|
||||
|
@ -45,12 +45,12 @@ class DebugHandlersListener implements EventSubscriberInterface
|
||||
* @param bool $scream Enables/disables screaming mode, where even silenced errors are logged
|
||||
* @param string $fileLinkFormat The format for links to source files
|
||||
*/
|
||||
public function __construct(callable $exceptionHandler = null, LoggerInterface $logger = null, $levels = null, $throwAt = -1, $scream = true, $fileLinkFormat = null)
|
||||
public function __construct(callable $exceptionHandler = null, LoggerInterface $logger = null, $levels = E_ALL, $throwAt = E_ALL, $scream = true, $fileLinkFormat = null)
|
||||
{
|
||||
$this->exceptionHandler = $exceptionHandler;
|
||||
$this->logger = $logger;
|
||||
$this->levels = $levels;
|
||||
$this->throwAt = is_numeric($throwAt) ? (int) $throwAt : (null === $throwAt ? null : ($throwAt ? -1 : null));
|
||||
$this->levels = null === $levels ? E_ALL : $levels;
|
||||
$this->throwAt = is_numeric($throwAt) ? (int) $throwAt : (null === $throwAt ? null : ($throwAt ? E_ALL : null));
|
||||
$this->scream = (bool) $scream;
|
||||
$this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
|
||||
}
|
||||
@ -79,7 +79,7 @@ class DebugHandlersListener implements EventSubscriberInterface
|
||||
$scream |= $type;
|
||||
}
|
||||
} else {
|
||||
$scream = null === $this->levels ? E_ALL | E_STRICT : $this->levels;
|
||||
$scream = $this->levels;
|
||||
}
|
||||
if ($this->scream) {
|
||||
$handler->screamAt($scream);
|
||||
|
@ -99,7 +99,20 @@ class LdapClient implements LdapClientInterface
|
||||
*/
|
||||
public function escape($subject, $ignore = '', $flags = 0)
|
||||
{
|
||||
return ldap_escape($subject, $ignore, $flags);
|
||||
$value = ldap_escape($subject, $ignore, $flags);
|
||||
|
||||
// Per RFC 4514, leading/trailing spaces should be encoded in DNs, as well as carriage returns.
|
||||
if ((int) $flags & LDAP_ESCAPE_DN) {
|
||||
if (!empty($value) && $value[0] === ' ') {
|
||||
$value = '\\20'.substr($value, 1);
|
||||
}
|
||||
if (!empty($value) && $value[strlen($value) - 1] === ' ') {
|
||||
$value = substr($value, 0, -1).'\\20';
|
||||
}
|
||||
$value = str_replace("\r", '\0d', $value);
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
private function connect()
|
||||
|
28
src/Symfony/Component/Ldap/Tests/LdapClientTest.php
Normal file
28
src/Symfony/Component/Ldap/Tests/LdapClientTest.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?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\Component\Ldap\Tests;
|
||||
|
||||
use Symfony\Component\Ldap\LdapClient;
|
||||
use Symfony\Polyfill\Php56\Php56 as p;
|
||||
|
||||
/**
|
||||
* @requires extension ldap
|
||||
*/
|
||||
class LdapClientTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testLdapEscape()
|
||||
{
|
||||
$ldap = new LdapClient();
|
||||
|
||||
$this->assertEquals('\20foo\3dbar\0d(baz)*\20', $ldap->escape(" foo=bar\r(baz)* ", null, p::LDAP_ESCAPE_DN));
|
||||
}
|
||||
}
|
@ -38,6 +38,8 @@ class BicValidator extends ConstraintValidator
|
||||
->setParameter('{{ value }}', $this->formatValue($value))
|
||||
->setCode(Bic::INVALID_LENGTH_ERROR)
|
||||
->addViolation();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// must contain alphanumeric values only
|
||||
@ -46,6 +48,8 @@ class BicValidator extends ConstraintValidator
|
||||
->setParameter('{{ value }}', $this->formatValue($value))
|
||||
->setCode(Bic::INVALID_CHARACTERS_ERROR)
|
||||
->addViolation();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// first 4 letters must be alphabetic (bank code)
|
||||
@ -54,6 +58,8 @@ class BicValidator extends ConstraintValidator
|
||||
->setParameter('{{ value }}', $this->formatValue($value))
|
||||
->setCode(Bic::INVALID_BANK_CODE_ERROR)
|
||||
->addViolation();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// next 2 letters must be alphabetic (country code)
|
||||
@ -62,6 +68,8 @@ class BicValidator extends ConstraintValidator
|
||||
->setParameter('{{ value }}', $this->formatValue($value))
|
||||
->setCode(Bic::INVALID_COUNTRY_CODE_ERROR)
|
||||
->addViolation();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// should contain uppercase characters only
|
||||
@ -70,6 +78,8 @@ class BicValidator extends ConstraintValidator
|
||||
->setParameter('{{ value }}', $this->formatValue($value))
|
||||
->setCode(Bic::INVALID_CASE_ERROR)
|
||||
->addViolation();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user