8000 Merge branch '2.7' · symfony/symfony@5e017e5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5e017e5

Browse files
committed
Merge branch '2.7'
* 2.7: [TwigBundle] always load the exception listener if the templating.engines is not present [TwigBundle] removed the Container dependency on ActionsExtension [Filesystem] keep exec perms when copying fixed typo Fixed minor typo - override [Filesystem] enforce umask while testing [TwigBridge] moved fixtures into their own directory [2.3] Fix lowest deps [TwigBundle] added missing @deprecated tags Use $this->iniSet() in tests Conflicts: src/Symfony/Bundle/TwigBundle/composer.json
2 parents 9c6d315 + 60a97ec commit 5e017e5

File tree

21 files changed

+50
-42
lines changed

21 files changed

+50
-42
lines changed

src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ protected function setUp()
4242

4343
$loader = new StubFilesystemLoader(array(
4444
__DIR__.'/../../Resources/views/Form',
45-
__DIR__,
45+
__DIR__.'/Fixtures/templates/form',
4646
));
4747

4848
$environment = new \Twig_Environment($loader, array('strict_variables' => true));

src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ protected function setUp()
4141

4242
$loader = new StubFilesystemLoader(array(
4343
__DIR__.'/../../Resources/views/Form',
44-
__DIR__,
44+
__DIR__.'/Fixtures/templates/form',
4545
));
4646

4747
$environment = new \Twig_Environment($loader, array('strict_variables' => true));

src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExceptionListenerPass.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@ public function process(ContainerBuilder $container)
2828
}
2929

3030
// register the exception controller only if Twig is enabled
31-
$engines = $container->getParameter('templating.engines');
32-
if (!in_array('twig', $engines)) {
33-
$container->removeDefinition('twig.exception_listener');
31+
if ($container->hasParameter('templating.engines')) {
32+
$engines = $container->getParameter('templating.engines');
33+
if (!in_array('twig', $engines)) {
34+
$container->removeDefinition('twig.exception_listener');
35+
}
3436
}
3537
}
3638
}

src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ public function process(ContainerBuilder $container)
2727
$container->getDefinition('twig.loader.filesystem')->addMethodCall('addPath', array(dirname(dirname($reflClass->getFileName())).'/Resources/views/Form'));
2828
}
2929

30+
if ($container->has('fragment.handler')) {
31+
$container->getDefinition('twig.extension.actions')->addTag('twig.extension');
32+
}
33+
3034
if ($container->has('translator')) {
3135
$container->getDefinition('twig.extension.trans')->addTag('twig.extension');
3236
}

src/Symfony/Bundle/TwigBundle/Extension/ActionsExtension.php

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
namespace Symfony\Bundle\TwigBundle\Extension;
1313

1414
use Symfony\Bundle\TwigBundle\TokenParser\RenderTokenParser;
15-
use Symfony\Bundle\FrameworkBundle\Templating\Helper\ActionsHelper;
1615
use Symfony\Component\DependencyInjection\ContainerInterface;
16+
use Symfony\Component\HttpKernel\Fragment\FragmentHandler;
1717

