#17034 closed defect (bug) (fixed)
E_NOTICE with WP_DEBUG when calling get_the_ID()
| Reported by: | tillkruess | Owned by: | wonderboymusic |
|---|---|---|---|
| Priority: | normal | Milestone: | 4.0 |
| Component: | Posts, Post Types | Version: | 3.1 |
| Severity: | minor | Keywords: | |
| Cc: | Focuses: |
Description
When get_the_ID() is called, but $post is NULL (for example on a 404 page) a E_NOTICE is caused when WP_DEBUG is set to TRUE.
Attachments (2)
Change History (14)
#3
follow-up:
↓ 4
@
13 years ago
Curious, why should get_the_ID() only be called from inside The Loop? Seems if we addressed the notice issue, it would be a decent way to check if there is a post object available.
#4
in reply to: ↑ 3
;
follow-up:
↓ 7
@
13 years ago
Replying to jtsternberg:
Seems if we addressed the notice issue, it would be a decent way to check if there is a post object available.
get_post() appears to be the correct way to check for that.
#7
in reply to: ↑ 4
;
follow-up:
↓ 8
@
12 years ago
Replying to SergeyBiryukov
get_post()appears to be the correct way to check for that.
get_post() can't be used as well, it returns the ID for the latest post on wp-signup.php, I didn't get the logic for that.
#8
in reply to: ↑ 7
;
follow-up:
↓ 9
@
12 years ago
- Milestone → 4.0
- Resolution wontfix
- Status closed → reopened
Replying to UmeshSingla:
get_post() can't be used as well, it returns the ID for the latest post on wp-signup.php, I didn't get the logic for that.
That sounds like a separate issue.
We could probably reconsider this to avoid the notice. Your patch on #28572 seems good.
#9
in reply to: ↑ 8
;
follow-up:
↓ 10
@
12 years ago
Replying to SergeyBiryukov:
That sounds like a separate issue.
We could probably reconsider this to avoid the notice. Your patch on #28572 seems good.
Yes, I'll try too replicate the get_post() issue, If it confirms, I'll go for a separate ticket and for this ticket do i need to submit the patch here again?
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
get_the_ID() should only be called from inside The Loop.