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
}

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -307,14 +307,10 @@ final public function finalize($value)
307307
foreach ($this->finalValidationClosures as $closure) {
308308
try {
309309
$value = $closure($value);
310-
} catch (Exception $correctEx) {
311-
throw $correctEx;
312-
} catch (\Exception $invalid) {
313-
throw new InvalidConfigurationException(sprintf(
314-
'Invalid configuration for path "%s": %s',
315-
$this->getPath(),
316-
$invalid->getMessage()
317-
), $invalid->getCode(), $invalid);
310+
} catch (Exception $e) {
311+
throw $e;
312+
} catch (\Exception $e) {
313+
throw new InvalidConfigurationException(sprintf('Invalid configuration for path "%s": %s', $this->getPath(), $e->getMessage()), $e->getCode(), $e);
318314
}
319315
}
320316

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ protected function finalizeValue($value)
197197
$this->prototype->setName($k);
198198
try {
199199
$value[$k] = $this->prototype->finalize($v);
200-
} catch (UnsetKeyException $unset) {
200+
} catch (UnsetKeyException $e) {
201201
unset($value[$k]);
202202
}
203203
}

src/Symfony/Component/Config/FileLocator.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public function locate($name, $currentPath = null, $first = true)
5353
array_unshift($paths, $currentPath);
5454
}
5555

56+
$paths = array_unique($paths);
5657
$filepaths = array();
5758

5859
foreach ($paths as $path) {
@@ -68,7 +69,7 @@ public function locate($name, $currentPath = null, $first = true)
6869
throw new \InvalidArgumentException(sprintf('The file "%s" does not exist (in: %s).', $name, implode(', ', $paths)));
6970
}
7071

71-
return array_values(array_unique($filepaths));
72+
return $filepaths;
7273
}
7374

7475
/**

src/Symfony/Component/Config/Loader/FileLoader.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,12 @@ public function import($resource, $type = null, $ignoreErrors = false, $sourceRe
8686
// we fallback to the current locator to keep BC
8787
// as some some loaders do not call the parent __construct()
8888
// @deprecated should be removed in 3.0
89-
$locator = $loader->getLocator() ?: $this->locator;
89+
$locator = $loader->getLocator();
90+
if (null === $locator) {
91+
@trigger_error('Not calling the parent constructor in '.get_class($loader).' which extends '.__CLASS__.' is deprecated since version 2.7 and will not be supported anymore in 3.0.', E_USER_DEPRECATED);
92+
$locator = $this->locator;
93+
}
94+
9095
$resource = $locator->locate($resource, $this->currentDir, false);
9196
}
9297

src/Symfony/Component/Console/Application.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1086,7 +1086,7 @@ private function splitStringByWidth($string, $width)
10861086
$lines[] = str_pad($line, $width);
10871087
$line = $char;
10881088
}
1089-
if (strlen($line)) {
1089+
if ('' !== $line) {
10901090
$lines[] = count($lines) ? str_pad($line, $width) : $line;
10911091
}
10921092

src/Symfony/Component/Console/Formatter/OutputFormatter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class OutputFormatter implements OutputFormatterInterface
3333
*/
3434
public static function escape($text)
3535
{
36-
return preg_replace('/([^\\\\]?)</is', '$1\\<', $text);
36+
return preg_replace('/([^\\\\]?)</', '$1\\<', $text);
3737
}
3838

3939
/**
@@ -146,7 +146,7 @@ public function format($message)
146146
$offset = 0;
147147
$output = '';
148148
$tagRegex = '[a-z][a-z0-9_=;-]*';
149-
preg_match_all("#<(($tagRegex) | /($tagRegex)?)>#isx", $message, $matches, PREG_OFFSET_CAPTURE);
149+
preg_match_all("#<(($tagRegex) | /($tagRegex)?)>#ix", $message, $matches, PREG_OFFSET_CAPTURE);
150150
foreach ($matches[0] as $i => $match) {
151151
$pos = $match[1];
152152
$text = $match[0];

src/Symfony/Component/Console/Helper/Table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ public function addRow($row)
171171
if ($row instanceof TableSeparator) {
172172
$this->rows[] = $row;
173173

174-
return;
174+
return $this;
175175
}
176176

177177
if (!is_array($row)) {

src/Symfony/Component/Console/Shell.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ private function readline()
206206
} else {
207207
$this->output->write($this->getPrompt());
208208
$line = fgets(STDIN, 1024);
209-
$line = (!$line && strlen($line) == 0) ? false : rtrim($line);
209+
$line = (false === $line || '' === $line) ? false : rtrim($line);
210210
}
211211

212212
return $line;

src/Symfony/Component/Console/Tests/Helper/ProcessHelperTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use Symfony\Component\Console\Helper\DebugFormatterHelper;
1515
use Symfony\Component\Console\Helper\HelperSet;
16-
use Symfony\Component\Console\Helper\Helper;
1716
use Symfony\Component\Console\Output\StreamOutput;
1817
use Symfony\Component\Console\Helper\ProcessHelper;
1918
use Symfony\Component\Process\Process;
@@ -59,7 +58,7 @@ public function provideCommandsAndOutput()
5958
6059
EOT;
6160
$successOutputDebugWithTags = <<<EOT
62-
RUN php -r "echo \"<info>42</info>\";"
61+
RUN php -r "echo '<info>42</info>';"
6362
OUT <info>42</info>
6463
RES Command ran successfully
6564
@@ -92,7 +91,7 @@ public function provideCommandsAndOutput()
9291
array('', 'php -r "echo 42;"', StreamOutput::VERBOSITY_VERBOSE, null),
9392
array($successOutputVerbose, 'php -r "echo 42;"', StreamOutput::VERBOSITY_VERY_VERBOSE, null),
9493
array($successOutputDebug, 'php -r "echo 42;"', StreamOutput::VERBOSITY_DEBUG, null),
95-
array($successOutputDebugWithTags, 'php -r "echo \"<info>42</info>\";"', StreamOutput::VERBOSITY_DEBUG, null),
94+
array($successOutputDebugWithTags, 'php -r "echo \'<info>42</info>\';"', StreamOutput::VERBOSITY_DEBUG, null),
9695
array('', 'php -r "syntax error"', StreamOutput::VERBOSITY_VERBOSE, null),
9796
array($syntaxErrorOutputVerbose, 'php -r "fwrite(STDERR, \'error message\');usleep(50000);fwrite(STDOUT, \'out message\');exit(252);"', StreamOutput::VERBOSITY_VERY_VERBOSE, null),
9897
array($syntaxErrorOutputDebug, 'php -r "fwrite(STDERR, \'error message\');usleep(50000);fwrite(STDOUT, \'out message\');exit(252);"', StreamOutput::VERBOSITY_DEBUG, null),

0 commit comments

Comments
 (0)