[wp-trac] [WordPress Trac] #44975: REST API support switching draft to unscheduled
WordPress Trac
noreply at wordpress.org
Mon Sep 23 15:48:21 UTC 2019
#44975: REST API support switching draft to unscheduled
-------------------------------------------------+-------------------------
Reporter: mnelson4 | Owner:
| adamsilverstein
Type: feature request | Status: assigned
Priority: normal | Milestone: 5.3
Component: REST API | Version: 4.7
Severity: normal | Resolution:
Keywords: has-patch 2nd-opinion has-unit- | Focuses:
tests |
-------------------------------------------------+-------------------------
Comment (by TimothyBlynJacobs):
Thank you for the feedback @Rarst!
> However underlying concept of null date in core is a mess.
In the patch we specifically set `post_date` and `post_date_gmt` to `null`
if the REST request parameter value is `null`. However, we could instead
set that to `0000-00-00 00:00:00` if that'd be better. AFAICT, they are
handled the [https://github.com/WordPress/wordpress-
develop/blob/82bded36f83fddd1d577c9c573ea3e05fe5a70ee/src/wp-
includes/post.php#L3689 same].
> So I suppose... If you want to literally zero a date then send null and
call it done. Something is probably broken about it though.
Yeah, we want the field in the DB to be set zeroed. The `null` value isn't
persisted beyond the API layer. Do you have ideas what might be broken?
IIRC from when we were researching this last year, it looks like passing
an "empty" value to `wp_insert_post` is the correct way to do this?
> Actual solution would really be designing a proper state of the post for
this and how it transitions, which very likely would need to be dedicated
and explicit, not derived from date fields.
Did you see @kadamwhite's
[https://core.trac.wordpress.org/ticket/44975#comment:5 comment]?
-----
> 44975.5.diff​ worked for null in my testing - sending a null value for
date_gmt reset the date correctly.
Awesome!
> One question: is the intention to also allow an empty string to reset or
only null?
Yeah, after
[https://wordpress.slack.com/archives/C02RQC26G/p1568915524059800
discussing in #core-restapi] we'll only allow `null` and not try to
convert an empty string to `null`. This also matches behavior of how we
handle `null` in other endpoints like Settings and Meta fields.
-----
Something I noticed when looking at the patch again, I think we need to
check against the item schema for`$schema['properties']['date(_gmt)']` the
same way we do for the regular post date updates. I uploaded a patch to
add that.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/44975#comment:34>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list