[wp-trac] [WordPress Trac] #44773: Non Existing Child Page of Custom Post Redirects Instead of 404

WordPress Trac noreply at wordpress.org
Mon Aug 13 17:20:11 UTC 2018


#44773: Non Existing Child Page of Custom Post Redirects Instead of 404
---------------------------+------------------------------
 Reporter:  Asitha         |       Owner:  (none)
     Type:  defect (bug)   |      Status:  new
 Priority:  normal         |   Milestone:  Awaiting Review
Component:  Rewrite Rules  |     Version:  4.9.8
 Severity:  critical       |  Resolution:
 Keywords:  needs-patch    |     Focuses:
---------------------------+------------------------------

Comment (by shariqkhan2012):

 I just had a cursory look and it appears that the problem could be in the
 function **redirect_guess_404_permalink** in file ''wp-
 includes/canonical.php''.

 For the case mentioned in the bug description the query comes out to be:


 {{{
 select * from $wpdb->posts where post_name like 'child' and
 post_type='events' and post_status='publish'

 }}}

 I am yet to do a more detailed debugging, but it looks odd to me why the
 query does not put the constraint of **post_parent** in the **where**
 condition.

 Because of the missing **post_parent** clause, the query returns the first
 post it gets which has a slug 'child', which is clearly not correct in
 this case.

 I am new to debugging core, so I don't have the faintest idea of the
 reason behind this, and what elase could break if we add the post_parent
 condition-check.

 Need feedback for this.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/44773#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list