Opened 17 years ago
Closed 17 years ago
#7976 closed defect (bug) (fixed)
Old Slug Redirect fails with Close Old Comments enabled
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | 2.7 | Priority: | highest omg bbq |
| Severity: | blocker | Version: | 2.7 |
| Component: | General | Keywords: | has-patch tested commit |
| Focuses: | Cc: |
Description
I was have a problem with Old slug redirects, and passed most of them off as server errors. But that is not the case.
Currently on the site, I have a custom structure for posts: /blog/%year%/%monthnum%/%day%/%postname%/
Remember that 'blog' is a static page holding the posts as well. The example to explain the problem is this.
Currently, I have this post, http://bugssite.org/blog/2008/07/28/left-4-dead-preview/. As you can see it goes to the post. The old slug for this post was "http://bugssite.org/blog/2008/07/28/left-4-dead/" but if you goto this link it shows the "single" page layout with nothing. It's not a '404' error as needed for old_slug checking.
I think the reason is that because /blog/ is a 'static page' and it is valid. If you do "http://bugssite.org/2008/07/28/left-4-dead/" or even "http://bugssite.org/left-4-dead/" it redirects to the correct page of "http://bugssite.org/blog/2008/07/28/left-4-dead-preview/"
Attachments (1)
Change History (10)
#2
@
17 years ago
I just confirmed it works as expected for me using the same permalink structure.
At first, I had an issue with a custom rewrite rule i've got in place, But once i delt with that, The redirection works for me as expected.
Throw some debug lines in around these locations:
wp_old_slug_redirect (): query.php line 2600 WP Class: classes line 210
to see what rewrite rule's being matched, and all that, you might find something funky in your rewrite rules.
#4
@
17 years ago
Here is $wp_query from "http://bugssite.org/blog/2008/07/28/left-4-dead/":
WP_Query Object
(
[query_vars] => Array
(
[year] => 2008
[monthnum] => 7
[day] => 28
[name] => left-4-dead
[error] =>
[m] => 0
[p] => 0
[post_parent] =>
[subpost] =>
[subpost_id] =>
[attachment] =>
[attachment_id] => 0
[hour] =>
[static] =>
[pagename] =>
[page_id] => 0
[second] =>
[minute] =>
[w] => 0
[category_name] =>
[tag] =>
[cat] =>
[tag_id] =>
[author_name] =>
[feed] =>
[tb] =>
[paged] =>
[comments_popup] =>
[meta_key] =>
[meta_value] =>
[preview] =>
[category__in] => Array
(
)
[category__not_in] => Array
(
)
[category__and] => Array
(
)
[post__in] => Array
(
)
[post__not_in] => Array
(
)
[tag__in] => Array
(
)
[tag__not_in] => Array
(
)
[tag__and] => Array
(
)
[tag_slug__in] => Array
(
)
[tag_slug__and] => Array
(
)
[caller_get_posts] =>
[suppress_filters] =>
[post_type] => post
[posts_per_page] => 7
[nopaging] =>
[comments_per_page] => 20
[order] => DESC
[orderby] => posts.post_date DESC
)
[request] => SELECT posts.* FROM posts WHERE 1=1 AND YEAR(posts.post_date)='2008' AND MONTH(posts.post_date)='7' AND DAYOFMONTH(posts.post_date)='28' AND posts.post_name = 'left-4-dead' AND posts.post_type = 'post' ORDER BY posts.post_date DESC
[post_count] => 1
[current_post] => -1
[in_the_loop] =>
[post] => stdClass Object
(
[comment_status] => closed
[ping_status] => closed
)
[comments] =>
[comment_count] => 0
[current_comment] => -1
[comment] =>
[found_posts] => 0
[max_num_pages] => 0
[max_num_comment_pages] => 0
[is_single] => 1
[is_preview] =>
[is_page] =>
[is_archive] =>
[is_date] =>
[is_year] =>
[is_month] =>
[is_day] =>
[is_time] =>
[is_author] =>
[is_category] =>
[is_tag] =>
[is_tax] =>
[is_search] =>
[is_feed] =>
[is_comment_feed] =>
[is_trackback] =>
[is_home] =>
[is_404] =>
[is_comments_popup] =>
[is_admin] =>
[is_attachment] =>
[is_singular] => 1
[is_robots] =>
[is_posts_page] =>
[is_paged] =>
[query] => Array
(
[year] => 2008
[monthnum] => 07
[day] => 28
[name] => left-4-dead
)
[posts] => Array
(
[0] => stdClass Object
(
[comment_status] => closed
[ping_status] => closed
)
)
)
404 Error Returns: 0
$wp_query->query_vars['name'] is: left-4-dead
#5
@
17 years ago
- Priority changed from high to highest omg bbq
- Severity changed from critical to blocker
Ok. The reason why it will not work is because 'Close old posts after X" was enabled. Once it was disabled it worked fine.
#6
@
17 years ago
[posts] => Array
(
[0] => stdClass Object
(
[comment_status] => closed
[ping_status] => closed
)
)
To me, It looks like the close comments on old posts is kicking in and breaking it, ShaneF confirmed on IRC that disabling that functionality allowed it to work.
attachment 7976.diff added.
- Returns early if $posts is empty
- Untested locally; ShaneF, feel like testing for me?
Judging from the IRC chat, I take is_404 is not being set?
If the issue is that the 404 is not being set, then that'd have the flow on effect of the redirection code not kicking in i believe.