Skip to content

Commit 67d7b23

Browse files
Merge MAGETWO-96505 into 2.3-bugfixes-040219
2 parents 6f5bc4f + 0fb5ba2 commit 67d7b23

File tree

6 files changed

+48
-8
lines changed

6 files changed

+48
-8
lines changed

.htaccess

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929

3030
############################################
3131
## default index file
32+
## Specifies option, to use methods arguments in backtrace or not
33+
SetEnv MAGE_DEBUG_SHOW_ARGS 1
3234

3335
DirectoryIndex index.php
3436

.htaccess.sample

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929

3030
############################################
3131
## default index file
32+
## Specifies option, to use methods arguments in backtrace or not
33+
SetEnv MAGE_DEBUG_SHOW_ARGS 1
3234

3335
DirectoryIndex index.php
3436

lib/internal/Magento/Framework/App/Http.php

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\Framework\App;
77

88
use Magento\Framework\App\Filesystem\DirectoryList;
9+
use Magento\Framework\Debug;
910
use Magento\Framework\ObjectManager\ConfigLoaderInterface;
1011
use Magento\Framework\App\Request\Http as RequestHttp;
1112
use Magento\Framework\App\Response\Http as ResponseHttp;
@@ -79,7 +80,7 @@ class Http implements \Magento\Framework\AppInterface
7980
* @param ResponseHttp $response
8081
* @param ConfigLoaderInterface $configLoader
8182
* @param State $state
82-
* @param Filesystem $filesystem,
83+
* @param Filesystem $filesystem
8384
* @param \Magento\Framework\Registry $registry
8485
*/
8586
public function __construct(
@@ -149,7 +150,7 @@ public function launch()
149150
}
150151

151152
/**
152-
* {@inheritdoc}
153+
* @inheritdoc
153154
*/
154155
public function catchException(Bootstrap $bootstrap, \Exception $exception)
155156
{
@@ -198,6 +199,7 @@ private function buildContentFromException(\Exception $exception)
198199
{
199200
/** @var \Exception[] $exceptions */
200201
$exceptions = [];
202+
201203
do {
202204
$exceptions[] = $exception;
203205
} while ($exception = $exception->getPrevious());
@@ -214,7 +216,12 @@ private function buildContentFromException(\Exception $exception)
214216
$index,
215217
get_class($exception),
216218
$exception->getMessage(),
217-
$exception->getTraceAsString()
219+
Debug::trace(
220+
$exception->getTrace(),
221+
true,
222+
true,
223+
(bool)getenv('MAGE_DEBUG_SHOW_ARGS')
224+
)
218225
);
219226
}
220227

@@ -312,7 +319,15 @@ private function handleInitException(\Exception $exception)
312319
*/
313320
private function handleGenericReport(Bootstrap $bootstrap, \Exception $exception)
314321
{
315-
$reportData = [$exception->getMessage(), $exception->getTraceAsString()];
322+
$reportData = [
323+
$exception->getMessage(),
324+
Debug::trace(
325+
$exception->getTrace(),
326+
true,
327+
true,
328+
(bool)getenv('MAGE_DEBUG_SHOW_ARGS')
329+
)
330+
];
316331
$params = $bootstrap->getParams();
317332
if (isset($params['REQUEST_URI'])) {
318333
$reportData['url'] = $params['REQUEST_URI'];

lib/internal/Magento/Framework/App/StaticResource.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\Framework\Filesystem;
1111
use Magento\Framework\Config\ConfigOptionsListConstants;
1212
use Psr\Log\LoggerInterface;
13+
use Magento\Framework\Debug;
1314

1415
/**
1516
* Entry point for retrieving static resources like JS, CSS, images by requested public path
@@ -138,15 +139,23 @@ public function launch()
138139
}
139140

140141
/**
141-
* {@inheritdoc}
142+
* @inheritdoc
142143
*/
143144
public function catchException(Bootstrap $bootstrap, \Exception $exception)
144145
{
145146
$this->getLogger()->critical($exception->getMessage());
146147
if ($bootstrap->isDeveloperMode()) {
147148
$this->response->setHttpResponseCode(404);
148149
$this->response->setHeader('Content-Type', 'text/plain');
149-
$this->response->setBody($exception->getMessage() . "\n" . $exception->getTraceAsString());
150+
$this->response->setBody(
151+
$exception->getMessage() . "\n" .
152+
Debug::trace(
153+
$exception->getTrace(),
154+
true,
155+
true,
156+
(bool)getenv('MAGE_DEBUG_SHOW_ARGS')
157+
)
158+
);
150159
$this->response->sendResponse();
151160
} else {
152161
require $this->getFilesystem()->getDirectoryRead(DirectoryList::PUB)->getAbsolutePath('errors/404.php');

lib/internal/Magento/Framework/Message/Manager.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Magento\Framework\Event;
99
use Psr\Log\LoggerInterface;
1010
use Magento\Framework\App\ObjectManager;
11+
use Magento\Framework\Debug;
1112

1213
/**
1314
* Message manager model
@@ -250,7 +251,12 @@ public function addException(\Exception $exception, $alternativeText = null, $gr
250251
'Exception message: %s%sTrace: %s',
251252
$exception->getMessage(),
252253
"\n",
253-
$exception->getTraceAsString()
254+
Debug::trace(
255+
$exception->getTrace(),
256+
true,
257+
true,
258+
(bool)getenv('MAGE_DEBUG_SHOW_ARGS')
259+
)
254260
);
255261

256262
$this->logger->critical($message);
@@ -288,7 +294,12 @@ public function addExceptionMessage(\Exception $exception, $alternativeText = nu
288294
'Exception message: %s%sTrace: %s',
289295
$exception->getMessage(),
290296
"\n",
291-
$exception->getTraceAsString()
297+
Debug::trace(
298+
$exception->getTrace(),
299+
true,
300+
true,
301+
(bool)getenv('MAGE_DEBUG_SHOW_ARGS')
302+
)
292303
);
293304

294305
$this->logger->critical($message);

nginx.conf.sample

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
# listen 80;
1010
# server_name mage.dev;
1111
# set $MAGE_ROOT /var/www/magento2;
12+
# set $MAGE_DEBUG_SHOW_ARGS 1
1213
# include /vagrant/magento2/nginx.conf.sample;
1314
# }
1415
#

0 commit comments

Comments
 (0)