I ran into the same error as above in WP 2.6.2 Fatal error: Call to a member function query() on a non-object in /wp-admin/includes/template.php on line 557
Problem ended up being with a post that was partially saved to the database. Deleting the following row from the wp_posts table resolved the issue.
mysql> select * from wp_posts \G
*************************** 8. row ***************************
ID: 0
post_author: 1
post_date: 0000-00-00 00:00:00
post_date_gmt: 0000-00-00 00:00:00
post_content:
post_title: Dealer Info
post_category: 0
post_excerpt:
post_status: draft
comment_status: open
ping_status: open
post_password:
post_name:
to_ping:
pinged:
post_modified: 2008-10-03 20:54:32
post_modified_gmt: 2008-10-04 02:54:32
post_content_filtered:
post_parent: 0
guid:
menu_order: 0
post_type: page
post_mime_type:
comment_count: 0
8 rows in set (0.00 sec)