In the Template.php file there is the following line:
if (ee()->config->item('enable_template_routes') == 'y')
But the issue is if there are no routes defined, and its enabled, it’ll eventually throw an exception:
Exception: Template route not found. in /var/www/html/system/ee/legacy/libraries/Template_router.php on line 53
Call Stack
# Time Memory Function Location
1 0.0010 367224 {main}( ) .../index.php:0
2 0.0024 368536 require_once( '/var/www/html/system/ee/EllisLab/ExpressionEngine/Boot/boot.php' ) .../index.php:172
3 0.0401 482608 EllisLab\ExpressionEngine\Core\Core->run( ) .../boot.php:146
4 0.0548 572792 EllisLab\ExpressionEngine\Core\Core->runController( ) .../Core.php:109
5 0.7794 2360704 call_user_func_array:{/var/www/html/system/ee/EllisLab/ExpressionEngine/Core/Core.php:229} ( ) .../Core.php:229
6 0.7794 2361096 EE->index( ) .../Core.php:229
7 0.7794 2361096 EE_Core->generate_page( ) .../ee.php:62
8 0.8478 2592624 EE_Template->run_template_engine( ) .../Core.php:656
9 0.8479 2594352 EE_Template->fetch_and_parse( ) .../Template.php:160
10 0.8479 2594384 EE_Template->parse_template_uri( ) .../Template.php:207
11 0.8494 2594384 EE_Template_Router->match( ) .../Template.php:2184
So why not make sure there are end_points before trying to process them? I suggest changing that line to this:
if (ee()->config->item('enable_template_routes') == 'y' && !empty(ee()->template_router->end_points))
I don’t see any downside here because the exception thrown doesn’t tell the user “hey, maybe you should define some routes if you’re going to enable them”
Thoughts?
That exception should be caught as it’s in a try/catch. Is it still making it through some how?
Otherwise, in order to check the endpoints in this conditional, the downside I see is we have to load the template router lib and make a DB call even if template routes aren’t enabled. The processing going on in match()
is trivial if there are no end-points, so I don’t really mind if the code makes it to match()
. If anything, throwing an Exception seems a little dramatic.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.