Skip to content

Commit

Permalink
Fixing fatal error caused by Debugger not being loaded when viewing t…
Browse files Browse the repository at this point in the history
…he default home page.
  • Loading branch information
markstory committed Dec 27, 2010
1 parent be96338 commit 3d966be
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions cake/console/templates/default/views/home.ctp
Expand Up @@ -2,6 +2,7 @@
$output = "<h2>Sweet, \"" . Inflector::humanize($app) . "\" got Baked by CakePHP!</h2>\n";
$output .="
<?php
App::import('Core', 'Debugger');
if (Configure::read() > 0):
Debugger::checkSecurityKeys();
endif;
Expand Down
1 change: 1 addition & 0 deletions cake/libs/view/pages/home.ctp
Expand Up @@ -18,6 +18,7 @@
if (Configure::read() == 0):
throw new NotFoundException();
endif;
App::import('Core', 'Debugger');
?>
<h2><?php echo __('Release Notes for CakePHP %s.', Configure::version()); ?></h2>
<a href="http://cakephp.org/changelogs/1.3.6"><?php __('Read the changelog'); ?> </a>
Expand Down

2 comments on commit 3d966be

@AD7six
Copy link
Member

@AD7six AD7six commented on 3d966be Dec 27, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I'd suggest that's the wrong fix, there isn't really a circumstance whereby you'd want to show the contents of that file with debug == 0.

IME it's actually quite common if you don't create an app/views/pages/home.ctp file and either through lack of foresight or error (with routes config) expose the default home page on your live app.

Therefore, I'd propose the following as a more appropriate fix:

if (!Configure::read()) {
    throw new NotFoundException();
    return; // no contents, just the layout. 
}

I also encourage other devs to create an appropriate or blank file in views/pages/home.ctp to prevent the default view from being reachable.

@markstory
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well the fix was to fix fatal errors because Debugger hadn't been loaded. But I see your point about both the baked home page, and the built-in one throwing exceptions.

Please sign in to comment.