diff options
author | diosmosis <diosmosis@users.noreply.github.com> | 2018-08-03 04:01:37 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-03 04:01:37 +0300 |
commit | f8ea46b3252ee14da53b32a9118e2af494c29eac (patch) | |
tree | ef57f1b96a0eba2477fd3939ddfdb1401dbfbcff /tests/resources | |
parent | cb1d83db863938ace3ebdafd072dfd32e434fded (diff) |
Reconstruct partial stack traces for fatal errors. (#13238)
* Reconstruct partial stack traces for fatal errors.
* tweak to fatal error breadcrumb
* Add docs + fix test.
* Add fatal error test and improve fatal error stack trace a bit.
* fix test on travis
Diffstat (limited to 'tests/resources')
-rw-r--r-- | tests/resources/trigger-fatal.php | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/tests/resources/trigger-fatal.php b/tests/resources/trigger-fatal.php new file mode 100644 index 0000000000..973622e6e0 --- /dev/null +++ b/tests/resources/trigger-fatal.php @@ -0,0 +1,57 @@ +<?php + +define('PIWIK_PRINT_ERROR_BACKTRACE', true); +define('PIWIK_ENABLE_DISPATCH', false); + +require_once __DIR__ . '/../../tests/PHPUnit/proxy/index.php'; + +$environment = new \Piwik\Application\Environment(null); +$environment->init(); + +\Piwik\Access::getInstance()->setSuperUserAccess(true); + +class MyClass +{ + public function triggerError() + { + try { + \Piwik\ErrorHandler::pushFatalErrorBreadcrumb(static::class); + + $val = ""; + while (true) { + $val .= str_repeat("*", 1024 * 1024 * 1024); + } + } finally { + \Piwik\ErrorHandler::popFatalErrorBreadcrumb(); + } + } + + public static function staticMethod() + { + try { + \Piwik\ErrorHandler::pushFatalErrorBreadcrumb(static::class); + + $instance = new MyClass(); + $instance->triggerError(); + } finally { + \Piwik\ErrorHandler::popFatalErrorBreadcrumb(); + } + } +} + +class MyDerivedClass extends MyClass +{ +} + +function myFunction() +{ + try { + \Piwik\ErrorHandler::pushFatalErrorBreadcrumb(); + + MyDerivedClass::staticMethod(); + } finally { + \Piwik\ErrorHandler::popFatalErrorBreadcrumb(); + } +} + +myFunction(); |