[wp-trac] [WordPress Trac] #14880: 404 Errors Replaced with Category Pages

WordPress Trac wp-trac at lists.automattic.com
Fri Nov 12 03:57:41 UTC 2010


#14880: 404 Errors Replaced with Category Pages
-------------------------------+--------------------------------------------
 Reporter:  askapache          |        Owner:  scribu  
     Type:  defect (bug)       |       Status:  reopened
 Priority:  normal             |    Milestone:  3.1     
Component:  Press This         |      Version:  3.1     
 Severity:  normal             |   Resolution:          
 Keywords:  reporter-feedback  |  
-------------------------------+--------------------------------------------

Comment(by askapache):

 I was able to add a hack-around to the plugin..
 In the template_redirect it was checking first whether it was a 404 with:

 {{{
 <?php
 if (!is_404() || '1' != $this->options['enabled']) return true;
 ?>
 }}}


 I changed that to

 {{{
 <?php
 if ((!is_404() || '1' != $this->options['enabled']) &&
 !isset($_GET['error'])) return true;
 else $wp_query->set_404();
 ?>
 }}}

 Which works but only because I have set my ErrorDocuments to
 /index.php?error=403 for each status code 400-599, so I know that when
 that query_string is there it's an error.

 The error handling should definately be improved, and I'd like to
 contribute the php error handling function from my plugin, just not sure
 how to go about doing that.

 I found out the main reason that this problem is happening is related to
 the new rewrites.  Specifically the category rewrites are taking over
 every request that isn't specific for another match like /feed works,
 page.html works, etc.. but if it's a 404 or a non-existant page, it
 defaults to showing my featured category, which is basically my home-page.
 Something to do with the category_name since even when I manually do
 ?category_name=windows the wp_query still shows category_name as featured.

 I'm also getting the following warnings with the latest revision:

 PHP Warning:  call_user_func() expects parameter 1 to be a valid callback,
 function 'topic_count_text_callback' not found or invalid function name in
 wp-includes/category-template.php on line 680

 which is the only warning/error I get on my site.


 I'm sure now that the way HTTP errors are recognized by WP can be greatly
 improved, but the real problem is caused by the rewrites.  I wrote the
 askapache rewriterules viewer plugin a couple years ago, and also have
 added debugging to the plugin I'm working on now, and the rewritecode
 definately has gotten better, but it's still incredibly loose.

 I don't use /category/%category%/ permalinks, I created my own plugin a
 couple years ago that uses /%scategory%/%postname%.html,

 Everything is fine, everything works correctly other than askapache.com
 /any-thing-not-explicitly-defined which now always displays my featured
 posts page, without even bothering to redirect to a proper url. Just a 200
 OK and heres my homepage for any 404 page.

 I am sure it's not related to apache or those rules, to check I tried it
 with several versions, on several hosts.  Sorry I'm going on and on..

 So now that I know its the new rewrite code that is doing this, (and I
 realize with a 100% default install it would work), does that mean it's
 not query-related?  As I get further along with the debugging plugin I'm
 working on, I think I can help with some of this, since I'm working on it
 anyway.  Any ideas?  I hate the idea of bugging people, and this isn't a
 small thing to fix or even look at I know.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/14880#comment:22>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list