Opened 12 months ago
#59773 new defect (bug)
WP-Admin post editor JS createPreloadingMiddleware has PHP WP_Query deliver Drafts while in editor they are not
Reported by: | vialars | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 6.3.2 |
Component: | Editor | Keywords: | |
Focuses: | Cc: |
Description
The WP-Admin post editor in its (Gutenberg) content has a (custom Genesis) block whose PHP template uses WP_Query to query other posts.
In this content, WP_Query does not deliver draft posts.
In the head section of the HTML document what the post editor is however, is a WP JS
wp.apiFetch.use( wp.apiFetch.createPreloadingMiddleware( { ... } ) )
and the argument has a property
"\/wp\/v2\/pages\/12?context=edit"
(post types post id is 12) which has a sub-property "rendered" whose value gets filled by PHP from the same template as the post editor content does and in the context of this head JS PHP, the WP_Query does deliver drafts.
This inconsistency lead to us discover an error where a WP PHP function return value was not checked for an error which did occur with a draft but not a "real" post.
However I bring this to your attention. You perhaps might want to 1. use one and only one and the same PHP call and 2. in that call set the context according to your documentation whether drafts are considered or not.