Make WordPress Core

Opened 8 years ago

Closed 7 years ago

Last modified 7 years ago

#14382 closed defect (bug) (invalid)

extra pages loading unnecessarily

Reported by: zengy Owned by:
Milestone: Priority: normal
Severity: major Version: 3.0
Component: Rewrite Rules Keywords: regression
Focuses: Cc:

Description (last modified by scribu)

I have a WP3 issue that I came across and I thought it should be posted here. I apologize if this has been posted previously. Please let me know if this issue exists as a current known bug.

I am coding a plugin that needs to do something on 'wp_head'. I was noticing that it was executing my code twice. I am now using error_log() to display the post ID and it is displaying the ID of the page I am loading plus another page ID.

This only happens when loading pages that have subpages associated with them. This bug occurs when a custom permalink structure is chosen. It does not happen when using the default permalink structure.

Here are steps to reproduce this issue:

1) Create a new WP3 site and create a .htaccess file.

2) Install and activate this plugin:


* Plugin Name: Post ID Test

function display_post_id() {
	global $post;
	error_log('post id: ' . $post->ID . ' | post title: ' . $post->post_title);

add_action('wp_head', 'display_post_id');


3) Create the following page hierarchy:

Page 1
  Page 1.1
  Page 1.2
Page 2

4) Change the permalink settings to "Day and Name".

5) Visit the front end for Page 2. Your error log will be something like this:

	[21-Jul-2010 19:59:04] post id: 10 | post title: Page 2

6) Now visit the front end for Page 1. Your error log will be something like this:

	[21-Jul-2010 20:00:46] post id: 4 | post title: Page 1
	[21-Jul-2010 20:00:47] post id: 6 | post title: Page 1.1

7) Page 1.1 generates the following:

	[21-Jul-2010 20:00:58] post id: 6 | post title: Page 1.1
	[21-Jul-2010 20:00:58] post id: 8 | post title: Page 1.2

I tried this in W 2.9.2 and the issue does not exist.

Change History (25)

#1 @scribu
8 years ago

  • Component changed from General to Query
  • Description modified (diff)

#2 follow-up: @scribu
8 years ago

  • Keywords reporter-feedback added; permalinks wp_head pages removed

This is probably a theme issue. Does it happen with Twentyten also?

#3 @scribu
8 years ago

  • Description modified (diff)

#4 in reply to: ↑ 2 @zengy
8 years ago

Replying to scribu:

This is probably a theme issue. Does it happen with Twentyten also?

I thought it may have been a theme issue as well, but it isn't. It happens in Twentyten as well. To make sure, I tested this with a new install of WP3.

#5 @zengy
8 years ago

  • Cc zengy added

#6 @scribu
8 years ago

Instead of error_log(), use debug_print_backtrace() and see what you get.

#7 @scribu
8 years ago

  • Component changed from Query to Rewrite Rules
  • Keywords regression added; reporter-feedback removed
  • Milestone changed from Awaiting Review to 3.1

Bug confirmed. The backtrace is identical in both cases.

#8 @scribu
8 years ago

It seems WP is simply loaded twice.

#9 @scribu
8 years ago

By the way, I'm on ngnix.

#10 @zengy
8 years ago

Glad to see this is happening for you as well. I have a project that is broken currently due to this bug. Is there any early insight as to what might be causing this? If so, I can go make a patch to the WP core to fix it for now.

I am using MAMP.

#11 @ericmann
8 years ago

  • Cc eric@… added

#12 @zengy
8 years ago

  • Severity changed from normal to major

#13 @azizur
8 years ago

  • Cc prodevstudio+wordpress@… added

#14 @freddyware
8 years ago

  • Cc frederick.ding@… added

#15 follow-up: @dd32
8 years ago

I cant reproduce this.

Have you disabled all plugins?

What widgets do you have active?

Do the posts have anything in them other than Text? Images? Links?

Beef up the code a bit:

function display_post_id() {
	global $post;
	error_log('post id: ' . $post->ID . ' | post title: ' . $post->post_title . ' | Time:' . $_SERVER['REQUEST_TIME'] . ' | UserAgent:' . $_SERVER['HTTP_USER_AGENT']);

add_action('wp_head', 'display_post_id');

See if the User agent reveals anything, If its "WordPress.*" then its likely a HTTP callback, if its the browser, It could be a HTTP Accelerator which caches pages you're likely to visit

#16 in reply to: ↑ 15 @zengy
7 years ago

OK, odd. Now I am not able to replicate it. I am wondering if this was some error in Apache?

#17 @blepoxp
7 years ago

I cannot reproduce this on 3.0.1 with PHP4 or PHP5 on apache.

#18 @scribu
7 years ago

Still there:

post id: 747 | post title: Page 1 | Time:1280697910 | UserAgent:Mozilla/5.0 (X11; U; Linux i686; en-US; rv: Gecko/20100723 Ubuntu/10.04 (lucid) Firefox/3.6.8

post id: 749 | post title: Page 1.1 | Time:1280697911 | UserAgent:Mozilla/5.0 (X11; U; Linux i686; en-US; rv: Gecko/20100723 Ubuntu/10.04 (lucid) Firefox/3.6.8

#19 @scribu
7 years ago

Just noticed that the problem does not appear if I use curl from the command line. I think Firefox prefetches the URL pointed to by the <link rel='next'> tag.

#20 @scribu
7 years ago

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

Also, the issue doesn not appear in Chrome.

#21 @scribu
7 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened


#22 @scribu
7 years ago

  • Milestone 3.1 deleted
  • Resolution set to invalid
  • Status changed from reopened to closed

I don't think there's much we can do here.

If somebody does comes up with a patch for this, feel free to reopen.

#23 @blepoxp
7 years ago

Ah. I was testing in Chrome. I can confirm the issue in FF as well.

#24 @WraithKenny
7 years ago

The description for this ticket says that he tested on WP 2.9.2 (presumably with the latest FF) and didn't replicate the bug... so doesn't that mean something changed in WP between 2.9.2 and 3.0?

#25 @scribu
7 years ago

Yes, the thing that probably changed was the addition of the <link rel='next'> tag. I might be wrong though.

Note: See TracTickets for help on using tickets.