WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#14299 closed defect (bug) (fixed)

get_post_permalink incorrect documentation and variable name

Reported by: filosofo Owned by:
Milestone: 3.0.1 Priority: normal
Severity: normal Version: 3.0
Component: Posts, Post Types Keywords: has-patch
Focuses: Cc:

Description

Says an argument is an ID when it could be either an ID or an object.

Attachments (2)

incorrect_doc_and_variable_name.14299.diff (1.4 KB) - added by filosofo 4 years ago.
make_argument_actually_integer_but_keep_filter.14299.diff (810 bytes) - added by filosofo 4 years ago.

Download all attachments as: .zip

Change History (8)

comment:1 nacin4 years ago

#14294

Makes sense we should ensure the filter always returns an ID, I think. Or maybe always a post object. Not sure which is more expected.

comment:2 filosofo4 years ago

Should always be a post object, so we can use the same callbacks we have on post_link.

That's how I discovered this issue: I was about to create a new callback to handle filtering a custom object type with post_type_link instead of post_link (as the plugin had prior to 3.0), but then I discovered in fact I could just use the existing callback and attach it to post_type_link.

comment:3 filosofo4 years ago

make_argument_actually_integer_but_keep_filter.14299.diff is probably a better approach: it keeps the stated argument value for get_post_permalink as an integer and consistently uses it as such, but explicitly passes the post object to the filter.

comment:4 nacin4 years ago

I like the latest approach.

comment:5 nacin4 years ago

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

(In [15411]) get_post_permalink() should take a post ID and pass the post object to the filter. Note that the filter received a post object previously as the variable. props filosofo, fixes #14299 for trunk.

comment:6 nacin4 years ago

(In [15412]) get_post_permalink() should take a post ID and pass the post object to the filter. Note that the filter received a post object previously as the variable. props filosofo, fixes #14299 for 3.0.

Note: See TracTickets for help on using tickets.