[wp-trac] Re: [WordPress Trac] #5121: statistics reported back from
 wordpress 2.3 bugged
    WordPress Trac 
    wp-trac at lists.automattic.com
       
    Thu Oct  4 18:16:45 GMT 2007
    
    
  
#5121: statistics reported back from wordpress 2.3 bugged
---------------------+------------------------------------------------------
 Reporter:  ihad     |        Owner:  anonymous
     Type:  defect   |       Status:  reopened 
 Priority:  normal   |    Milestone:           
Component:  General  |      Version:  2.3      
 Severity:  normal   |   Resolution:           
 Keywords:           |  
---------------------+------------------------------------------------------
Changes (by ihad):
  * status:  closed => reopened
  * version:  => 2.3
  * resolution:  invalid =>
Comment:
 This is wordpress related after all, so I am reopening this ticket.
 ---quote--->
 It was not a K2 bug.
 It's the matter of when $wp_the_query->get_queried_object() is firstly
 called.
 As I mentioned above, $wp_the_query->post is overrode by $post.
 wp-settings.php
 $wp_the_query =& new WP_Query();
 $wp_query     =& $wp_the_query;
 wp-includes/class.php WP::register_globals()
 $GLOBALS['posts'] = & $wp_query->posts;
 $GLOBALS['post'] = & $wp_query->post;
 If a page haven't called $wp_the_query->get_queried_object() before a
 'custom loop' (or something overriding $post or $posts),
 get_queried_object_id() would retun last post id of the 'custom loop'.
 $wp_the_query->get_queried_object() would not stable until it is firstly
 called before any plugin or theme.
 It seems stable 'cause it returns pre-set value if available.
 function get_queried_object() {
         if (isset($this->queried_object)) {
                 return $this->queried_object;
         }
 Because almost wordpress theme use 'wp_title()' for <title> </title> and
 wp_title call 'wp_query->get_queried_object()', there seems no problem.
 For current K2 does not use wp_title() but the_title() which does not call
 'get_queried_object', this issue seems related to K2.
 Here's my suggestion to wordpress and I think it will help make
 $wp_the_query stable.
 wp-includes/classes.php 'WP::query_posts()'
 function query_posts() {
         global $wp_the_query;
         $this->build_query_string();
         $wp_the_query->query($this->query_vars);
         $wp_the_query->get_queried_object();// add this line
 }
 And temporary patch for K2 is replacing the_title() with wp_title() on
 header.php but it will not solve the whole problem.
 <---- endquote from 082net (Thanks man, it worked for me for now).
-- 
Ticket URL: <http://trac.wordpress.org/ticket/5121#comment:5>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software
    
    
More information about the wp-trac
mailing list