From 34595c02bacb9ff869e1614817196d037a422fed Mon Sep 17 00:00:00 2001 From: mrgoldy Date: Thu, 27 Feb 2020 15:51:12 +0100 Subject: [PATCH 1/2] [ticket/16378] Update deprecated console exception_subscriber event PHPBB3-16378 --- phpBB/phpbb/console/exception_subscriber.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/phpBB/phpbb/console/exception_subscriber.php b/phpBB/phpbb/console/exception_subscriber.php index b240993203..b9fb9ac654 100644 --- a/phpBB/phpbb/console/exception_subscriber.php +++ b/phpBB/phpbb/console/exception_subscriber.php @@ -15,7 +15,7 @@ namespace phpbb\console; use phpbb\exception\exception_interface; use Symfony\Component\Console\ConsoleEvents; -use Symfony\Component\Console\Event\ConsoleExceptionEvent; +use Symfony\Component\Console\Event\ConsoleErrorEvent; use Symfony\Component\EventDispatcher\EventSubscriberInterface; class exception_subscriber implements EventSubscriberInterface @@ -39,27 +39,27 @@ class exception_subscriber implements EventSubscriberInterface * This listener is run when the ConsoleEvents::EXCEPTION event is triggered. * It translate the exception message. If din debug mode the original exception is embedded. * - * @param ConsoleExceptionEvent $event + * @param ConsoleErrorEvent $event */ - public function on_exception(ConsoleExceptionEvent $event) + public function on_exception(ConsoleErrorEvent $event) { - $original_exception = $event->getException(); + $original_exception = $event->getError(); if ($original_exception instanceof exception_interface) { - $parameters = array_merge(array($original_exception->getMessage()), $original_exception->get_parameters()); - $message = call_user_func_array(array($this->language, 'lang'), $parameters); + $parameters = array_merge([$original_exception->getMessage()], $original_exception->get_parameters()); + $message = call_user_func_array([$this->language, 'lang'], $parameters); $exception = new \RuntimeException($message , $original_exception->getCode(), $original_exception); - $event->setException($exception); + $event->setError($exception); } } static public function getSubscribedEvents() { - return array( - ConsoleEvents::EXCEPTION => 'on_exception', - ); + return [ + ConsoleEvents::ERROR => 'on_exception', + ]; } } From ba04bc9d227b83fd4e7bd0f552eaa6efee8fbcc0 Mon Sep 17 00:00:00 2001 From: mrgoldy Date: Fri, 28 Feb 2020 13:41:06 +0100 Subject: [PATCH 2/2] [ticket/16378] Update function name to on_error PHPBB3-16378 --- phpBB/phpbb/console/exception_subscriber.php | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/phpBB/phpbb/console/exception_subscriber.php b/phpBB/phpbb/console/exception_subscriber.php index b9fb9ac654..15b317f349 100644 --- a/phpBB/phpbb/console/exception_subscriber.php +++ b/phpBB/phpbb/console/exception_subscriber.php @@ -20,15 +20,13 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface; class exception_subscriber implements EventSubscriberInterface { - /** - * @var \phpbb\language\language - */ + /** @var \phpbb\language\language */ protected $language; /** - * Construct method + * Constructor. * - * @param \phpbb\language\language $language Language object + * @param \phpbb\language\language $language Language object */ public function __construct(\phpbb\language\language $language) { @@ -36,12 +34,12 @@ class exception_subscriber implements EventSubscriberInterface } /** - * This listener is run when the ConsoleEvents::EXCEPTION event is triggered. - * It translate the exception message. If din debug mode the original exception is embedded. + * This listener is run when the ConsoleEvents::ERROR event is triggered. + * It translate the error message. If in debug mode the original exception is embedded. * * @param ConsoleErrorEvent $event */ - public function on_exception(ConsoleErrorEvent $event) + public function on_error(ConsoleErrorEvent $event) { $original_exception = $event->getError(); @@ -59,7 +57,7 @@ class exception_subscriber implements EventSubscriberInterface static public function getSubscribedEvents() { return [ - ConsoleEvents::ERROR => 'on_exception', + ConsoleEvents::ERROR => 'on_error', ]; } }