Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
d1038981
Commit
d1038981
authored
Jul 09, 2012
by
Danny Berger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix DebugStack->stopQuery to prevent unnecessary timings when disabled.
parent
40d9841f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
1 deletion
+50
-1
DebugStack.php
lib/Doctrine/DBAL/Logging/DebugStack.php
+3
-1
DebugStackTest.php
tests/Doctrine/Tests/DBAL/Logging/DebugStackTest.php
+47
-0
No files found.
lib/Doctrine/DBAL/Logging/DebugStack.php
View file @
d1038981
...
...
@@ -61,7 +61,9 @@ class DebugStack implements SQLLogger
*/
public
function
stopQuery
()
{
$this
->
queries
[
$this
->
currentQuery
][
'executionMS'
]
=
microtime
(
true
)
-
$this
->
start
;
if
(
$this
->
enabled
)
{
$this
->
queries
[
$this
->
currentQuery
][
'executionMS'
]
=
microtime
(
true
)
-
$this
->
start
;
}
}
}
tests/Doctrine/Tests/DBAL/Logging/DebugStackTest.php
0 → 100644
View file @
d1038981
<?php
namespace
Doctrine\Tests\DBAL\Logging
;
require_once
__DIR__
.
'/../../TestInit.php'
;
class
DebugStackTest
extends
\Doctrine\Tests\DbalTestCase
{
public
function
setUp
()
{
$this
->
logger
=
new
\Doctrine\DBAL\Logging\DebugStack
();
}
public
function
tearDown
()
{
unset
(
$this
->
logger
);
}
public
function
testLoggedQuery
()
{
$this
->
logger
->
startQuery
(
'SELECT column FROM table'
);
$this
->
assertEquals
(
array
(
1
=>
array
(
'sql'
=>
'SELECT column FROM table'
,
'params'
=>
null
,
'types'
=>
null
,
'executionMS'
=>
0
,
),
),
$this
->
logger
->
queries
);
$this
->
logger
->
stopQuery
();
$this
->
assertGreaterThan
(
0
,
$this
->
logger
->
queries
[
1
][
'executionMS'
]);
}
public
function
testLoggedQueryDisabled
()
{
$this
->
logger
->
enabled
=
false
;
$this
->
logger
->
startQuery
(
'SELECT column FROM table'
);
$this
->
assertEquals
(
array
(),
$this
->
logger
->
queries
);
$this
->
logger
->
stopQuery
();
$this
->
assertEquals
(
array
(),
$this
->
logger
->
queries
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment