Description
Description
With debug = true, rendering any exception that has no matching template in templates/Error/ (e.g. TypeError, ValueError, RuntimeException) writes a warning to the
cake.error log scope:
warning: MissingTemplateException - Failed to render error template `typeError` . Error: Template file `Error/type_error.php` could not be found.
The error page itself renders fine (falls back to error500), so this is only log noise, but it fires for basically every uncaught PHP error during development.
Cause
WebExceptionRenderer::_template() returns the exception-derived method name (typeError) as the template name in debug mode without checking whether such a template exists.
_outputMessage() then calls render('typeError'), catches the resulting MissingTemplateException, logs a warning and re-renders error500.
The warning was introduced in bcacc667cb ("Add logging to error rendering failures"). Logging is useful when a template that should exist is missing (e.g. a broken error500.php), but the fallback from an exception-specific template to error500 is the expected path for all non-Cake exceptions and should not be logged as a problem.
Steps to reproduce
Configure::write('debug', true);
$renderer = new \Cake\Error\Renderer\WebExceptionRenderer(new \TypeError('bad type'), new ServerRequest());
$renderer->render();
Check the cake.error log.
Expected
Either no warning when falling back from a non-existent exception-specific template to error500, or _template() should only return the exception-specific name when the template
actually exists.
Actual
A MissingTemplateException warning is logged on every TypeError / RuntimeException / etc.
CakePHP Version
5.2-5.4
PHP Version
8.3
Description
Description
With
debug = true, rendering any exception that has no matching template intemplates/Error/(e.g.TypeError,ValueError,RuntimeException) writes a warning to thecake.errorlog scope:The error page itself renders fine (falls back to
error500), so this is only log noise, but it fires for basically every uncaught PHP error during development.Cause
WebExceptionRenderer::_template()returns the exception-derived method name (typeError) as the template name in debug mode without checking whether such a template exists._outputMessage()then callsrender('typeError'), catches the resultingMissingTemplateException, logs a warning and re-renderserror500.The warning was introduced in bcacc667cb ("Add logging to error rendering failures"). Logging is useful when a template that should exist is missing (e.g. a broken
error500.php), but the fallback from an exception-specific template toerror500is the expected path for all non-Cake exceptions and should not be logged as a problem.Steps to reproduce
Check the
cake.errorlog.Expected
Either no warning when falling back from a non-existent exception-specific template to
error500, or_template()should only return the exception-specific name when the templateactually exists.
Actual
A
MissingTemplateExceptionwarning is logged on everyTypeError/RuntimeException/ etc.CakePHP Version
5.2-5.4
PHP Version
8.3