Make WordPress Core

Opened 16 years ago

Closed 16 years ago

Last modified 16 years ago

#5121 closed defect (bug) (fixed)

statistics reported back from wordpress 2.3 bugged

Reported by: ihad's profile ihad Owned by:
Milestone: 2.3.1 Priority: high
Severity: normal Version: 2.3
Component: General Keywords: has-patch
Focuses: Cc:

Description

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...

Something is messed up and everything so far indicates it has to do with wp2.3

Attachments (1)

save_fist_wp_query_to_wp_the_query.patch (449 bytes) - added by 082net 16 years ago.

Download all attachments as: .zip

Change History (16)

#1 @ihad
16 years ago

  • Version set to 2.3

#2 @ihad
16 years ago

if any dev needs access to my stats for more info, let me know and I add your email.

#3 @DD32
16 years ago

  • Milestone 2.5 deleted
  • Resolution set to invalid
  • Status changed from new to closed
  • Version 2.3 deleted

With the changes introduced, its likely that many plugins will need to be changed.
Check for updates for your plugins and see if they're compatible with WP 2.3.

Given theres no information here that shows WP has a bug, i'm going to close this as invalid, re-open it if you find (or the plugin author finds) something specifically wrong with WP (This seriously sounds like a plugin bug introduced by a DB change)

#4 @ihad
16 years ago

more info from 082net (SlimStats)

---quote--->
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/

<---end-quote---

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

-> http://wordpress.org/support/topic/136624?replies=3#post-625352

#5 @ihad
16 years ago

  • Resolution invalid deleted
  • Status changed from closed to reopened
  • Version set to 2.3

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()
$GLOBALSposts? = & $wp_query->posts;
$GLOBALSpost? = & $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).

#6 @Nazgul
16 years ago

  • Milestone set to 2.4

#7 @foolswisdom
16 years ago

  • Milestone changed from 2.4 to 2.5

#8 follow-up: @andy
16 years ago

  • Milestone changed from 2.5 to 2.3.1
  • Priority changed from normal to high

$wp_the_query must be fixed in the next bugfix release. Please do not push this back.

Proposed solution: at the end of wp(), do

global $wp_the_query, $wp_query;
if ( !isset( $wp_the_query ) )
  $wp_the_query = $wp_query;

without reference ampersand.

#9 in reply to: ↑ 8 @Nazgul
16 years ago

  • Keywords needs-patch added
  • Milestone changed from 2.3.1 to 2.4

Replying to andy:

$wp_the_query must be fixed in the next bugfix release. Please do not push this back.

Andy, tickets without a patch tend to get pushed back.
If you (or somebody else) is interested in seeing an issue fixed, attach a patch and tag it as has-patch. That way the core developers will notice it and usually include it much sooner.

Also, all fixes go into the current development branch first and are then sometimes backported to a maintenance release. Therefore I'm setting the milestone as 2.4 for now.

#10 @foolswisdom
16 years ago

  • Milestone changed from 2.4 to 2.3.1

Andy, is Andy Skelton, setting milestone to 2.3.1 . Don't know why he didn't attach the patch.

#11 @082net
16 years ago

  • Keywords has-patch added; needs-patch removed

Attached Andy's patch. (wp-includes/functions.php)

#12 @andy
16 years ago

Sorry about the missing patch, Nazgul. I was in a rush.

Thanks for making the patch, 082net. Does it work as intended? :-)

#13 @082net
16 years ago

It works very well and by the root :-)

#14 @ryan
16 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

(In [6232]) Make sure initial query is saved when calling wp(). Props andy. fixes #5121 for 2.3

#15 @ryan
16 years ago

trunk fixed with [6233]

Note: See TracTickets for help on using tickets.