1818
/**
1919
* Twig extension for Symfony actions helper.
@@ -24,16 +24,26 @@
2424
*/
2525
class ActionsExtension extends \Twig_Extension
2626
{
27-
private $container;
27+
private $handler;
2828

2929
/**
30-
* Constructor.
30+
* @param FragmentHandler|ContainerInterface $handler
3131
*
32-
* @param ContainerInterface $container The service container
32+
* @deprecated Passing a ContainerInterface as a first argument is deprecated as of 2.7 and will be removed in 3.0.
3333
*/
34-
public function __construct(ContainerInterface $container)
34+
public function __construct($handler)
3535
{
36-
$this->container = $container;
36+
if ($handler instanceof FragmentHandler) {
37+
$this->handler = $handler;
38+
} elseif ($handler instanceof ContainerInterface) {
39+
trigger_error(sprintf('The ability to pass a ContainerInterface instance as a first argument to %s was deprecated in 2.7 and will be removed in 3.0. Please, pass a FragmentHandler instance instead.', __METHOD__), E_USER_DEPRECATED);
40+
41+
$this->handler = $handler->get('fragment.handler');
42+
} else {
43+
throw new \BadFunctionCallException(sprintf('%s takes a FragmentHandler or a ContainerInterface object as its first argument.', __METHOD__));
44+
}
45+
46+
$this->handler = $handler;
3747
}
3848

3949
/**
@@ -42,11 +52,14 @@ public function __construct(ContainerInterface $container)
4252
* @param string $uri A URI
4353
* @param array $options An array of options
4454
*
45-
* @see ActionsHelper::render()
55+
* @see FragmentHandler::render()
4656
*/
4757
public function renderUri($uri, array $options = array())
4858
{
49-
return $this->container->get('templating.helper.actions')->render($uri, $options);
59+
$strategy = isset($options['strategy']) ? $options['strategy'] : 'inline';
60+
unset($options['strategy']);
61+
62+
return $this->handler->render($uri, $strategy, $options);
5063
}
5164

5265
/**

src/Symfony/Bundle/TwigBundle/Node/RenderNode.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* Represents a render node.
1616
*
1717
* @author Fabien Potencier <fabien@symfony.com>
18+
*
19+
* @deprecated since version 2.2, to be removed in 3.0.
1820
*/
1921
class RenderNode extends \Twig_Node
2022
{

src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@
7171
</service>
7272

7373
<service id="twig.extension.actions" class="%twig.extension.actions.class%" public="false">
74-
<tag name="twig.extension" />
75-
<argument type="service" id="service_container" />
74+
<argument type="service" id="fragment.handler" />
7675
</service>
7776

7877
<service id="twig.extension.code" class="%twig.extension.code.class%" public="false">

src/Symfony/Bundle/TwigBundle/TokenParser/RenderTokenParser.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
* Token Parser for the render tag.
1818
*
1919
* @author Fabien Potencier <fabien@symfony.com>
20+
*
21+
* @deprecated since version 2.2, to be removed in 3.0.
2022
*/
2123
class RenderTokenParser extends \Twig_TokenParser
2224
{

src/Symfony/Component/Debug/Tests/DebugClassLoaderTest.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,14 @@ public function testIdempotence()
6262
public function testUnsilencing()
6363
{
6464
ob_start();
65-
$bak = array(
66-
ini_set('log_errors', 0),
67-
ini_set('display_errors', 1),
68-
);
65+
66+
$this->iniSet('log_errors', 0);
67+
$this->iniSet('display_errors', 1);
6968

7069
// See below: this will fail with parse error
7170
// but this should not be @-silenced.
7271
@class_exists(__NAMESPACE__.'\TestingUnsilencing', true);
7372

74-
ini_set('log_errors', $bak[0]);
75-
ini_set('display_errors', $bak[1]);
7673
$output = ob_get_clean();
7774

7875
$this->assertStringMatchesFormat('%aParse error%a', $output);

src/Symfony/Component/DependencyInjection/ExpressionLanguage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class ExpressionLanguage extends BaseExpressionLanguage
2525
{
2626
public function __construct(ParserCacheInterface $cache = null, array $providers = array())
2727
{
28-
// prepend the default provider to let users overide it easily
28+
// prepend the default provider to let users override it easily
2929
array_unshift($providers, new ExpressionLanguageProvider());
3030

3131
parent::__construct($cache, $providers);

src/Symfony/Component/Filesystem/Filesystem.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,8 @@ public function copy($originFile, $targetFile, $override = false)
6969
throw new IOException(sprintf('Failed to copy "%s" to "%s".', $originFile, $targetFile), 0, null, $originFile);
7070
}
7171

72-
if (is_executable($originFile)) {
73-
// User Executable | Group Executable | Other Executable
74-
chmod($targetFile, fileperms($targetFile) | 0x0040 | 0x0008 | 0x0001);
75-
}
72+
// Like `cp`, preserve executable permission bits
73+
@chmod($targetFile, fileperms($targetFile) | (fileperms($originFile) & 0111));
7674

7775
if (stream_is_local($originFile) && $bytesCopied !== filesize($originFile)) {
7876
throw new IOException(sprintf('Failed to copy the whole content of "%s" to "%s %g bytes copied".', $originFile, $targetFile, $bytesCopied), 0, null, $originFile);

src/Symfony/Component/Filesystem/Tests/FilesystemTest.php

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,23 +1002,10 @@ public function testCopyShouldKeepExecutionPermission()
10021002
$targetFilePath = $this->workspace.DIRECTORY_SEPARATOR.'copy_target_file';
10031003

10041004
file_put_contents($sourceFilePath, 'SOURCE FILE');
1005-
chmod($sourceFilePath, 0755);
1005+
chmod($sourceFilePath, 0745);
10061006

10071007
$this->filesystem->copy($sourceFilePath, $targetFilePath);
10081008

1009-
$this->assertFilePermissions(755, $targetFilePath);
1010-
}
1011-
1012-
public function testCopyShouldNotKeepWritePermissionOtherThanCurrentUser()
1013-
{
1014-
$sourceFilePath = $this->workspace.DIRECTORY_SEPARATOR.'copy_source_file';
1015-
$targetFilePath = $this->workspace.DIRECTORY_SEPARATOR.'copy_target_file';
1016-
1017-
file_put_contents($sourceFilePath, 'SOURCE FILE');
1018-
chmod($sourceFilePath, 0777);
1019-
1020-
$this->filesystem->copy($sourceFilePath, $targetFilePath);
1021-
1022-
$this->assertFilePermissions(755, $targetFilePath);
1009+
$this->assertFilePermissions(767, $targetFilePath);
10231010
}
10241011
}

src/Symfony/Component/Filesystem/Tests/FilesystemTestCase.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
class FilesystemTestCase extends \PHPUnit_Framework_TestCase
1515
{
16+
private $umask;
17+
1618
/**
1719
* @var string $workspace
1820
*/
@@ -37,6 +39,7 @@ public static function setUpBeforeClass()
3739

3840
public function setUp()
3941
{
42+
$this->umask = umask(0);
4043
$this->workspace = rtrim(sys_get_temp_dir(), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.time().rand(0, 1000);
4144
mkdir($this->workspace, 0777, true);
4245
$this->workspace = realpath($this->workspace);
@@ -45,6 +48,7 @@ public function setUp()
4548
public function tearDown()
4649
{
4750
$this->clean($this->workspace);
51+
umask($this->umask);
4852
}
4953

5054
/**

src/Symfony/Component/Security/Core/Authorization/ExpressionLanguage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class ExpressionLanguage extends BaseExpressionLanguage
2525
{
2626
public function __construct(ParserCacheInterface $cache = null, array $providers = array())
2727
{
28-
// prepend the default provider to let users overide it easily
28+
// prepend the default provider to let users override it easily
2929
array_unshift($providers, new ExpressionLanguageProvider());
3030

3131
parent::__construct($cache, $providers);

0 commit comments

Comments
 (0)
0