#17034 closed defect (bug) (fixed)
E_NOTICE with WP_DEBUG when calling get_the_ID()
Reported by: | tillkruess | Owned by: | wonderboymusic |
---|---|---|---|
Milestone: | 4.0 | Priority: | normal |
Severity: | minor | Version: | 3.1 |
Component: | Posts, Post Types | Keywords: | |
Focuses: | Cc: |
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)
#2
@
13 years ago
- Milestone Awaiting Review deleted
- Resolution set to wontfix
- Status changed from new to closed
#3
follow-up:
↓ 4
@
11 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
@
11 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
@
10 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
@
10 years ago
- Milestone set to 4.0
- Resolution wontfix deleted
- Status changed from closed to 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
@
10 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?
get_the_ID() should only be called from inside The Loop.