Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 73e9009

Browse files
[HttpKernel] rename ExceptionEvent to ErrorEvent and remove the ErrorException wrapper
1 parent 040d93d commit 73e9009

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+736
-181
lines changed

UPGRADE-4.4.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Console
1414
* Deprecated returning `null` from `Command::execute()`, return `0` instead
1515
* Deprecated the `Application::renderException()` and `Application::doRenderException()` methods,
1616
use `renderThrowable()` and `doRenderThrowable()` instead.
17+
* Deprecated `ConsoleErrorEvent::getError()/setError()`, use `getException()/setException()` instead
1718

1819
Debug
1920
-----
@@ -154,6 +155,12 @@ HttpKernel
154155
* Marked the `RouterDataCollector::collect()` method as `@final`.
155156
* The `DataCollectorInterface::collect()` and `Profiler::collect()` methods third parameter signature
156157
will be `\Throwable $exception = null` instead of `\Exception $exception = null` in Symfony 5.0.
158+
* Deprecated class `ExceptionEvent`, use `ErrorEvent` instead
159+
* Deprecated class `ExceptionListener`, use `ErrorListener` instead
160+
* Deprecated constant `KernelEvents::EXCEPTION`, use `KernelEvents::ERROR` instead
161+
* Deprecated event `kernel.exception`, listen to `kernel.error` instead
162+
* Deprecated method `ProfilerListener::onKernelException()`, use `onKernelError()` instead
163+
* Deprecated method `RouterListener::onKernelException()`, use `onKernelError()` instead
157164

158165
Lock
159166
----
@@ -212,6 +219,7 @@ Security
212219
* The `LdapUserProvider` class has been deprecated, use `Symfony\Component\Ldap\Security\LdapUserProvider` instead.
213220
* Implementations of `PasswordEncoderInterface` and `UserPasswordEncoderInterface` should add a new `needsRehash()` method
214221
* Deprecated returning a non-boolean value when implementing `Guard\AuthenticatorInterface::checkCredentials()`. Please explicitly return `false` to indicate invalid credentials.
222+
* Deprecated method `ExceptionListener::onKernelException()`, use `onKernelError()` instead
215223
* Deprecated passing more than one attribute to `AccessDecisionManager::decide()` and `AuthorizationChecker::isGranted()` (and indirectly the `is_granted()` Twig and ExpressionLanguage function)
216224

217225
**Before**

UPGRADE-5.0.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Console
3939
* Removed the `setVerticalBorderChar()` method in favor of the `setVerticalBorderChars()` method in `TableStyle`.
4040
* Removed the `getVerticalBorderChar()` method in favor of the `getBorderChars()` method in `TableStyle`.
4141
* Removed support for returning `null` from `Command::execute()`, return `0` instead
42+
* Removed `ConsoleErrorEvent::getError()/setError()`, use `getException()/setException()` instead
4243
* The `ProcessHelper::run()` method takes the command as an array of arguments.
4344

4445
Before:
@@ -290,6 +291,12 @@ HttpKernel
290291
* Removed `TranslatorListener` in favor of `LocaleAwareListener`
291292
* The `DebugHandlersListener` class has been made `final`
292293
* Removed `SaveSessionListener` in favor of `AbstractSessionListener`
294+
* Removed class `ExceptionEvent`, use `ErrorEvent` instead
295+
* Removed class `ExceptionListener`, use `ErrorListener` instead
296+
* Removed constant `KernelEvents::EXCEPTION`, use `KernelEvents::ERROR` instead
297+
* Removed event `kernel.exception`, listen to `kernel.error` instead
298+
* Removed method `ProfilerListener::onKernelException()`, use `onKernelError()` instead
299+
* Removed method `RouterListener::onKernelException()`, use `onKernelError()` instead
293300
* Added new Bundle directory convention consistent with standard skeletons:
294301

