3 declare(strict_types
=1);
7 use PhpMyAdmin\Utils\SessionCache
;
10 * Statement resource usage.
14 public static function isSupported(DatabaseInterface
$dbi): bool
16 if (SessionCache
::has('profiling_supported')) {
17 return (bool) SessionCache
::get('profiling_supported');
21 * 5.0.37 has profiling but for example, 5.1.20 does not
22 * (avoid a trip to the server for MySQL before 5.0.37)
23 * and do not set a constant as we might be switching servers
25 if ($dbi->fetchValue('SELECT @@have_profiling')) {
26 SessionCache
::set('profiling_supported', true);
31 SessionCache
::set('profiling_supported', false);
36 public static function enable(DatabaseInterface
$dbi): void
38 if (! isset($_SESSION['profiling']) ||
! self
::isSupported($dbi)) {
42 $dbi->query('SET PROFILING=1;');
45 /** @psalm-return list<array{Status: non-empty-string, Duration: numeric-string}> */
46 public static function getInformation(DatabaseInterface
$dbi): array
48 if (! isset($_SESSION['profiling']) ||
! self
::isSupported($dbi)) {
52 /** @psalm-var list<array{Status: non-empty-string, Duration: numeric-string}> $profile */
53 $profile = $dbi->fetchResult('SHOW PROFILE;');
59 * Check if profiling was requested and remember it.
61 public static function check(DatabaseInterface
$dbi, ResponseRenderer
$response): void
63 if (isset($_REQUEST['profiling']) && self
::isSupported($dbi)) {
64 $_SESSION['profiling'] = true;
65 } elseif (isset($_REQUEST['profiling_form'])) {
66 // the checkbox was unchecked
67 unset($_SESSION['profiling']);
70 if (! isset($_SESSION['profiling'])) {
74 $scripts = $response->getHeader()->getScripts();
76 'vendor/chart.umd.js',
77 'vendor/jquery/jquery.tablesorter.js',