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

Description

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

Here is a small repro:


$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:


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:


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

Assigning to Bill Karwin

Fixed in revision 6170.

Updating Fix Version to follow issue tracker conventions.