New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ErrorController::beforeRender not called #17603
Comments
Could it be in any way related to #17599 ? |
|
Sure. For this file: // src/Controller/ErrorController.php
<?php
declare(strict_types=1);
namespace App\Controller;
use Cake\Event\EventInterface;
class ErrorController extends AppController
{
public function beforeRender(EventInterface $event)
{
\Cake\Log\Log::debug('event');
parent::beforeRender($event);
$this->viewBuilder()->setTemplatePath('Error');
$this->viewBuilder()->setClassName(\App\View\InternalView::class);
}
} With Cake 4.4.18, I enter a non existing URL in the browser, With Cake 5.0.5, I enter a non existing URL in the browser (same one as above), |
I am unable to reproduced this, |
Which files should I look into to find out more about what is going on? |
Commenting out the // Application.php
public function middleware(MiddlewareQueue $middlewareQueue): MiddlewareQueue
{
$middlewareQueue
// Catch any exceptions in the lower layers,
// and make an error page/response
// ->add(new ErrorHandlerMiddleware(Configure::read('Error')))
... // bootstrap.php, unchanged
(new ErrorTrap(Configure::read('Error')))->register();
(new ExceptionTrap(Configure::read('Error')))->register(); I'll try to reproduce this issue on a new project. |
I successfully reproduced it on a new project: composer create-project --prefer-dist cakephp/app:5.* cms
composer require cakephp/authentication // app_local.php
'debug' => false, Apply this diff Call URL http://localhost:8765/few/asd There is no |
On the reproduction repo (previous comment), commenting Authentication stuff made // AppController.php
public function initialize(): void
{
parent::initialize();
$this->loadComponent('Flash');
// $this->loadComponent('Authentication.Authentication');
} // PagesController.php
public function initialize(): void
{
parent::initialize();
// $this->Authentication->allowUnauthenticated(['display']);
} |
Since you added a
|
That's right. |
We could have the error rendering process log an error when using the application's |
When error rendering fails it can be tedious to diagnose what the problem is. Having some logging when rendering fails could help triage the problem and get to a solution quicker. Refs #17603
When error rendering fails it can be tedious to diagnose what the problem is. Having some logging when rendering fails could help triage the problem and get to a solution quicker. Refs #17603
We've improved the logging here, so closing for now. If we need further improvements we can have new issues for those topics. |
Description
We recently made the switch from Cake 4 to Cake 5. Since then, our 404 page stopped working.
How to reproduce
produces
Expected behavior
To see
event
in the logs, and to seeApp\View\InternalView
in the HTML output.CakePHP Version
5.0.5
PHP Version
8.1.25
The text was updated successfully, but these errors were encountered: