Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 80ee9cb

Browse files
Merge branch '2.8'
* 2.8: (42 commits) [DoctrineBridge] Bypass the db when no valid identifier is provided in ORMQueryBuilderLoader [Serializer] Fixed typo in comment [Form] Fixed: Filter non-integers when selecting entities by int ID [Form] [EventListener] fixed sending non array data on submit to ResizeListener Fix merge Fix merge Add test for HHVM FatalErrors [2.6][Debug] Fix fatal-errors handling on HHVM [Debug] Fix log level of stacked errors [Form] Deprecated "cascade_validation" [Form] Add "prototype_data" option to collection type [VarDumper] Fix uninitialized id in HtmlDumper [Form] Added the 'range' FormType Fixed fluent interface [Console] Fix tests on Windows [2.7] Fix unsilenced deprecation notices [2.3][Debug] Fix fatal-errors handling on HHVM [Debug] fix debug class loader case test on windows Standardize the name of the exception variables [Debug+VarDumper] Fix handling of PHP7 exception/error model ... Conflicts: CHANGELOG-2.7.md UPGRADE-2.7.md UPGRADE-2.8.md src/Symfony/Bridge/Twig/AppVariable.php src/Symfony/Component/Console/Helper/DialogHelper.php src/Symfony/Component/Debug/ErrorHandler.php src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php src/Symfony/Component/DependencyInjection/Compiler/ResolveParameterPlaceHoldersPass.php src/Symfony/Component/Form/AbstractType.php src/Symfony/Component/Form/AbstractTypeExtension.php src/Symfony/Component/HttpKernel/Tests/DependencyInjection/ContainerAwareHttpKernelTest.php src/Symfony/Component/HttpKernel/Tests/Logger.php src/Symfony/Component/PropertyAccess/Exception/UnexpectedTypeException.php src/Symfony/Component/Routing/Route.php
2 parents dfb4ccf + 6a2d3a4 commit 80ee9cb

File tree

106 files changed

+1420
-284
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+1420
-284
lines changed

UPGRADE-3.0.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ UPGRADE FROM 2.x to 3.0
353353
* The `request` service was removed. You must inject the `request_stack`
354354
service instead.
355355

356-
* The `templating.helper.assets` was moved to `templating_php.xml`. You can
356+
* The `templating.helper.assets` was removed in Symfony 3.0. You should
357357
use the `assets.package` service instead.
358358

359359
Before:

src/Symfony/Bridge/Doctrine/Form/ChoiceList/ORMQueryBuilderLoader.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,18 @@ public function getEntitiesByIds($identifier, array $values)
9999
$metadata = $qb->getEntityManager()->getClassMetadata($entity);
100100
if (in_array($metadata->getTypeOfField($identifier), array('integer', 'bigint', 'smallint'))) {
101101
$parameterType = Connection::PARAM_INT_ARRAY;
102+
103+
// Filter out non-integer values (e.g. ""). If we don't, some
104+
// databases such as PostgreSQL fail.
105+
$values = array_values(array_filter($values, function ($v) {
106+
return (string) $v === (string) (int) $v;
107+
}));
102108
} else {
103109
$parameterType = Connection::PARAM_STR_ARRAY;
104110
}
111+
if (!$values) {
112+
return array();
113+
}
105114

106115
return $qb->andWhere($where)
107116
->getQuery()

src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/ORMQueryBuilderLoaderTest.php

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use Symfony\Bridge\Doctrine\Test\DoctrineTestHelper;
1616
use Doctrine\DBAL\Connection;
1717

