Opened 3 years ago
Closed 3 years ago
#11435 closed defect (bug) (fixed)
Notice when requesting post title of non-existent post
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | 3.0 |
| Component: | General | Version: | 2.9 |
| Severity: | normal | Keywords: | has-patch get_the_title tested |
| Cc: |
Description
If you try to get the post title using get_the_title(123), where 123 is not an existing post's ID, you get two notices because get_the_title() tries to access non-existent properties of NULL.
What exacerbates the problem is that the ID passed to the "the_title" filter is based on the (non-existent) ID property of the supposed post object. So filter callbacks can't fully deal with non-existent post title requests, as they do not get the requested ID.
Attachments (1)
Change History (4)
- Keywords tested added
Tested the patch. Does apply clean, works.
The only change compared to the current behaviour is, that for the case $post->post_title was undefined, it now passes an empty string instead of NULL to the various filters. IMHO this is a good to go, otherwise we could default the title to NULL to gain 100% binary compability.

Related: #11521