[wp-trac] [WordPress Trac] #59773: WP-Admin post editor JS createPreloadingMiddleware has PHP WP_Query deliver Drafts while in editor they are not
WordPress Trac
noreply at wordpress.org
Tue Oct 31 11:17:33 UTC 2023
#59773: WP-Admin post editor JS createPreloadingMiddleware has PHP WP_Query deliver
Drafts while in editor they are not
--------------------------+-----------------------------
Reporter: vialars | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Editor | Version: 6.3.2
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
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.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/59773>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list