[wp-trac] [WordPress Trac] #6088: $wpdb->num_queries oddness related to plugins/function

WordPress Trac wp-trac at lists.automattic.com
Tue Mar 4 04:17:17 GMT 2008


#6088: $wpdb->num_queries oddness related to plugins/function
--------------------------+-------------------------------------------------
 Reporter:  Viper007Bond  |       Owner:  anonymous  
     Type:  defect        |      Status:  new        
 Priority:  low           |   Milestone:  2.6        
Component:  Template      |     Version:  2.5        
 Severity:  minor         |    Keywords:  needs-patch
--------------------------+-------------------------------------------------
 This in a theme's `footer.php` works fine:

 {{{
 <?php echo get_num_queries(); ?> queries. <?php timer_stop(1); ?> seconds.
 }}}

 However, if you stick that inside a function that's been hooked via
 `add_action( 'wp_footer', 'myfunction' );`, it doesn't. Instead it
 displays the page generation time to a 5 decimal accuracy.

 {{{
 echo get_num_queries() . ' queries. ' . timer_stop(1) . " seconds.\n";
 }}}

 This doesn't work either:

 {{{
 global $wpdb;
 echo $wpdb->num_queries . ' queries. ' . timer_stop(1) . " seconds.\n";
 }}}

 The funny thing is that it works fine in the admin area. The bug of
 displaying the generation time rather than the queries only affects the
 main site.

 I haven't a clue why this is happening, else I'd patch.

 [[BR]]
 '''Install Specs'''

 PHP: 5.2.5[[BR]]
 MySQL: 5.0.51[[BR]]
 WordPress: SVN 7148 (2.5-beta1 / 7098)

-- 
Ticket URL: <http://trac.wordpress.org/ticket/6088>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list