Opened 2 years ago
Closed 20 months ago
#16688 closed defect (bug) (fixed)
Inconsistent 'the_title' filter
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | 3.3 |
| Component: | General | Version: | 3.1 |
| Severity: | normal | Keywords: | dev-feedback has-patch |
| Cc: | jeff@… |
Description
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)
Change History (9)
jfarthing84 — 2 years ago
comment:1
jfarthing84 — 2 years ago
- Keywords has-patch added
comment:3
SergeyBiryukov — 21 months 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:
http://core.trac.wordpress.org/browser/tags/3.2.1/wp-includes/deprecated.php#L152
Though they are both deprecated, I wonder if that should be fixed too.
Related changeset: [2227]
Adds missing ID filter args, amends args in deprecated functions using post object to post ID
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.
markjaquith — 20 months ago
comment:5
markjaquith — 20 months ago
Just got rid of the pointless $arc_title variable and used $arcresult->post_title instead.
comment:6
markjaquith — 20 months ago
- Owner set to markjaquith
- Resolution set to fixed
- Status changed from new to closed
In [18907]:

+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.