Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"symfony/config": "^3.4 || ^4.0 || ^5.0",
"symfony/console": "^3.4 || ^4.0 || ^5.0",
"symfony/css-selector": "^3.4 || ^4.0 || ^5.0",
"symfony/debug": "^3.4 || ^4.0 || ^5.0",
"symfony/debug": "^3.4 || ^4.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

debug:^5.0 does not exist.

"symfony/dependency-injection": "^3.4 || ^4.0 || ^5.0",
"symfony/doctrine-bridge": "^3.4 || ^4.0 || ^5.0",
"symfony/dom-crawler": "^3.4 || ^4.0 || ^5.0",
Expand Down
9 changes: 4 additions & 5 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,10 @@ parameters:

# Expected, due to forward compatibility
-
message: '#Class Symfony\\Component\\ErrorRenderer\\ErrorRenderer not found\.#'
message: '#Class Symfony\\Component\\ErrorHandler\\ErrorRenderer\\ErrorRendererInterface not found\.#'
path: %currentWorkingDirectory%/tests/Fixtures/app/AppKernel.php
-
message: '#Parameter \$exception of method ApiPlatform\\Core\\Action\\ExceptionAction::__invoke\(\) has invalid typehint type Symfony\\Component\\ErrorRenderer\\Exception\\FlattenException\.#'
path: %currentWorkingDirectory%/src/Action/ExceptionAction.php
-
message: '#Call to method get(Class|Headers|StatusCode)\(\) on an unknown class Symfony\\Component\\ErrorRenderer\\Exception\\FlattenException\.#'
message: '#Parameter \$exception of method ApiPlatform\\Core\\Action\\ExceptionAction::__invoke\(\) has invalid typehint type Symfony\\Component\\ErrorHandler\\Exception\\FlattenException\.#'
path: %currentWorkingDirectory%/src/Action/ExceptionAction.php
- '#Call to method get(Class|Headers|StatusCode)\(\) on an unknown class Symfony\\Component\\ErrorHandler\\Exception\\FlattenException\.#'
- '#Class Symfony\\Component\\ErrorHandler\\Exception\\FlattenException not found\.#'
2 changes: 1 addition & 1 deletion src/Action/ExceptionAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

use ApiPlatform\Core\Util\ErrorFormatGuesser;
use Symfony\Component\Debug\Exception\FlattenException as LegacyFlattenException;
use Symfony\Component\ErrorRenderer\Exception\FlattenException;
use Symfony\Component\ErrorHandler\Exception\FlattenException;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Serializer\SerializerInterface;
Expand Down
7 changes: 4 additions & 3 deletions src/Hydra/Serializer/ErrorNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@

use ApiPlatform\Core\Api\UrlGeneratorInterface;
use ApiPlatform\Core\Problem\Serializer\ErrorNormalizerTrait;
use Symfony\Component\Debug\Exception\FlattenException;
use Symfony\Component\Debug\Exception\FlattenException as LegacyFlattenException;
use Symfony\Component\ErrorHandler\Exception\FlattenException;
use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;

/**
* Converts {@see \Exception} or {@see \Symfony\Component\Debug\Exception\FlattenException} to a Hydra error representation.
* Converts {@see \Exception} or {@see FlattenException} or {@see LegacyFlattenException} to a Hydra error representation.
*
* @author Kévin Dunglas <[email protected]>
* @author Samuel ROZE <[email protected]>
Expand Down Expand Up @@ -67,7 +68,7 @@ public function normalize($object, $format = null, array $context = [])
*/
public function supportsNormalization($data, $format = null)
{
return self::FORMAT === $format && ($data instanceof \Exception || $data instanceof FlattenException);
return self::FORMAT === $format && ($data instanceof \Exception || $data instanceof FlattenException || $data instanceof LegacyFlattenException);
}

