Merge branch '4.1'

* 4.1:
  fix merge
  [travis][appveyor] use symfony/flex to accelerate builds
  Add missing stderr redirection
  clean up unused code
  Remove the HTML5 validation from the profiler URL search form
  [Filesystem] Add test to prevent regression when using array|resource with dumpFile
  Add help texts for checkboxes in horizontal bootstrap 4 forms
  [Security] Call AccessListener after LogoutListener
This commit is contained in:
Nicolas Grekas 2018-08-18 18:57:16 +02:00
commit 1c248e572e
14 changed files with 140 additions and 48 deletions

View File

@ -188,6 +188,15 @@ install:
SYMFONY_VERSION=$(cat composer.json | grep '^ *"dev-master". *"[1-9]' | grep -o '[0-9.]*')
fi
- |
# Install symfony/flex
if [[ $deps = low ]]; then
export SYMFONY_REQUIRE='>=2.3'
else
export SYMFONY_REQUIRE=">=$SYMFONY_VERSION"
fi
composer global require symfony/flex dev-master
- |
# Legacy tests are skipped when deps=high and when the current branch version has not the same major version number than the next one
[[ $deps = high && ${SYMFONY_VERSION%.*} != $(git show $(git ls-remote --heads | grep -FA1 /$SYMFONY_VERSION | tail -n 1):composer.json | grep '^ *"dev-master". *"[1-9]' | grep -o '[0-9]*' | head -n 1) ]] && LEGACY=,legacy

View File

@ -10,6 +10,7 @@ init:
- SET PATH=c:\php;%PATH%
- SET COMPOSER_NO_INTERACTION=1
- SET SYMFONY_DEPRECATIONS_HELPER=strict
- SET "SYMFONY_REQUIRE=>=4.2"
- SET ANSICON=121x90 (121x90)
- REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Command Processor" /v DelayedExpansion /t REG_DWORD /d 1 /f
@ -40,9 +41,10 @@ install:
- echo extension=php_curl.dll >> php.ini-max
- copy /Y php.ini-max php.ini
- cd c:\projects\symfony
- IF NOT EXIST composer.phar (appveyor DownloadFile https://getcomposer.org/download/1.3.0/composer.phar)
- IF NOT EXIST composer.phar (appveyor DownloadFile https://github.com/composer/composer/releases/download/1.7.1/composer.phar)
- php composer.phar self-update
- copy /Y .composer\* %APPDATA%\Composer\
- php composer.phar global require --no-progress symfony/flex dev-master
- php .github/build-packages.php "HEAD^" src\Symfony\Bridge\PhpUnit
- IF %APPVEYOR_REPO_BRANCH%==master (SET COMPOSER_ROOT_VERSION=dev-master) ELSE (SET COMPOSER_ROOT_VERSION=%APPVEYOR_REPO_BRANCH%.x-dev)
- php composer.phar update --no-progress --no-suggest --ansi

View File

@ -12,7 +12,7 @@ class CoverageListenerTest extends TestCase
$this->markTestSkipped('This test cannot be run on Windows.');
}
exec('type phpdbg', $output, $returnCode);
exec('type phpdbg 2> /dev/null', $output, $returnCode);
if (\PHP_VERSION_ID >= 70000 && 0 === $returnCode) {
$php = 'phpdbg -qrr';

View File

@ -81,6 +81,7 @@ col-sm-10
<div class="{{ block('form_label_class') }}"></div>{#--#}
<div class="{{ block('form_group_class') }}">
{{- form_widget(form) -}}
{{- form_help(form) -}}
{{- form_errors(form) -}}
</div>{#--#}
</div>

View File

@ -214,4 +214,24 @@ abstract class AbstractBootstrap4HorizontalLayoutTest extends AbstractBootstrap4
$this->assertMatchesXpath($html, '/div[@class="form-group row"]/div[@class="col-sm-2" or @class="col-sm-10"]', 2);
}
public function testCheckboxRowWithHelp()
{
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\CheckboxType');
$view = $form->createView();
$html = $this->renderRow($view, array('label' => 'foo', 'help' => 'really helpful text'));
$this->assertMatchesXpath($html,
'/div
[@class="form-group row"]
[
./div[@class="col-sm-2" or @class="col-sm-10"]
/following-sibling::div[@class="col-sm-2" or @class="col-sm-10"]
[
./small[text() = "[trans]really helpful text[/trans]"]
]
]
'
);
}
}

View File

@ -49,4 +49,14 @@ class LogoutTest extends WebTestCase
$this->assertFalse(static::$container->get('security.csrf.token_storage')->hasToken('foo'));
}
public function testAccessControlDoesNotApplyOnLogout()
{
$client = $this->createClient(array('test_case' => 'LogoutAccess', 'root_config' => 'config.yml'));
$client->request('POST', '/login', array('_username' => 'johannes', '_password' => 'test'));
$client->request('GET', '/logout');
$this->assertRedirect($client->getResponse(), '/');
}
}

View File

@ -0,0 +1,18 @@
<?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.
*/
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
use Symfony\Bundle\SecurityBundle\SecurityBundle;
return array(
new FrameworkBundle(),
new SecurityBundle(),
);

View File

@ -0,0 +1,26 @@
imports:
- { resource: ./../config/framework.yml }
security:
encoders:
Symfony\Component\Security\Core\User\User: plaintext
providers:
in_memory:
memory:
users:
johannes: { password: test, roles: [ROLE_USER] }
firewalls:
default:
form_login:
check_path: login
remember_me: true
require_previous_session: false
logout: ~
anonymous: ~
stateless: true
access_control:
- { path: ^/login$, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: .*, roles: IS_AUTHENTICATED_FULLY }

View File

@ -0,0 +1,5 @@
login:
path: /login
logout:
path: /logout

View File

@ -22,7 +22,7 @@
<div class="form-group">
<label for="url">URL</label>
<input type="url" name="url" id="url" value="{{ url }}">
<input type="text" name="url" id="url" value="{{ url }}">
</div>
<div class="form-group">

View File

@ -1467,6 +1467,31 @@ class FilesystemTest extends FilesystemTestCase
}
}
public function testDumpFileWithArray()
{
$filename = $this->workspace.\DIRECTORY_SEPARATOR.'foo'.\DIRECTORY_SEPARATOR.'baz.txt';
$this->filesystem->dumpFile($filename, array('bar'));
$this->assertFileExists($filename);
$this->assertStringEqualsFile($filename, 'bar');
}
public function testDumpFileWithResource()
{
$filename = $this->workspace.\DIRECTORY_SEPARATOR.'foo'.\DIRECTORY_SEPARATOR.'baz.txt';
$resource = fopen('php://memory', 'rw');
fwrite($resource, 'bar');
fseek($resource, 0);
$this->filesystem->dumpFile($filename, $resource);
fclose($resource);
$this->assertFileExists($filename);
$this->assertStringEqualsFile($filename, 'bar');
}
public function testDumpFileOverwritesAnExistingFile()
{
$filename = $this->workspace.\DIRECTORY_SEPARATOR.'foo.txt';

View File

@ -16,6 +16,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\FinishRequestEvent;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\Security\Http\Firewall\AccessListener;
use Symfony\Component\Security\Http\Firewall\LogoutListener;
/**
@ -55,20 +56,31 @@ class Firewall implements EventSubscriberInterface
$listeners[2] = null;
}
$authenticationListeners = $listeners[0];
$exceptionListener = $listeners[1];
$logoutListener = $listeners[2];
$accessListener = null;
$authenticationListeners = array();
if (null !== $exceptionListener) {
foreach ($listeners[0] as $listener) {
if ($listener instanceof AccessListener) {
$accessListener = $listener;
} else {
$authenticationListeners[] = $listener;
}
}
if (null !== $exceptionListener = $listeners[1]) {
$this->exceptionListeners[$event->getRequest()] = $exceptionListener;
$exceptionListener->register($this->dispatcher);
}
$this->handleRequest($event, $authenticationListeners);
if (null !== $logoutListener) {
$logoutListener->handle($event);
if (null !== $logoutListener = $listeners[2]) {
$authenticationListeners[] = $logoutListener;
}
if (null !== $accessListener) {
$authenticationListeners[] = $accessListener;
}
$this->handleRequest($event, $authenticationListeners);
}
public function onKernelFinishRequest(FinishRequestEvent $event)

View File

@ -83,7 +83,7 @@ class FirewallTest extends TestCase
->getMock()
;
$event
->expects($this->once())
->expects($this->at(0))
->method('hasResponse')
->will($this->returnValue(true))
;

View File

@ -499,11 +499,6 @@ class Parser
private function getNextEmbedBlock(int $indentation = null, bool $inSequence = false): ?string
{
$oldLineIndentation = $this->getCurrentLineIndentation();
$blockScalarIndentations = array();
if ($this->isBlockScalarHeader()) {
$blockScalarIndentations[] = $oldLineIndentation;
}
if (!$this->moveToNextLine()) {
return null;
@ -562,30 +557,9 @@ class Parser
$isItUnindentedCollection = $this->isStringUnIndentedCollectionItem();
if (empty($blockScalarIndentations) && $this->isBlockScalarHeader()) {
$blockScalarIndentations[] = $this->getCurrentLineIndentation();
}
$previousLineIndentation = $this->getCurrentLineIndentation();
while ($this->moveToNextLine()) {
$indent = $this->getCurrentLineIndentation();
// terminate all block scalars that are more indented than the current line
if (!empty($blockScalarIndentations) && $indent < $previousLineIndentation && '' !== trim($this->currentLine)) {
foreach ($blockScalarIndentations as $key => $blockScalarIndentation) {
if ($blockScalarIndentation >= $indent) {
unset($blockScalarIndentations[$key]);
}
}
}
if (empty($blockScalarIndentations) && !$this->isCurrentLineComment() && $this->isBlockScalarHeader()) {
$blockScalarIndentations[] = $indent;
}
$previousLineIndentation = $indent;
if ($isItUnindentedCollection && !$this->isCurrentLineEmpty() && !$this->isStringUnIndentedCollectionItem() && $newIndent === $indent) {
$this->moveToPreviousLine();
break;
@ -1004,16 +978,6 @@ class Parser
return '-' === rtrim($this->currentLine) || 0 === strpos($this->currentLine, '- ');
}
/**
* Tests whether or not the current line is the header of a block scalar.
*
* @return bool
*/
private function isBlockScalarHeader(): bool
{
return '' !== $this->currentLine && (bool) self::preg_match('~'.self::BLOCK_SCALAR_HEADER_PATTERN.'$~', $this->currentLine);
}
/**
* A local wrapper for `preg_match` which will throw a ParseException if there
* is an internal error in the PCRE engine.