[wp-trac] [WordPress Trac] #27117: Fatal error in url_to_postid() when $wp_rewrite is null

WordPress Trac noreply at wordpress.org
Wed Feb 12 22:33:42 UTC 2014


#27117: Fatal error in  url_to_postid() when $wp_rewrite is null
---------------------------+-----------------------------
 Reporter:  chrishoward    |      Owner:
     Type:  defect (bug)   |     Status:  new
 Priority:  normal         |  Milestone:  Awaiting Review
Component:  Rewrite Rules  |    Version:  3.8.1
 Severity:  normal         |   Keywords:
  Focuses:                 |
---------------------------+-----------------------------
 Encountered a fatal error today:

 ''Fatal error: Call to a member function wp_rewrite_rules() on a non-
 object in /Users/chrishoward/Dropbox/wp-mba.dev/wp-includes/rewrite.php on
 line 301''

 Did some testing, and $wp_rewrite was null.

 Line 301 is:

         $rewrite = $wp_rewrite->wp_rewrite_rules();

 Changed it to:

         $rewrite =
 !empty($wp_rewrite)?$wp_rewrite->wp_rewrite_rules():false;

 and things seem to work.

 Not sure if the true problem is the 3rd party plugin that called this
 function, or WP, but I do think there should be some sort of protection in
 WP from getting a fatal error in this rare circumstance.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/27117>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list