Skip to content

Commit 928363c

Browse files
committed
Keeping backward compatibility with legacy FlattenException usage
1 parent 62216ea commit 928363c

File tree

13 files changed

+113
-26
lines changed

13 files changed

+113
-26
lines changed

UPGRADE-4.4.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,33 @@ HttpKernel
155155
current directory or with a glob pattern. The fallback directories have never been advocated
156156
so you likely do not use those in any app based on the SF Standard or Flex edition.
157157
* Getting the container from a non-booted kernel is deprecated
158+
* Deprecated passing the `exception` attribute (instance of `Symfony\Component\Debug\Exception\FlattenException`)
159+
to the configured controller of the `ExceptionListener`, use the `e` attribute
160+
(instance of `Symfony\Component\ErrorRenderer\Exception\FlattenException`) instead
161+
162+
before:
163+
```php
164+
use Symfony\Component\Debug\Exception\FlattenException;
165+
166+
class ExceptionController
167+
{
168+
public function __invoke(FlattenException $exception)
169+
{
170+
}
171+
}
172+
```
173+
174+
after:
175+
```php
176+
use Symfony\Component\ErrorRenderer\Exception\FlattenException;
177+
178+
class ExceptionController
179+
{
180+
public function __invoke(FlattenException $e)
181+
{
182+
}
183+
}
184+
```
158185

159186
Lock
160187
----

UPGRADE-5.0.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,33 @@ HttpKernel
341341
* Removed the second and third argument of `FileLocator::__construct`
342342
* Removed loading resources from `%kernel.root_dir%/Resources` and `%kernel.root_dir%` as
343343
fallback directories.
344+
* Removed passing the `exception` attribute (instance of `Symfony\Component\Debug\Exception\FlattenException`)
345+
to the configured controller of the `ExceptionListener`, use the `e` attribute
346+
(instance of `Symfony\Component\ErrorRenderer\Exception\FlattenException`) instead
347+
348+
before:
349+
```php
350+
use Symfony\Component\Debug\Exception\FlattenException;
351+
352+
class ExceptionController
353+
{
354+
public function __invoke(FlattenException $exception)
355+
{
356+
}
357+
}
358+
```
359+
360+
after:
361+
```php
362+
use Symfony\Component\ErrorRenderer\Exception\FlattenException;
363+
364+
class ExceptionController
365+
{
366+
public function __invoke(FlattenException $e)
367+
{
368+
}
369+
}
370+
```
344371

345372
Intl
346373
----

src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Bundle\TwigBundle\Controller;
1313

14-
use Symfony\Component\ErrorRenderer\Exception\FlattenException;
14+
use Symfony\Component\Debug\Exception\FlattenException;
1515
use Symfony\Component\HttpFoundation\Request;
1616
use Symfony\Component\HttpFoundation\Response;
1717
use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;

src/Symfony/Bundle/TwigBundle/Controller/PreviewErrorController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Bundle\TwigBundle\Controller;
1313

14-
use Symfony\Component\ErrorRenderer\Exception\FlattenException;
14+
use Symfony\Component\Debug\Exception\FlattenException;
1515
use Symfony\Component\HttpFoundation\Request;
1616
use Symfony\Component\HttpKernel\HttpKernelInterface;
1717

src/Symfony/Bundle/TwigBundle/Tests/Controller/ExceptionControllerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
use Symfony\Bundle\TwigBundle\Controller\ExceptionController;
1515
use Symfony\Bundle\TwigBundle\Tests\TestCase;
16-
use Symfony\Component\ErrorRenderer\Exception\FlattenException;
16+
use Symfony\Component\Debug\Exception\FlattenException;
1717
use Symfony\Component\HttpFoundation\Request;
1818
use Twig\Environment;
1919
use Twig\Loader\ArrayLoader;

src/Symfony/Bundle/TwigBundle/Tests/Controller/PreviewErrorControllerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
use Symfony\Bundle\TwigBundle\Controller\PreviewErrorController;
1515
use Symfony\Bundle\TwigBundle\Tests\TestCase;
16-
use Symfony\Component\ErrorRenderer\Exception\FlattenException;
16+
use Symfony\Component\Debug\Exception\FlattenException;
1717
use Symfony\Component\HttpFoundation\Request;
1818
use Symfony\Component\HttpFoundation\Response;
1919
use Symfony\Component\HttpKernel\HttpKernelInterface;

src/Symfony/Component/ErrorRenderer/Exception/FlattenException.php

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
* Basically, this class removes all objects from the trace.
2323
*
2424
* @author Fabien Potencier <fabien@symfony.com>
25+
*
26+
* @internal
2527
*/
2628
class FlattenException
2729
{
@@ -37,6 +39,11 @@ class FlattenException
3739
private $file;
3840
private $line;
3941

42+
public static function create(\Exception $exception, int $statusCode = null, array $headers = []): self
43+
{
44+
return static::createFromThrowable($exception, $statusCode, $headers);
45+
}
46+
4047
public static function createFromThrowable(\Throwable $exception, int $statusCode = null, array $headers = []): self
4148
{
4249
$e = new static();
@@ -374,18 +381,3 @@ public function getAsString()
374381
return rtrim($message);
375382
}
376383
}
377-
378-
namespace Symfony\Component\Debug\Exception;
379-
380-
if (!class_exists(FlattenException::class, false)) {
381-
class_alias(\Symfony\Component\ErrorRenderer\Exception\FlattenException::class, FlattenException::class);
382-
}
383-
384-
if (false) {
385-
/**
386-
* @deprecated since Symfony 4.4, use Symfony\Component\ErrorRenderer\Exception\FlattenException instead.
387-
*/
388-
class FlattenException extends \Symfony\Component\ErrorRenderer\Exception\FlattenException
389-
{
390-
}
391-
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Debug\Exception;
13+
14+
if (!class_exists(FlattenException::class, false)) {
15+
class_alias(\Symfony\Component\ErrorRenderer\Exception\FlattenException::class, FlattenException::class);
16+
}
17+
18+
if (false) {
19+
/**
20+
* @deprecated since Symfony 4.4, use Symfony\Component\ErrorRenderer\Exception\FlattenException instead.
21+
*/
22+
class FlattenException extends \Symfony\Component\ErrorRenderer\Exception\FlattenException
23+
{
24+
}
25+
}

src/Symfony/Component/ErrorRenderer/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
},
3434
"autoload": {
3535
"psr-4": { "Symfony\\Component\\ErrorRenderer\\": "" },
36+
"classmap": [ "Resources/stubs/Exception/FlattenException.php" ],
3637
"exclude-from-classmap": [
3738
"/Tests/"
3839
]

src/Symfony/Component/HttpKernel/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ CHANGELOG
1515
* Marked all dispatched event classes as `@final`
1616
* Added `ErrorController` to enable the preview and error rendering mechanism
1717
* Getting the container from a non-booted kernel is deprecated.
18+
* Deprecated passing the `exception` attribute (instance of `Symfony\Component\Debug\Exception\FlattenException`)
19+
to the configured controller of the `ExceptionListener`
1820

1921
4.3.0
2022
-----

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy