-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[TwigBridge] Improve error rendering when running tests #58456
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
32d771e
b372dd7
1ce9351
6b9fa3d
fc8cbe1
3895881
04882bd
7eaf087
a043bf7
332ee7e
aeac330
181729c
00575a5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?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. | ||
*/ | ||
|
||
namespace Symfony\Bundle\TwigBundle\DependencyInjection\Compiler; | ||
|
||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Definition; | ||
use Symfony\Component\ErrorHandler\ErrorRenderer\CliErrorRenderer; | ||
|
||
/** | ||
* @author Javier Eguiluz <javier.eguiluz@gmail.com> | ||
* @internal | ||
*/ | ||
class ErrorRendererPass implements CompilerPassInterface | ||
{ | ||
public function process(ContainerBuilder $container): void | ||
{ | ||
// in the 'test' environment, use the CLI error renderer as the default one | ||
if ($container->hasDefinition('test.client')) { | ||
$container->getDefinition('twig.error_renderer.html') | ||
->setArgument(1, new Definition(CliErrorRenderer::class)); | ||
javiereguiluz marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wouldn't this break if the error-handler component is not installed (which is not a dependency of the bundle right now) ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and maybe we need a conflict with older versions of the component to ensure we don't inject a version that does not properly report a plaintext content type (and so is subject to XSS) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the decision of which fallback error renderer is the best does not depend on the environment but on the SAPI value, as you did at the beginning. What about creating a service factory that injects the proper error renderer depending on the SAPI value? |
||
} | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.