#3267 closed defect (bug) (fixed)
PHP Error in template-functions-links.php
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 2.0.6 | Priority: | high |
| Severity: | normal | Version: | 2.0.4 |
| Component: | General | Keywords: | commit |
| Focuses: | 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 (15)
#2
@
19 years ago
- 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
#3
@
19 years ago
/me curses wiki formatting ;-)
$wp_query =& new WP_Query(); $wp_rewrite =& new WP_Rewrite(); $wp =& new WP();
#4
@
19 years ago
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
#5
@
19 years ago
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
#7
@
19 years ago
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
#8
follow-up:
↓ 9
@
19 years ago
- 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
#9
in reply to:
↑ 8
@
19 years ago
- Keywords reporter-feedback added
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
@
19 years ago
- 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.
#11
@
19 years ago
- 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.
#12
@
19 years ago
- Keywords commit added; reporter-feedback removed
Mark, how about checking in that change to trunk now then?
Do you still get it with all plugins disabled?