WordPress.org

Ready to get started?Download WordPress

Forums

stats bug since 2.3 (with wp-stats and SlimStats) (17 posts)

  1. ihad
    Member
    Posted 6 years ago #

    see http://wordpress.org/support/topic/135835

    and ticket #5121:
    http://trac.wordpress.org/ticket/5121

    After upgrading to wordpress 2.3, none of my statistic plugins (wp-stats 1.1.1 and SlimStat? 1.605) work properly anymore.

    It looks like all hits to posts are returned as hits for one post: Spider-Man 3 (2007) 112 http://www.ihad.de/2007/05/06/spider-man-3-2007/ e.g. a hit is listed as "Spider Man 3" but the link points to http://www.ihad.de/2005/09/16/pitch-black-2000/ a totally different article.

    I moved the post back to "draft" status and sure enough wp-stats (and SlimStats?) started reporting all hits to any post as hits for post My first 80386 PC 4 http://www.ihad.de/2007/04/10/my-first-80386-pc/

    Since this happens with any statistic plugin I am a bit at a loss what could be the cause. Possibly the wp 2.3 DB changes? This happens no matter what theme I have active (even the wp 2.3 default theme).

    I had a friend search for "Rome canceled" in goggle and click on the link that leads to my post: http://www.ihad.de/2007/02/24/rome-season-3-cancelled/

    afterwards the stats increased by one for the Spider-Man post...

  2. Lester Chan
    Member
    Posted 6 years ago #

  3. ihad
    Member
    Posted 6 years ago #

    according to 082net this is a wp 2.3 issue:
    ---
    082net c-kr | October 2nd, 2007, 6:09 pm

    ihad//
    I found that it's not related to K2 but WP_Query.

    $wp_query was overridden by plugins, themes, and widgets using 'new WP_Query()' or 'query_posts()' and 'wp_reset_query()' seems does not works. ( I don't know why 'new WP_Query()' overrides $wp_query :-( Is it a bug or general? )

    So, I decided to query the request again even if it's already queried by wordpress.

    I'll update this plugin soon with another bug patches.

    Thanks!
    http://082net.com/2007/818/wp-slimstat-ex-v1_6/

    ---

    I guess wordpress.com stats plugin needs an update too then?

  4. 082net
    Member
    Posted 6 years ago #

    I was wrong, it's not about WP_Query but $post.

    $post variable overrides $wp_query->post and $wp_the_query->post.

    And any plugin or theme using 'custom loop' would replace the wordpress $post, and 'latest post' sidebar module is one of them.

    e.g.
    foreach($myposts as $post) {......}
    or
    while($myposts->have_posts): $myposts->the_post(); ...... endwhile;

    $myposts would be get_posts('query...') or new WP_Query('query...')

    Since almost stat plugin do their job at the end of the page load, they got overridden post values.

    And here's a temporary patch.

    WordPress.com Stats
    Find :

    if ( ( $wp_the_query->is_single || $wp_the_query->is_page ) && !$wp_the_query->is_attachment )
    		$a['post'] = $wp_the_query->get_queried_object_id();
    	else

    Replace with :

    if ( ( $wp_the_query->is_single || $wp_the_query->is_page ) && !$wp_the_query->is_attachment ) {
    		$wp_the_query->rewind_posts();
    		$a['post'] = $wp_the_query->get_queried_object_id();
    	} else

    SlimStat-Ex
    (I'll update this plugin soon.)
    Find : (inside of function _getPostTitle - lib/functions.php)

    if($track) {
    			$_query =& $wp_query;
    		} else {

    Replace with :

    if($track) {
    			$_query =& $wp_query;
    			$_query->rewind_posts();
    		} else {
  5. Andy Skelton
    Member
    Posted 6 years ago #

    $wp_the_query was created to ensure a copy of the first WP_Query would be available even after subsequent instantiations.

    It's is_single and we're asking for the queried_object_id of $wp_the_query. Why would a rewind fix the problem? Have you verified it against posts that aren't the most recent?

  6. 082net
    Member
    Posted 6 years ago #

    I had a big mistake on my testing. I've tested with $wp_the_query->post->ID not with $wp_the_query->get_queried_object_id(), so it returned wrong(overridden) value. ( I thought they are the same :| )

    BTW, $wp_the_query->queried_object_id was overrode by K2 and $wp_the_query->get_queried_object_id() always returned last post id of recent entries on wp_footer or shutdown hook when it has a 'latest posts' module on single post page.

    I'll report this to K2 team and ask them if it's a bug.

  7. 082net
    Member
    Posted 6 years ago #

    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 overrod 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/class.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.

  8. ihad
    Member
    Posted 6 years ago #

    So you are saying this is "sort of" a wordpress 2.3 bug?

    Added your modifications and it worked! Thanks a lot!

  9. ihad
    Member
    Posted 6 years ago #

    Hm, seems it still does not fully work.

    external [post] Banned Blaupunkt Commercial
    points in fact to:
    http://www.ihad.de/2006/01/12/24-season-5-starts-this-weekend/

    Oh well...

  10. 082net
    Member
    Posted 6 years ago #

    Did you mean SlimStat-Ex?

    Maybe it's a pre-inserted(wp_slimex_resource) title while you have the problem.

  11. ihad
    Member
    Posted 6 years ago #

    yes, I meant slim-stat ex

    in fact almost none of the "titles" displayed in the stats match the actual urls they refer to.

    same goes for wp.com stats.

  12. omikami
    Member
    Posted 6 years ago #

    Has the plugin been updated now so it's safe for use with WordPress 2.3?

  13. edwinkort
    Member
    Posted 6 years ago #

    Not sure if this was addressed before. Can't find it.

    I've been having problems with creating new static pages since upgrading to wp2.3. See my post at the support site.

    When I disabled all the plugins and reactivated them, I found out that this plugin was creating the problems.

  14. Andy Skelton
    Member
    Posted 6 years ago #

    The bug in both plugins was caused by a WordPress bug. The plugins do not need to be updated. The next bugfix release of WordPress will have the fix. It was committed just about an hour ago. You can apply it yourself if you understand this:

    http://trac.wordpress.org/changeset/6232

  15. dawniemom
    Member
    Posted 6 years ago #

    I am not running 2.3 (my host hasn't provided it yet) and my stats stopped working when I changed my theme. In the docs, it refers to a "call to", but I am having trouble trying to figure out what it refers to.

  16. ihad
    Member
    Posted 6 years ago #

    Thanks Andy. The only thing I'd like to add here is that I am surprised that the ticket got closed that quickly as a non WP related issue and had I and 082net pursued that matter it would have stayed that way. I just hope this does not become common practice.

    Cheers,
    Alex

  17. JohnBarrdear
    Member
    Posted 6 years ago #

    Can somebody confirm a) whether this has been fixed and b) in which version of WP it is (or will be) released in?

    I have a suspiciously similar problem occurring at the moment. See: http://wordpress.org/support/topic/155879?replies=2&post-689973

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags