Make WordPress Core

Opened 13 years ago

Closed 13 years ago

#16688 closed defect (bug) (fixed)

Inconsistent 'the_title' filter

Reported by: jfarthing84's profile jfarthing84 Owned by: markjaquith's profile markjaquith
Milestone: 3.3 Priority: normal
Severity: normal Version: 3.1
Component: General Keywords: dev-feedback has-patch
Focuses: Cc:


In most places, 'the_title' filter passes two arguments, the title being filtered and the post ID. This is the desirable situation.

However, there are a few places in core code that do not pass the second argument while utilizing 'the_title' filter. This inconsistency is causing notices from my plugin because it expects the second argument in a callback attached to the filter.

Attachments (3)

changes.diff (1.0 KB) - added by jfarthing84 13 years ago.
16688.diff (2.0 KB) - added by GaryJ 13 years ago.
Adds missing ID filter args, amends args in deprecated functions using post object to post ID
16688.2.diff (2.4 KB) - added by markjaquith 13 years ago.

Download all attachments as: .zip

Change History (9)

13 years ago

#1 @jfarthing84
13 years ago

  • Keywords has-patch added

#2 @GaryJ
13 years ago

+1 on this - my plugin is experiencing exactly the same warnings due to this inconsistency. Of the 14 instances of the_title filter being applied currently in trunk, two of them don't pass the ID along, which the patch fixes.

#3 @SergeyBiryukov
13 years ago

  • Milestone changed from Awaiting Review to 3.3

For some reason previous_post() and next_post() pass the whole $post object instead of $post->ID:

Though they are both deprecated, I wonder if that should be fixed too.

Related changeset: [2227]

13 years ago

Adds missing ID filter args, amends args in deprecated functions using post object to post ID

#4 @GaryJ
13 years ago

Well, next_post() is trying to pass in $nextpost as the second argument - and that doesn't appear to be defined anywhere in that function. I assume it's supposed to be $post (and then as per your comment, $post->ID). Patch attached in case this is decided to be fixed as well, though there will be an obvious backwards compatibility concern.

13 years ago

#5 @markjaquith
13 years ago

Just got rid of the pointless $arc_title variable and used $arcresult->post_title instead.

#6 @markjaquith
13 years ago

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

In [18907]:

Always pass the post ID as the second argument to the the_title filter. props GaryJ. fixes #16688

Note: See TracTickets for help on using tickets.