18-
class ORMQueryBuilderLoaderTest extends DoctrineTestHelper
18+
class ORMQueryBuilderLoaderTest extends \PHPUnit_Framework_TestCase
1919
{
2020
/**
2121
* @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException
@@ -27,6 +27,7 @@ public function testItOnlyWorksWithQueryBuilderOrClosure()
2727

2828
/**
2929
* @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException
30+
* @group legacy
3031
*/
3132
public function testClosureRequiresTheEntityManager()
3233
{
@@ -47,16 +48,16 @@ public function testIdentifierTypeIsIntegerArray()
4748

4849
protected function checkIdentifierType($classname, $expectedType)
4950
{
50-
$em = $this->createTestEntityManager();
51+
$em = DoctrineTestHelper::createTestEntityManager();
5152

5253
$query = $this->getMockBuilder('QueryMock')
5354
->setMethods(array('setParameter', 'getResult', 'getSql', '_doExecute'))
5455
->getMock();
5556

5657
$query->expects($this->once())
5758
->method('setParameter')
58-
->with('ORMQueryBuilderLoader_getEntitiesByIds_id', array(), $expectedType)
59-
->will($this->returnValue($query));
59+
->with('ORMQueryBuilderLoader_getEntitiesByIds_id', array(1, 2), $expectedType)
60+
->willReturn($query);
6061

6162
$qb = $this->getMockBuilder('Doctrine\ORM\QueryBuilder')
6263
->setConstructorArgs(array($em))
@@ -65,12 +66,41 @@ protected function checkIdentifierType($classname, $expectedType)
6566

6667
$qb->expects($this->once())
6768
->method('getQuery')
68-
->will($this->returnValue($query));
69+
->willReturn($query);
6970

7071
$qb->select('e')
7172
->from($classname, 'e');
7273

7374
$loader = new ORMQueryBuilderLoader($qb);
74-
$loader->getEntitiesByIds('id', array());
75+
$loader->getEntitiesByIds('id', array(1, 2));
76+
}
77+
78+
public function testFilterNonIntegerValues()
79+
{
80+
$em = DoctrineTestHelper::createTestEntityManager();
81+
82+
$query = $this->getMockBuilder('QueryMock')
83+
->setMethods(array('setParameter', 'getResult', 'getSql', '_doExecute'))
84+
->getMock();
85+
86+
$query->expects($this->once())
87+
->method('setParameter')
88+
->with('ORMQueryBuilderLoader_getEntitiesByIds_id', array(1, 2, 3), Connection::PARAM_INT_ARRAY)
89+
->willReturn($query);
90+
91+
$qb = $this->getMockBuilder('Doctrine\ORM\QueryBuilder')
92+
->setConstructorArgs(array($em))
93+
->setMethods(array('getQuery'))
94+
->getMock();
95+
96+
$qb->expects($this->once())
97+
->method('getQuery')
98+
->willReturn($query);
99+
100+
$qb->select('e')
101+
->from('Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity', 'e');
102+
103+
$loader = new ORMQueryBuilderLoader($qb);
104+
$loader->getEntitiesByIds('id', array(1, '', 2, 3, 'foo'));
75105
}
76106
}

src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,11 @@
176176
{{ block('form_widget_simple') }}
177177
{%- endblock email_widget -%}
178178

179+
{%- block range_widget -%}
180+
{% set type = type|default('range') %}
181+
{{- block('form_widget_simple') -}}
182+
{%- endblock range_widget %}
183+
179184
{%- block button_widget -%}
180185
{%- if label is empty -%}
181186
{%- if label_format is not empty -%}

src/Symfony/Bundle/FrameworkBundle/Resources/config/form.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@
104104
<service id="form.type.radio" class="Symfony\Component\Form\Extension\Core\Type\RadioType">
105105
<tag name="form.type" alias="radio" />
106106
</service>
107+
<service id="form.type.range" class="Symfony\Component\Form\Extension\Core\Type\RangeType">
108+
<tag name="form.type" alias="range" />
109+
</service>
107110
<service id="form.type.repeated" class="Symfony\Component\Form\Extension\Core\Type\RepeatedType">
108111
<tag name="form.type" alias="repeated" />
109112
</service>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?php echo $view['form']->block($form, 'form_widget_simple', array('type' => isset($type) ? $type : 'range'));

src/Symfony/Bundle/FrameworkBundle/Templating/GlobalVariables.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Symfony\Component\DependencyInjection\ContainerInterface;
1515
use Symfony\Component\HttpFoundation\Request;
1616
use Symfony\Component\HttpFoundation\Session\Session;
17-
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
1817
use Symfony\Component\Security\Core\SecurityContext;
1918

2019
/**

src/Symfony/Bundle/TwigBundle/TwigEngine.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function render($name, array $parameters = array())
5353
try {
5454
// try to get the real file name of the template where the error occurred
5555
$e->setTemplateFile(sprintf('%s', $this->locator->locate($this->parser->parse($e->getTemplateFile()))));
56-
} catch (\Exception $ex) {
56+
} catch (\Exception $e2) {
5757
}
5858
}
5959

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/translation.html.twig

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@
5757
{% endblock %}
5858

5959
{% block panelContent %}
60+
{% set filter = request.query.get('state', '-1') %}
61+
{% set filterOptions = {
62+
'-1': '',
63+
(constant('Symfony\\Component\\Translation\\DataCollectorTranslator::MESSAGE_DEFINED')): 'Defined messages',
64+
(constant('Symfony\\Component\\Translation\\DataCollectorTranslator::MESSAGE_MISSING')): 'Missing messages',
65+
(constant('Symfony\\Component\\Translation\\DataCollectorTranslator::MESSAGE_EQUALS_FALLBACK')): 'Fallback messages',
66+
} %}
67+
6068
<h2>Translation Stats</h2>
6169
<table>
6270
<tbody>
@@ -72,6 +80,22 @@
7280
<th>Missing messages</th>
7381
<td><pre>{{ collector.countMissings }}</pre></td>
7482
</tr>
83+
<tr>
84+
<th>Filter</th>
85+
<td>
86+
<form id="filter-form" action="" method="get" style="display: inline">
87+
<input type="hidden" name="panel" value="translation">
88+
<select id="filter" name="state" onchange="document.getElementById('filter-form').submit(); ">
89+
{% for key,option in filterOptions %}
90+
<option value="{{ key }}"{{ filter == key ? ' selected' : '' }}>{{ option }}</option>
91+
{% endfor %}
92+
</select>
93+
<noscript>
94+
<input type="submit" value="refresh">
95+
</noscript>
96+
</form>
97+
</td>
98+
</tr>
7599
</tbody>
76100
</table>
77101

@@ -83,7 +107,7 @@
83107
<th>Id</th>
84108
<th>Message Preview</th>
85109
</tr>
86-
{% for message in collector.messages %}
110+
{% for message in collector.messages if message.state == filter or filter == '-1' %}
87111
<tr>
88112
<td><code>{{ translator.state(message) }}</code></td>
89113
<td><code>{{ message.locale }}</code></td>

src/Symfony/Component/Config/Definition/ArrayNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ protected function finalizeValue($value)
246246

247247
try {
248248
$value[$name] = $child->finalize($value[$name]);
249-
} catch (UnsetKeyException $unset) {
249+
} catch (UnsetKeyException $e) {
250250
unset($value[$name]);
251251
}
252252
}

0 commit comments

Comments
 (0)