Skip to content

Commit

Permalink
Only allow xdebug to handle exceptions when request comes through ind…
Browse files Browse the repository at this point in the history
…ex.php

- Since the Bootstrap::run method is called from files like get.php and
  static.php, it is important that exceptions result in 404 headers,
  even when in developer mode.
  • Loading branch information
erikhansen committed Jan 7, 2016
1 parent 535758e commit 4e7be01
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);
/** @var \Magento\Framework\App\Http $app */
$app = $bootstrap->createApplication('Magento\Framework\App\Http');
$bootstrap->run($app);
$bootstrap->run($app, false);
10 changes: 8 additions & 2 deletions lib/internal/Magento/Framework/App/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,17 +244,23 @@ public function createApplication($type, $arguments = [])
* Runs an application
*
* @param \Magento\Framework\AppInterface $application
* @param bool $alwaysHandleExceptions Whether to handle exceptions regardless of developer mode setting
* @return void
*/
public function run(AppInterface $application)
public function run(AppInterface $application, $alwaysHandleExceptions = true)
{
$prelaunchSuccessful = $this->preLaunch($application);
if (!$prelaunchSuccessful) {
return;
}

// If ignoring exceptions, don't wrap in a try/catch block so that PHP/Xdebug can output a clean backtrace
if ($this->isDeveloperMode() && $this->ignoreExceptionsInDeveloperMode()) {
if ($this->isDeveloperMode()
&& $this->ignoreExceptionsInDeveloperMode()
// Certain entry points such as get.php and static.php should always be handled by the try/catch block
// below since any exceptions should return a 404 header
&& !$alwaysHandleExceptions
) {
Profiler::start('magento');
$response = $application->launch();
$response->sendResponse();
Expand Down
2 changes: 1 addition & 1 deletion pub/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params);
/** @var \Magento\Framework\App\Http $app */
$app = $bootstrap->createApplication('Magento\Framework\App\Http');
$bootstrap->run($app);
$bootstrap->run($app, false);

0 comments on commit 4e7be01

Please sign in to comment.