295302
```
@@ -470,6 +477,7 @@ Security
470477
* Classes implementing the `TokenInterface` must implement the two new methods
471478
`__serialize` and `__unserialize`
472479
* Implementations of `Guard\AuthenticatorInterface::checkCredentials()` must return a boolean value now. Please explicitly return `false` to indicate invalid credentials.
480+
* Removed method `ExceptionListener::onKernelException()`, use `onKernelError()` instead
473481

474482
SecurityBundle
475483
--------------

src/Symfony/Bundle/FrameworkBundle/Console/Application.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
use Symfony\Component\Console\Output\ConsoleOutputInterface;
2020
use Symfony\Component\Console\Output\OutputInterface;
2121
use Symfony\Component\Console\Style\SymfonyStyle;
22+
use Symfony\Component\Debug\Exception\FatalThrowableError;
2223
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
23-
use Symfony\Component\ErrorHandler\Exception\ErrorException;
2424
use Symfony\Component\HttpKernel\Bundle\Bundle;
2525
use Symfony\Component\HttpKernel\Kernel;
2626
use Symfony\Component\HttpKernel\KernelInterface;
@@ -211,7 +211,7 @@ private function renderRegistrationErrors(InputInterface $input, OutputInterface
211211
$this->doRenderThrowable($error, $output);
212212
} else {
213213
if (!$error instanceof \Exception) {
214-
$error = new ErrorException($error);
214+
$error = new FatalThrowableError($error);
215215
}
216216

217217
$this->doRenderException($error, $output);

src/Symfony/Bundle/FrameworkBundle/EventListener/SuggestMissingPackageSubscriber.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ final class SuggestMissingPackageSubscriber implements EventSubscriberInterface
4646

4747
public function onConsoleError(ConsoleErrorEvent $event): void
4848
{
49-
if (!$event->getError() instanceof CommandNotFoundException) {
49+
if (!$event->getException() instanceof CommandNotFoundException) {
5050
return;
5151
}
5252

@@ -64,14 +64,14 @@ public function onConsoleError(ConsoleErrorEvent $event): void
6464
$exact = false;
6565
}
6666

67-
$error = $event->getError();
67+
$error = $event->getException();
6868

6969
if ($error->getAlternatives() && !$exact) {
7070
return;
7171
}
7272

7373
$message = sprintf("%s\n\nYou may be looking for a command provided by the \"%s\" which is currently not installed. Try running \"composer require %s\".", $error->getMessage(), $suggestion[0], $suggestion[1]);
74-
$event->setError(new CommandNotFoundException($message));
74+
$event->setException(new CommandNotFoundException($message));
7575
}
7676

7777
public static function getSubscribedEvents(): array

src/Symfony/Bundle/FrameworkBundle/Resources/config/services.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<parameter key="Symfony\Component\HttpKernel\Event\FinishRequestEvent">kernel.finish_request</parameter>
2222
<parameter key="Symfony\Component\HttpKernel\Event\RequestEvent">kernel.request</parameter>
2323
<parameter key="Symfony\Component\HttpKernel\Event\ViewEvent">kernel.view</parameter>
24+
<parameter key="Symfony\Component\HttpKernel\Event\ErrorEvent">kernel.error</parameter>
2425
<parameter key="Symfony\Component\HttpKernel\Event\ExceptionEvent">kernel.exception</parameter>
2526
<parameter key="Symfony\Component\HttpKernel\Event\TerminateEvent">kernel.terminate</parameter>
2627
<parameter key="Symfony\Component\Workflow\Event\GuardEvent">workflow.guard</parameter>

src/Symfony/Bundle/FrameworkBundle/Resources/config/web.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
<argument type="service" id="error_renderer" />
9696
</service>
9797

98-
<service id="exception_listener" class="Symfony\Component\HttpKernel\EventListener\ExceptionListener">
98+
<service id="exception_listener" class="Symfony\Component\HttpKernel\EventListener\ErrorListener">
9999
<tag name="kernel.event_subscriber" />
100100
<tag name="monolog.logger" channel="request" />
101101
<argument>%kernel.error_controller%</argument>

src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ private function createEventForSuggestingPackages(string $command, array $altern
254254
$subscriber = new SuggestMissingPackageSubscriber();
255255
$subscriber->onConsoleError($event);
256256

257-
return $event->getError()->getMessage();
257+
return $event->getException()->getMessage();
258258
}
259259

260260
private function getKernel(array $bundles, $useDispatcher = false)

src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/ConcreteMicroKernel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ protected function configureContainer(ContainerBuilder $c, LoaderInterface $load
103103
public static function getSubscribedEvents(): array
104104
{
105105
return [
106-
KernelEvents::EXCEPTION => 'onKernelException',
106+
KernelEvents::ERROR => 'onKernelException',
107107
];
108108
}
109109
}

src/Symfony/Bundle/FrameworkBundle/composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"paragonie/sodium_compat": "^1.8",
3636
"symfony/asset": "^3.4|^4.0|^5.0",
3737
"symfony/browser-kit": "^4.3|^5.0",
38-
"symfony/console": "^4.3.4|^5.0",
38+
"symfony/console": "^4.4|^5.0",
3939
"symfony/css-selector": "^3.4|^4.0|^5.0",
4040
"symfony/dom-crawler": "^4.3|^5.0",
4141
"symfony/dotenv": "^4.3.6|^5.0",
@@ -70,7 +70,7 @@
7070
"phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0",
7171
"symfony/asset": "<3.4",
7272
"symfony/browser-kit": "<4.3",
73-
"symfony/console": "<4.3",
73+
"symfony/console": "<4.4",
7474
"symfony/dotenv": "<4.3.6",
7575
"symfony/dom-crawler": "<4.3",
7676
"symfony/http-client": "<4.4",

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function previewErrorPageAction(Request $request, $code)
4343

4444
/*
4545
* This Request mimics the parameters set by
46-
* \Symfony\Component\HttpKernel\EventListener\ExceptionListener::duplicateRequest, with
46+
* \Symfony\Component\HttpKernel\EventListener\ErrorListener::duplicateRequest, with
4747
* the additional "showException" flag.
4848
*/
4949

0 commit comments

Comments
 (0)