diff --git a/phpBB/cron.php b/phpBB/cron.php index c99b772487..b74796fb78 100644 --- a/phpBB/cron.php +++ b/phpBB/cron.php @@ -12,6 +12,9 @@ */ use Symfony\Component\HttpFoundation\RedirectResponse; +use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\Routing\Exception\ExceptionInterface; +use Symfony\Component\Routing\Exception\RouteNotFoundException; /** */ @@ -30,8 +33,38 @@ $get_params_array = $request->get_super_global(\phpbb\request\request_interface: /** @var \phpbb\controller\helper $controller_helper */ $controller_helper = $phpbb_container->get('controller.helper'); -$response = new RedirectResponse( - $controller_helper->route('phpbb_cron_run', $get_params_array, false), - 301 +$cron_route = 'phpbb_cron_run'; + +try +{ + $response = new RedirectResponse( + $controller_helper->route($cron_route, $get_params_array, false), + Response::HTTP_MOVED_PERMANENTLY + ); + $response->send(); +} +catch (RouteNotFoundException $exception) +{ + $error = 'ROUTE_NOT_FOUND'; + $error_parameters = $cron_route; + $error_code = Response::HTTP_NOT_FOUND; +} +catch (ExceptionInterface $exception) +{ + $error = 'ROUTE_INVALID_MISSING_PARAMS'; + $error_parameters = $cron_route; + $error_code = Response::HTTP_BAD_REQUEST; +} +catch (Throwable $exception) +{ + $error = $exception->getMessage(); + $error_parameters = []; + $error_code = Response::HTTP_INTERNAL_SERVER_ERROR; +} + +$language = $phpbb_container->get('language'); +$response = new Response( + $language->lang($error, $error_parameters), + $error_code ); $response->send(); diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index 9eab230ad4..f112a09e8d 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -678,6 +678,10 @@ $lang = array_merge($lang, array( 'RETURN_TOPIC' => '%sReturn to the topic last visited%s', 'RETURN_TO' => 'Return to “%s”', 'RETURN_TO_INDEX' => 'Return to Board Index', + + 'ROUTE_NOT_FOUND' => 'The requested route “%s” could not be found.', + 'ROUTE_INVALID_MISSING_PARAMS' => 'Invalid or missing parameters passed for route “%s”.', + 'FEED' => 'Feed', 'FEED_NEWS' => 'News', 'FEED_TOPICS_ACTIVE' => 'Active Topics',