FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
phpmyadmin/src/Profiling.php at master · DDd-Devops/phpmyadmin · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
DDd-Devops
/
phpmyadmin
Public
forked from
phpmyadmin/phpmyadmin
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
phpmyadmin
/
src
/
Profiling.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
80 lines (64 loc) · 2.17 KB
Breadcrumbs
phpmyadmin
/
src
/
Profiling.php
Copy path
File metadata and controls
80 lines (64 loc) · 2.17 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
declare
(strict_types=
1
);
namespace
PhpMyAdmin
;
use
PhpMyAdmin
\
Utils
\
SessionCache
;
/**
* Statement resource usage.
*/
final
class
Profiling
{
public
static
function
isSupported
(
DatabaseInterface
$
dbi
):
bool
{
if
(SessionCache::
has
(
'
profiling_supported
'
)) {
return
(
bool
) SessionCache::
get
(
'
profiling_supported
'
);
}
/**
* 5.0.37 has profiling but for example, 5.1.20 does not
* (avoid a trip to the server for MySQL before 5.0.37)
* and do not set a constant as we might be switching servers
*/
if
(
$
dbi
->
fetchValue
(
'
SELECT @@have_profiling
'
)) {
SessionCache::
set
(
'
profiling_supported
'
,
true
);
return
true
;
}
SessionCache::
set
(
'
profiling_supported
'
,
false
);
return
false
;
}
public
static
function
enable
(
DatabaseInterface
$
dbi
):
void
{
if
(!
isset
(
$
_SESSION
[
'
profiling
'
]) || !
self
::
isSupported
(
$
dbi
)) {
return
;
}
$
dbi
->
query
(
'
SET PROFILING=1;
'
);
}
/** @psalm-return list<array{Status: non-empty-string, Duration: numeric-string}> */
public
static
function
getInformation
(
DatabaseInterface
$
dbi
):
array
{
if
(!
isset
(
$
_SESSION
[
'
profiling
'
]) || !
self
::
isSupported
(
$
dbi
)) {
return
[];
}
/** @psalm-var list<array{Status: non-empty-string, Duration: numeric-string}> $profile */
$
profile
=
$
dbi
->
fetchResult
(
'
SHOW PROFILE;
'
);
return
$
profile
;
}
/**
* Check if profiling was requested and remember it.
*/
public
static
function
check
(
DatabaseInterface
$
dbi
,
ResponseRenderer
$
response
):
void
{
if
(
isset
(
$
_REQUEST
[
'
profiling
'
]) &&
self
::
isSupported
(
$
dbi
)) {
$
_SESSION
[
'
profiling
'
] =
true
;
}
elseif
(
isset
(
$
_REQUEST
[
'
profiling_form
'
])) {
// the checkbox was unchecked
unset(
$
_SESSION
[
'
profiling
'
]);
}
if
(!
isset
(
$
_SESSION
[
'
profiling
'
])) {
return
;
}
$
scripts
=
$
response
->
getHeader
()->
getScripts
();
$
scripts
->
addFiles
([
'
vendor/chart.umd.js
'
,
'
vendor/jquery/jquery.tablesorter.js
'
,
]);
}
}
Back
|
FazBrowse Home
|
New Git URL