kayue/WordpressBundle — Issue #2: Global variable $wp_rewrite is returning NULL
Author: kayue
Created: 2011-12-05 04:04:46+00:00
State: open

Hi

I was testing with Wordpress 3.3 RC1. I got the following error when the ApiLoader was trying to require_once the wp-load.php

Fatal error: Call to a member function add_rewrite_tag() on a non-object in /Users/kayue/Sites/wordpress/wp-includes/taxonomy.php on line 333

And line 333 look like this:

$wp_rewrite->add_rewrite_tag("%$taxonomy%", $tag, $args['query_var'] ? "{$args['query_var']}=" : "taxonomy=$taxonomy&term=");

For some reason the global variable `$wp_rewrite` is returning `null`.
I tried to create a simple script and `require_once "wp-load.php"`, the script ran without any problem.
And if I add `$GLOBALS['wp_rewrite'] = $wp_rewrite` to `wp-settings.php`, looks like it solved the problem

Does anyone knows what could be wrong?

Backtrace:

array(7) {
[0]=>
array(4) {
["file"]=>
string(53) "/Users/kayue/Sites/wordpress/wp-includes/taxonomy.php"
["line"]=>
int(30)
["function"]=>
string(17) "register_taxonomy"
["args"]=>
array(3) {
[0]=>
&string(8) "category"
[1]=>
&string(4) "post"
[2]=>
&array(6) {
["hierarchical"]=>
bool(true)
["query_var"]=>
string(13) "category_name"
["rewrite"]=>
array(3) {
["hierarchical"]=>
bool(true)
["slug"]=>
string(8) "category"
["with_front"]=>
bool(true)
}
["public"]=>
bool(true)
["show_ui"]=>
bool(true)
["_builtin"]=>
bool(true)
}
}
}
[1]=>
array(2) {
["function"]=>
string(25) "create_initial_taxonomies"
["args"]=>
array(1) {
[0]=>
&string(0) ""
}
}
[2]=>
array(4) {
["file"]=>
string(51) "/Users/kayue/Sites/wordpress/wp-includes/plugin.php"
["line"]=>
int(405)
["function"]=>
string(20) "call_user_func_array"
["args"]=>
array(2) {
[0]=>
&string(25) "create_initial_taxonomies"
[1]=>
&array(1) {
[0]=>
string(0) ""
}
}
}
[3]=>
array(4) {
["file"]=>
string(44) "/Users/kayue/Sites/wordpress/wp-settings.php"
["line"]=>
int(304)
["function"]=>
string(9) "do_action"
["args"]=>
array(1) {
[0]=>
&string(4) "init"
}
}
[4]=>
array(4) {
["file"]=>
string(42) "/Users/kayue/Sites/wordpress/wp-config.php"
["line"]=>
int(93)
["args"]=>
array(1) {
[0]=>
string(44) "/Users/kayue/Sites/wordpress/wp-settings.php"
}
["function"]=>
string(12) "require_once"
}
[5]=>
array(4) {
["file"]=>
string(40) "/Users/kayue/Sites/wordpress/wp-load.php"
["line"]=>
int(29)
["args"]=>
array(1) {
[0]=>
string(42) "/Users/kayue/Sites/wordpress/wp-config.php"
}
["function"]=>
string(12) "require_once"
}
...