Issues

ZF-1861: Profiler does not obey filtered query types set by method setFilterQueryType()

Issue Type: Bug Created: 2007-08-17T20:02:44.000+0000 Last Updated: 2008-01-23T18:28:48.000+0000 Status: Resolved Fix version(s): - 1.0.2 (25/Sep/07)

Reporter: Salvador Ledezma (ledezma) Assignee: Bill Karwin (bkarwin) Tags: - Zend_Db

Related issues: Attachments:

Description

Using the method setFilterQueryType() has no effect on the query profiles that are saved by the profiler.

Here is a small repro:

<pre class="highlight">
$db = Zend_Db::factory('Db2', $params);

$db->getProfiler()->setEnabled(true);
$db->getProfiler()->setFilterQueryType(Zend_Db_Profiler::INSERT);

$data = array("PRODUCT_NAME" => "hello");
$db->insert("SIMP", $data);

$sql = 'SELECT * FROM SIMP';
$result = $db->fetchAll($sql);

$db->getProfiler()->setEnabled(false);

$profiler = $db->getProfiler();
$qp = $profiler->getQueryProfiles();

print_r($qp);

The output of the print_r() statement is:

<pre class="highlight">
Array
(
    [0] => Zend_Db_Profiler_Query Object
        (
            [_query:protected] => INSERT INTO "SIMP" ("PRODUCT_NAME") VALUES (?)
            [_queryType:protected] => 4
            [_startedMicrotime:protected] => 1187397850.1719
            [_endedMicrotime:protected] => 1187397850.1731
            [_boundParams:protected] => Array
                (
                    [1] => hello
                )

            [_parameterValues:protected] => Array
                (
                    [1] => hello
                )

        )

    [1] => Zend_Db_Profiler_Query Object
        (
            [_query:protected] => SELECT * FROM SIMP
            [_queryType:protected] => 32
            [_startedMicrotime:protected] => 1187397850.1751
            [_endedMicrotime:protected] => 1187397850.1758
            [_boundParams:protected] => Array
                (
                )

            [_parameterValues:protected] => Array
                (
                )

        )

)

Expected output is only the INSERT statement because of the INSERT filter:

<pre class="highlight">
Array
(
    [0] => Zend_Db_Profiler_Query Object
        (
            [_query:protected] => INSERT INTO "SIMP" ("PRODUCT_NAME") VALUES (?)
            [_queryType:protected] => 4
            [_startedMicrotime:protected] => 1187397972.7345
            [_endedMicrotime:protected] => 1187397972.7355
            [_boundParams:protected] => Array
                (
                    [1] => hello
                )

            [_parameterValues:protected] => Array
                (
                    [1] => hello
                )

        )

)

I am not very familiar with the profiler code, but it seems like the queryEnds() method is never called. It is in there that the filtering takes place.

Another thing I noticed is that in the Statement class, the constructor calls queryStart() in the profiler, but the execute() method, only ends the queryProfile. I don't think this info gets back to the profiler so that it knows to end the query as well.

Comments

Posted by Bill Karwin (bkarwin) on 2007-08-18T17:48:57.000+0000

Assigning to Bill Karwin

Posted by Bill Karwin (bkarwin) on 2007-08-21T17:00:20.000+0000

Fixed in revision 6170.

Posted by Wil Sinclair (wil) on 2008-01-23T18:28:48.000+0000

Updating Fix Version to follow issue tracker conventions.

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts