[wp-trac] [WordPress Trac] #30854: `wp_insert_post` doesn't save revision for new published post
WordPress Trac
noreply at wordpress.org
Thu Nov 18 19:00:06 UTC 2021
#30854: `wp_insert_post` doesn't save revision for new published post
-------------------------------------------------+-------------------------
Reporter: JamesDiGioia | Owner:
| adamsilverstein
Type: defect (bug) | Status: assigned
Priority: normal | Milestone: 5.9
Component: Revisions | Version:
Severity: normal | Resolution:
Keywords: has-patch has-unit-tests has- | Focuses:
testing-info needs-testing needs-dev-note |
-------------------------------------------------+-------------------------
Comment (by adamsilverstein):
> It also looks like there are a couple of REST API tests that will need
to be updated. The only one that might be a functionality change we are
concerned about is WP_Test_REST_Revisions_Controller::test_get_item.
Do you see these tests failing?
> It seems like the revision no longer has author information?
Interesting, I would expect that to come from the saved post, but perhaps
it comes from current_user which might not be set for something like an
import. This might be ok in that case. How does it show in the UI? Any
issues when restoring the revision (I wouldn't think so because the author
would become the current user)?
> To account for the custom post statuses, whether a revision is saved
upon a transition from new might best be included as property within
register_post_status()
To be clear, this only effects posts created programmatically (eg an xml
import). when posts are created in the editor UI, ''an initial revision is
already being created''. I'm not sure post types need to opt into this
behavior, this is how revisions should work when have them enabled.
For custom post statuses programmatically created posts, I like the idea
of adding something to register_post_status, as long as the name includes
"programmatic" or "wp_create_post" to make it clear it only effects that.
I agree we should consider new_to_ private, future and pending statuses,
these would also be missing an initial revision when importing for
example, vs if you created them in the admin UI. Might apply to every
status, I'll have to check what triggers for a normal draft.
I will do some follow up testing with various post statuses and report
back here .
--
Ticket URL: <https://core.trac.wordpress.org/ticket/30854#comment:41>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list