Opened 6 weeks ago
Closed 6 weeks ago
#65238 closed defect (bug) (duplicate)
Negative post id get_post is always false
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | 6.9.4 |
| Component: | General | Keywords: | |
| Focuses: | Cc: |
Description
Since https://github.com/WordPress/wordpress-develop/commit/450524a5a7a0708875f82ee5e75bb90c04049dbe, (WordPress 6.9?) there is no way to put in references to negative id post. This was used on numerous sites to show posts in the usual way on frontend and queries, without having to create actual posts in the WP database (queries to other systems for example.)
Since WP_Post is a final class, there doesn't seem to be a way to patch this to not return false out of WP_Post::get_instance(). And there isn't a way to set transient external data on a search or result page with
wp_cache_set($nonPostId, new WP_Post($post), 'posts');
as in every version of WordPress before.
I think this is already being requested in #64362.