/**
Expand Down
7 changes: 4 additions & 3 deletions src/JsonApi/Serializer/ErrorNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@
namespace ApiPlatform\Core\JsonApi\Serializer;

use ApiPlatform\Core\Problem\Serializer\ErrorNormalizerTrait;
use Symfony\Component\Debug\Exception\FlattenException;
use Symfony\Component\Debug\Exception\FlattenException as LegacyFlattenException;
use Symfony\Component\ErrorHandler\Exception\FlattenException;
use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;

/**
* Converts {@see \Exception} or {@see \Symfony\Component\Debug\Exception\FlattenException} to a JSON API error representation.
* Converts {@see \Exception} or {@see FlattenException} or {@see LegacyFlattenException} to a JSON API error representation.
*
* @author Héctor Hurtarte <[email protected]>
*/
Expand Down Expand Up @@ -60,7 +61,7 @@ public function normalize($object, $format = null, array $context = [])
*/
public function supportsNormalization($data, $format = null)
{
return self::FORMAT === $format && ($data instanceof \Exception || $data instanceof FlattenException);
return self::FORMAT === $format && ($data instanceof \Exception || $data instanceof FlattenException || $data instanceof LegacyFlattenException);
}

/**
Expand Down
5 changes: 3 additions & 2 deletions src/Problem/Serializer/ErrorNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@

namespace ApiPlatform\Core\Problem\Serializer;

use Symfony\Component\Debug\Exception\FlattenException;
use Symfony\Component\Debug\Exception\FlattenException as LegacyFlattenException;
use Symfony\Component\ErrorHandler\Exception\FlattenException;
use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;

Expand Down Expand Up @@ -67,7 +68,7 @@ public function normalize($object, $format = null, array $context = [])
*/
public function supportsNormalization($data, $format = null)
{
return self::FORMAT === $format && ($data instanceof \Exception || $data instanceof FlattenException);
return self::FORMAT === $format && ($data instanceof \Exception || $data instanceof FlattenException || $data instanceof LegacyFlattenException);
}

/**
Expand Down
5 changes: 3 additions & 2 deletions src/Problem/Serializer/ErrorNormalizerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@

namespace ApiPlatform\Core\Problem\Serializer;

use Symfony\Component\Debug\Exception\FlattenException;
use Symfony\Component\Debug\Exception\FlattenException as LegacyFlattenException;
use Symfony\Component\ErrorHandler\Exception\FlattenException;
use Symfony\Component\HttpFoundation\Response;

trait ErrorNormalizerTrait
Expand All @@ -26,7 +27,7 @@ private function getErrorMessage($object, array $context, bool $debug = false):
return $message;
}

if ($object instanceof FlattenException) {
if ($object instanceof FlattenException || $object instanceof LegacyFlattenException) {
$statusCode = $context['statusCode'] ?? $object->getStatusCode();
if ($statusCode >= 500 && $statusCode < 600) {
$message = Response::$statusTexts[$statusCode];
Expand Down
8 changes: 4 additions & 4 deletions tests/Fixtures/app/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
use Symfony\Bundle\WebProfilerBundle\WebProfilerBundle;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\ErrorRenderer\ErrorRenderer;
use Symfony\Component\ErrorHandler\ErrorRenderer\ErrorRendererInterface;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Routing\RouteCollectionBuilder;
use Symfony\Component\Security\Core\Encoder\SodiumPasswordEncoder;
use Symfony\Component\Security\Core\Encoder\NativePasswordEncoder;
use Symfony\Component\Security\Core\User\UserInterface;

/**
Expand Down Expand Up @@ -98,7 +98,7 @@ protected function configureContainer(ContainerBuilder $c, LoaderInterface $load

$loader->load(__DIR__."/config/config_{$this->getEnvironment()}.yml");

$alg = class_exists(SodiumPasswordEncoder::class) && SodiumPasswordEncoder::isSupported() ? 'auto' : 'bcrypt';
$alg = class_exists(NativePasswordEncoder::class) ? 'auto' : 'bcrypt';
$securityConfig = [
'encoders' => [
User::class => $alg,
Expand Down Expand Up @@ -155,7 +155,7 @@ protected function configureContainer(ContainerBuilder $c, LoaderInterface $load
}

$twigConfig = ['strict_variables' => '%kernel.debug%'];
if (class_exists(ErrorRenderer::class)) {
if (interface_exists(ErrorRendererInterface::class)) {
$twigConfig['exception_controller'] = null;
}
$c->prependExtensionConfig('twig', $twigConfig);
Expand Down