Skip to content

Commit 16ac46b

Browse files
committed
Merge branch '2.7' into 2.8
* 2.7: [HttpFoundation] Improve phpdoc [Logging] Add support for firefox in ChromePhpHandler Windows 10 version check in just one line Detect CLI color support for Windows 10 build 10586 [Security] Fixed SwitchUserListener when exiting an impersonication with AnonymousToken [EventDispatcher] Try first if the event is Stopped [FrameworkBundle] fixes grammar in container:debug command manual. [Form] fix "prototype" not required when parent form is not required
2 parents e7d7e1e + 034f476 commit 16ac46b

File tree

12 files changed

+121
-12
lines changed

12 files changed

+121
-12
lines changed

src/Symfony/Bridge/Monolog/Handler/ChromePhpHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function onKernelResponse(FilterResponseEvent $event)
4141
return;
4242
}
4343

44-
if (!preg_match('{\bChrome/\d+[\.\d+]*\b}', $event->getRequest()->headers->get('User-Agent'))) {
44+
if (!preg_match('{\b(?:Chrome/\d+(?:\.\d+)*|Firefox/(?:4[3-9]|[5-9]\d|\d{3,})(?:\.\d)*)\b}', $event->getRequest()->headers->get('User-Agent'))) {
4545
$this->sendHeaders = false;
4646
$this->headers = array();
4747

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,11 @@ public static function register($mode = 0)
194194
private static function hasColorSupport()
195195
{
196196
if ('\\' === DIRECTORY_SEPARATOR) {
197-
return false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI') || 'xterm' === getenv('TERM');
197+
return
198+
0 >= version_compare('10.0.10586', PHP_WINDOWS_VERSION_MAJOR.'.'.PHP_WINDOWS_VERSION_MINOR.'.'.PHP_WINDOWS_VERSION_BUILD)
199+
|| false !== getenv('ANSICON')
200+
|| 'ON' === getenv('ConEmuANSI')
201+
|| 'xterm' === getenv('TERM');
198202
}
199203

200204
return defined('STDOUT') && function_exists('posix_isatty') && @posix_isatty(STDOUT);

src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ protected function configure()
8080
8181
<info>php %command.full_name% --parameters</info>
8282
83-
Display a specific parameter by specifying his name with the <info>--parameter</info> option:
83+
Display a specific parameter by specifying its name with the <info>--parameter</info> option:
8484
8585
<info>php %command.full_name% --parameter=kernel.debug</info>
8686

src/Symfony/Component/Console/Output/StreamOutput.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,19 @@ protected function doWrite($message, $newline)
8585
*
8686
* Colorization is disabled if not supported by the stream:
8787
*
88-
* - Windows without Ansicon, ConEmu or Mintty
88+
* - Windows before 10.0.10586 without Ansicon, ConEmu or Mintty
8989
* - non tty consoles
9090
*
9191
* @return bool true if the stream supports colorization, false otherwise
9292
*/
9393
protected function hasColorSupport()
9494
{
9595
if (DIRECTORY_SEPARATOR === '\\') {
96-
return false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI') || 'xterm' === getenv('TERM');
96+
return
97+
0 >= version_compare('10.0.10586', PHP_WINDOWS_VERSION_MAJOR.'.'.PHP_WINDOWS_VERSION_MINOR.'.'.PHP_WINDOWS_VERSION_BUILD)
98+
|| false !== getenv('ANSICON')
99+
|| 'ON' === getenv('ConEmuANSI')
100+
|| 'xterm' === getenv('TERM');
97101
}
98102

99103
return function_exists('posix_isatty') && @posix_isatty($this->stream);

src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ public function dispatch($eventName, Event $event = null)
124124
$event = new Event();
125125
}
126126

127+
if (null !== $this->logger && $event->isPropagationStopped()) {
128+
$this->logger->debug(sprintf('The "%s" event is already stopped. No listeners have been called.', $eventName));
129+
}
130+
127131
$this->preProcess($eventName);
128132
$this->preDispatch($eventName, $event);
129133

src/Symfony/Component/EventDispatcher/EventDispatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,10 @@ public function removeSubscriber(EventSubscriberInterface $subscriber)
178178
protected function doDispatch($listeners, $eventName, Event $event)
179179
{
180180
foreach ($listeners as $listener) {
181-
call_user_func($listener, $event, $eventName, $this);
182181
if ($event->isPropagationStopped()) {
183182
break;
184183
}
184+
call_user_func($listener, $event, $eventName, $this);
185185
}
186186
}
187187

src/Symfony/Component/Form/Extension/Core/Type/CollectionType.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ public function buildView(FormView $view, FormInterface $form, array $options)
6262
));
6363

6464
if ($form->getConfig()->hasAttribute('prototype')) {
65-
$view->vars['prototype'] = $form->getConfig()->getAttribute('prototype')->createView($view);
65+
$prototype = $form->getConfig()->getAttribute('prototype');
66+
$view->vars['prototype'] = $prototype->setParent($form)->createView($view);
6667
}
6768
}
6869

src/Symfony/Component/Form/Tests/Extension/Core/Type/CollectionTypeTest.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,4 +362,46 @@ public function testPrototypeSetNotRequired()
362362
$this->assertFalse($form->createView()->vars['required'], 'collection is not required');
363363
$this->assertFalse($form->createView()->vars['prototype']->vars['required'], '"prototype" should not be required');
364364
}
365+
366+
public function testPrototypeSetNotRequiredIfParentNotRequired()
367+
{
368+
$child = $this->factory->create('collection', array(), array(
369+
'type' => 'file',
370+
'allow_add' => true,
371+
'prototype' => true,
372+
'prototype_name' => '__test__',
373+
));
374+
375+
$parent = $this->factory->create('form', array(), array(
376+
'required' => false,
377+
));
378+
379+
$child->setParent($parent);
380+
$this->assertFalse($parent->createView()->vars['required'], 'Parent is not required');
381+
$this->assertFalse($child->createView()->vars['required'], 'Child is not required');
382+
$this->assertFalse($child->createView()->vars['prototype']->vars['required'], '"Prototype" should not be required');
383+
}
384+
385+
public function testPrototypeNotOverrideRequiredByEntryOptionsInFavorOfParent()
386+
{
387+
$child = $this->factory->create('collection', array(), array(
388+
'type' => 'file',
389+
'allow_add' => true,
390+
'prototype' => true,
391+
'prototype_name' => '__test__',
392+
'options' => array(
393+
'required' => true,
394+
),
395+
));
396+
397+
$parent = $this->factory->create('form', array(), array(
398+
'required' => false,
399+
));
400+
401+
$child->setParent($parent);
402+
403+
$this->assertFalse($parent->createView()->vars['required'], 'Parent is not required');
404+
$this->assertFalse($child->createView()->vars['required'], 'Child is not required');
405+
$this->assertFalse($child->createView()->vars['prototype']->vars['required'], '"Prototype" should not be required');
406+
}
365407
}

src/Symfony/Component/HttpFoundation/Request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ public static function getHttpMethodParameterOverride()
717717
* Note: Finding deep items is deprecated since version 2.8, to be removed in 3.0.
718718
*
719719
* @param string $key the key
720-
* @param mixed $default the default value
720+
* @param mixed $default the default value if the parameter key does not exist
721721
* @param bool $deep is parameter deep in multidimensional array
722722
*
723723
* @return mixed

src/Symfony/Component/Security/Http/Firewall/SwitchUserListener.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Security\Http\Firewall;
1313

1414
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
15+
use Symfony\Component\Security\Core\User\UserInterface;
1516
use Symfony\Component\Security\Core\User\UserProviderInterface;
1617
use Symfony\Component\Security\Core\User\UserCheckerInterface;
1718
use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface;
@@ -161,7 +162,7 @@ private function attemptExitUser(Request $request)
161162
throw new AuthenticationCredentialsNotFoundException('Could not find original Token object.');
162163
}
163164

164-
if (null !== $this->dispatcher) {
165+
if (null !== $this->dispatcher && $original->getUser() instanceof UserInterface) {
165166
$user = $this->provider->refreshUser($original->getUser());
166167
$switchEvent = new SwitchUserEvent($request, $user);
167168
$this->dispatcher->dispatch(SecurityEvents::SWITCH_USER, $switchEvent);

0 commit comments

Comments
 (0)