1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use Xmf\Module\Helper\Permission; |
|
|
|
|
4
|
|
|
|
5
|
|
|
|
6
|
|
|
/** |
7
|
|
|
* @copyright 2019-2021 XOOPS Project (https://xoops.org) |
8
|
|
|
* @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
9
|
|
|
* @author Richard Griffith <[email protected]> |
10
|
|
|
*/ |
11
|
|
|
class Xwhoops25CorePreload extends XoopsPreloadItem |
|
|
|
|
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* eventCoreIncludeCommonAuthSuccess |
15
|
|
|
* |
16
|
|
|
* @return void |
17
|
|
|
*/ |
18
|
|
|
public static function eventCoreIncludeCommonAuthSuccess() |
19
|
|
|
{ |
20
|
|
|
$autoloader = dirname(__DIR__) . '/vendor/autoload.php'; |
21
|
|
|
if (!file_exists($autoloader)) { |
22
|
|
|
trigger_error("xwhoops25/vendor/autoload.php not found, was 'composer install' done?"); |
23
|
|
|
return; |
24
|
|
|
} |
25
|
|
|
xoops_loadLanguage('logger'); |
|
|
|
|
26
|
|
|
require_once $autoloader; |
27
|
|
|
$permissionHelper = new Permission('xwhoops25'); |
28
|
|
|
if ($permissionHelper) { |
|
|
|
|
29
|
|
|
$permissionName = 'use_xwhoops'; |
30
|
|
|
$permissionItemId = 0; |
31
|
|
|
|
32
|
|
|
if ($permissionHelper->checkPermission($permissionName, $permissionItemId, false)) { |
33
|
|
|
$whoops = new \Whoops\Run; |
34
|
|
|
$handler = new \Whoops\Handler\PrettyPageHandler; |
35
|
|
|
$whoops->pushHandler($handler); |
36
|
|
|
$whoops->register(); |
37
|
|
|
$handler->addDataTableCallback( |
38
|
|
|
_LOGGER_QUERIES, |
|
|
|
|
39
|
|
|
function () { |
40
|
|
|
$logger = XoopsLogger::getInstance(); |
|
|
|
|
41
|
|
|
if (false == $logger->renderingEnabled) { |
42
|
|
|
return ['XoopsLogger' => 'off']; // logger is off so data is incomplete |
43
|
|
|
} |
44
|
|
|
$queries = []; |
45
|
|
|
$count=1; |
46
|
|
|
foreach($logger->queries as $key => $q) { |
47
|
|
|
$error = (null===$q['errno'] ? '' : $q['errno'].' ') . (null===$q['error'] ? '' : $q['error']); |
48
|
|
|
$queryTime = isset($q['query_time']) ? sprintf('%0.6f', $q['query_time']) : ''; |
49
|
|
|
$queryKey = (string) $count++ . ' - ' . $queryTime; |
50
|
|
|
if (null !== $q['errno']) { |
51
|
|
|
$queryKey = (string) $count .' - Error' ; |
52
|
|
|
} |
53
|
|
|
$queries[$queryKey] = htmlentities($q['sql']) . ' ' . $error; |
54
|
|
|
} |
55
|
|
|
return ($queries); |
56
|
|
|
} |
57
|
|
|
); |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths