<commit_before><?php

class PhpDebugToolbarDoctrineConnectionListener extends Doctrine_EventListener {
   
    protected $last_exec_start_time = null;

    public function preExec(Doctrine_Event $event)
    {
        $this->last_exec_start_time = microtime(true);
    }

    public function postExec(Doctrine_Event $event)
    {
        DoctrineDatabaseToolbarExtension::$count++;
        DoctrineDatabaseToolbarExtension::$time += (microtime(true) - $this->last_exec_start_time);
    }

    public function preStmtExecute(Doctrine_Event $event)
    {
        $query_group = $event->getQuery();
        $query_string = $query_group;
        foreach ($event->getParams() as $value) {
            /*
             * Just replace the first ?, not all!
             */
            $query_string = preg_replace('/\?/', $value, $query_string, 1);
        }

        $backtrace = array_slice(debug_backtrace(false), 4);
        foreach ($backtrace as $k => $v)
        {
            unset($backtrace[$k]['args']);
            unset($backtrace[$k]['object']);
        }
        $this->last_exec_start_time = microtime(true);
        PhpDebugToolbar::appendValue('database_queries', array(
            'sql' => $query_string,
            'stack' => $backtrace,
            'group' => $query_group
        ));
    }

    public function postStmtExecute(Doctrine_Event $event)
    {
        DoctrineDatabaseToolbarExtension::$count++;
        DoctrineDatabaseToolbarExtension::$time += (microtime(true) - $this->last_exec_start_time);
    }
 
    public function preQuery(Doctrine_Event $event)
    {
        $this->last_exec_start_time = microtime(true);
    }

    public function postQuery(Doctrine_Event $event)
    {
        DoctrineDatabaseToolbarExtension::$count++;
        DoctrineDatabaseToolbarExtension::$time += (microtime(true) - $this->last_exec_start_time);
    }
}
<commit_msg>Checking whether we have any params at all (in case of prepared statements, this failed earlier!)<commit_after><?php

class PhpDebugToolbarDoctrineConnectionListener extends Doctrine_EventListener {
   
    protected $last_exec_start_time = null;

    public function preExec(Doctrine_Event $event)
    {
        $this->last_exec_start_time = microtime(true);
    }

    public function postExec(Doctrine_Event $event)
    {
        DoctrineDatabaseToolbarExtension::$count++;
        DoctrineDatabaseToolbarExtension::$time += (microtime(true) - $this->last_exec_start_time);
    }

    public function preStmtExecute(Doctrine_Event $event)
    {
        $query_group = $event->getQuery();
        $query_string = $query_group;
        $params = $event->getParams();

        if ($params) {
            foreach ($params as $value) {
                /*
                 * Just replace the first ?, not all!
                 */
                $query_string = preg_replace('/\?/', $value, $query_string, 1);
            }
        }

        $backtrace = array_slice(debug_backtrace(false), 4);
        foreach ($backtrace as $k => $v)
        {
            unset($backtrace[$k]['args']);
            unset($backtrace[$k]['object']);
        }
        $this->last_exec_start_time = microtime(true);
        PhpDebugToolbar::appendValue('database_queries', array(
            'sql' => $query_string,
            'stack' => $backtrace,
            'group' => $query_group
        ));
    }

    public function postStmtExecute(Doctrine_Event $event)
    {
        DoctrineDatabaseToolbarExtension::$count++;
        DoctrineDatabaseToolbarExtension::$time += (microtime(true) - $this->last_exec_start_time);
    }
 
    public function preQuery(Doctrine_Event $event)
    {
        $this->last_exec_start_time = microtime(true);
    }

    public function postQuery(Doctrine_Event $event)
    {
        DoctrineDatabaseToolbarExtension::$count++;
        DoctrineDatabaseToolbarExtension::$time += (microtime(true) - $this->last_exec_start_time);
    }
}

{'fraction_non_alphanumeric': 0.12178998220188152, 'fraction_numerical': 0.0010170353419781336, 'mean_word_length': 2.7043314500941618, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2651403', 'n_tokens_mistral': 1128, 'n_tokens_neox': 1138, 'n_words': 193}