Ticket #3267 (closed defect: fixed)

Opened 2 years ago

Last modified 2 years ago

PHP Error in template-functions-links.php

Reported by: Mike_Koepke Assigned to: markjaquith
Priority: high Milestone: 2.0.6
Component: General Version: 2.0.4
Severity: normal Keywords: commit
Cc:

Description

When looking through my server error log, I am getting numerous entries with the following error message:

PHP Fatal error: Call to a member function get_feed_permastruct() on a non-object in /var/www/vhosts/mikekoepke.com/httpdocs/wp-includes/template-functions-links.php on line 185

I am running php 5.0.4

Change History

10/21/06 12:46:01 changed by markjaquith

  • owner changed from anonymous to markjaquith.
  • status changed from new to assigned.

Do you still get it with all plugins disabled?

10/21/06 13:20:06 changed by Denis-de-Bernardy

  • component changed from Template to General.

$wp_rewrite and other WP objects get destroyed before the shutdown hook is called, because they are created as follows:

$wp_query = new WP_Query(); $wp_rewrite = new WP_Rewrite(); $wp = new WP();

I've filed a bug or two related to this in the past, but they never were taken into account. To fix, replace the above with the following in wp-settings.php:

$wp_query =& new WP_Query(); $wp_rewrite =& new WP_Rewrite(); $wp =& new WP();

This extends the life of these objects to _after_ the shutdown hook is called.

Denis

10/21/06 13:21:06 changed by Denis-de-Bernardy

/me curses wiki formatting ;-)

$wp_query   =& new WP_Query();
$wp_rewrite =& new WP_Rewrite();
$wp         =& new WP();

10/21/06 16:50:34 changed by Mike_Koepke

Mark,

I have made the changes Denis has suggested and cleared my server error log. I have about 5-10 of these errors a day, so I am not sure of the sequence of events on the blog that causes the error to occur.

We'll see what happens.

Mike

10/22/06 13:49:40 changed by Mike_Koepke

Mark,

After making the changes Denis suggested, I have not seen the error. I will keep monitoring the error log. Is there anything else you want me to check?

Mike

10/23/06 03:07:17 changed by markjaquith

Mike,

The other thing to check is how PHP4 handles this change.

10/24/06 03:25:45 changed by Mike_Koepke

Mark,

I have made the change on a PHP 4.4.1 server and so far so good. Denis' suggestion works on both PHP 4 & 5. since making the change 3 days ago I haven't seen the template-functions-links.php at all.

Mike

(follow-up: ↓ 9 ) 10/25/06 13:11:45 changed by Mike_Koepke

  • milestone changed from 2.0.5 to 2.1.

Mark,

Well the error occurred again. My domain error log has 5 entries from yesterday. Denis' fix isn't the solution. I'll need to do some troubleshooting to figure out why this is occurring. This ticket should probably get pushed to 2.1 for now.

Mike

(in reply to: ↑ 8 ) 10/25/06 13:26:48 changed by westi

  • keywords set to reporter-feedback.

Replying to Mike_Koepke:

Well the error occurred again. My domain error log has 5 entries from yesterday. Denis' fix isn't the solution. I'll need to do some troubleshooting to figure out why this is occurring. This ticket should probably get pushed to 2.1 for now.

This looks like you have a plugin which calls that function for particular request types that is calling it before the objects are created.

i.e. the function is called before the {'init'} action fires http://trac.wordpress.org/browser/branches/2.0/wp-settings.php#L225.

Do you know what request(s) happen at the same time as the errors in your error_log - some example requests from the access_log may help track this down

10/26/06 00:04:30 changed by Mike_Koepke

  • milestone changed from 2.1 to 2.0.5.

Doh! I did something stupid in that I accidentally wiped out Denis' change when I uploaded a new version of his theme. This explains why the error reoccurred. Anyway I have reapplied it.

As for troubleshooting, I'm not getting a timestamp when the error occurred so I don't know what exactly transpired in the access log at the time. I will say the errors come in bunches. Basically the last "unpatched" occurrence had 3 template-link errors, an unrelated error, and then 2 more. Again without the timestamp it is hard to determine exactly what happened.

Now that I have reapplied Denis' change, I'll watch for additional problems.

10/26/06 06:25:53 changed by markjaquith

  • milestone changed from 2.0.5 to 2.1.

consensus in #wordpress-dev is that this is a hack, but a hack that'll likely keep working. I don't feel good about putting it into 2.0.5, however... it's sort of 11th hour on that.

westi's caveat about running things on plugin load stays in effect, however. init and plugins_loaded are your friends.

11/08/06 00:03:02 changed by foolswisdom

  • keywords changed from reporter-feedback to commit.

Mark, how about checking in that change to trunk now then?

11/19/06 01:18:56 changed by ryan

  • status changed from assigned to closed.
  • version changed from 2.0.4 to 2.0.5.
  • resolution set to fixed.

11/19/06 01:19:08 changed by ryan

  • version changed from 2.0.5 to 2.0.4.
  • milestone changed from 2.1 to 2.0.5.

11/19/06 01:19:14 changed by ryan

  • milestone changed from 2.0.5 to 2.0.6.