#15771 closed defect (bug) (fixed)
url_to_postid() issues a notice on unmatching url's
Reported by: | dd32 | Owned by: | |
---|---|---|---|
Milestone: | 3.1 | Priority: | normal |
Severity: | normal | Version: | 3.1 |
Component: | General | Keywords: | |
Focuses: | Cc: |
Description
url_to_postid() causes a Notice when the supplied url cannot be found on the site.
This is caused by #15770
Notice: Undefined property: WP_Query::$post in \wp-includes\rewrite.php on line 341
Change History (14)
#3
@
14 years ago
- Version set to 3.1
I considered that, But that matches Attachments as well, I felt it best to leave it how it currently is for now.
#5
@
14 years ago
is_page == is_single | is_page | is_attachment. An attachment is always either is_single or is_page in addition to being is_attachment. |
#6
@
14 years ago
You're probably right then, Changing that to is_singular, or for that matter, anything which specifies we've hit a unique post object, would do.
#8
@
14 years ago
nacin, the source says otherwise:
$this->is_singular = $this->is_single || $this->is_page || $this->is_attachment;
http://core.trac.wordpress.org/browser/trunk/wp-includes/query.php?rev=16854#L1404
#9
follow-up:
↓ 12
@
14 years ago
Right, I'm saying the source there is redundant. is_single XOR is_page will always be true when is_attachment is true. The last part is dead code. (That said, I wouldn't remove it, because it explains what is_singular is supposed to match.)
Again, I may have missed something, but I went through every is_attachment flag in WP_Query and found every one of them to also be paired with is_single or is_page.
I think this ticket is fine as is, also.
#12
in reply to:
↑ 9
@
14 years ago
If we have a general, atomic flag for a particular purpose, I think it should be used. Maybe even use is_singular().
(In [16872]) Check to see if WP_Query has returned any posts before blindly accessing posts. Fixes #15771