Welcome to mirror list, hosted at ThFree Co, Russian Federation.

trigger-fatal.php « resources « tests - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3065331b652ce4858540ab80638e725a09d6438e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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($arg1, $arg2)
    {
        try {
            \Piwik\ErrorHandler::pushFatalErrorBreadcrumb(static::class, ['arg1' => $arg1, 'arg2' => $arg2]);

            $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('argval', 'another');
        } finally {
            \Piwik\ErrorHandler::popFatalErrorBreadcrumb();
        }
    }
}

class MyDerivedClass extends MyClass
{
}

function myFunction()
{
    try {
        \Piwik\ErrorHandler::pushFatalErrorBreadcrumb();

        MyDerivedClass::staticMethod();
    } finally {
        \Piwik\ErrorHandler::popFatalErrorBreadcrumb();
    }
}

myFunction();