WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#13125 closed defect (bug) (fixed)

?p=xxx no longer redirects to ?page_id=xxx for Pages

Reported by: ryan Owned by: markjaquith
Milestone: 3.0 Priority: normal
Severity: blocker Version: 3.0
Component: Canonical Keywords: has-patch tested
Focuses: Cc:

Description

WP 2.9 redirects ?p= requests for pages to a ?page_id request. 3.0 issues a 404 instead.

Attachments (3)

13125.patch (1.0 KB) - added by solarissmoke 4 years ago.
Redirect p=NNN requests to page_id=NNN when a page with that ID exists
13125-2.patch (960 bytes) - added by night815 4 years ago.
small format changes to adhere to the coding standards
13125-3.patch (1003 bytes) - added by solarissmoke 4 years ago.
Don't attempt to redirect to revisions

Download all attachments as: .zip

Change History (14)

comment:1 ryan4 years ago

demetris tracked this down to [13315], which looks to have done this purposefully. I think a canonical redirect would be nice here.

comment:2 solarissmoke4 years ago

  • Keywords has-patch added

How does this patch look? It works for me, both with/without pretty permalinks enabled.

solarissmoke4 years ago

Redirect p=NNN requests to page_id=NNN when a page with that ID exists

night8154 years ago

small format changes to adhere to the coding standards

comment:3 night8154 years ago

  • Keywords tested added

I added a new patch that change "if(" to "if (". I did notice that your patch seemed to add an extra line at the end of the file. my patch doesn't even though it's still in my file. Is this because the trunk was already updated with that change?

anyways, I also tested this patch and it works.

comment:4 nacin4 years ago

The line at the end of the file is just line endings. It gets cleaned up upon commit.

comment:5 dd324 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [14355]) Serve a canonical redirection for ?p=, ?page_id=, ?attachment_id= url's for incorrect post_types (ie. ?p=<page_id> will redirect to that page url). Fixes #13125

comment:6 dd324 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

Needs some more changes here, Specifically, ?p=<revision_ID> will attempt a redirect to invalid url's (Or at least, url's that the user should not see):
{{
?p=5 redirects to http://localhost/wordpress-commit/index.php/blog/2010/05/3-revision/
}}}

solarissmoke4 years ago

Don't attempt to redirect to revisions

comment:7 solarissmoke4 years ago

Patch to check for revisions - although:

Are post revisions ever meant to be directly accessible? (the only way I can currently find to access them is through the diff viewer). If not, then link-template.php could be modified to check for this along with drafts/auto-drafts/pending:

Line 117

if ( '' != $permalink && !in_array($post->post_status, array('draft', 'pending', 'auto-draft')) && 'revision' != $post->post_type )

comment:8 nacin4 years ago

Those post_status checks should instead use get_post_stati.

comment:9 ryan4 years ago

  • Severity changed from normal to blocker

comment:10 ryan4 years ago

(In [14595]) Attempt canonical redirect only for public post types. Props solarissmoke. see #13125

comment:11 ryan4 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

Good enough? Reopen if there's more that needs to be done.

Note: See TracTickets for help on using tickets.