[wp-trac] [WordPress Trac] #30854: `wp_insert_post` doesn't save revision for new published post

WordPress Trac noreply at wordpress.org
Sat Jun 5 07:00:08 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.8
Component:  Revisions                 |     Version:
 Severity:  normal                    |  Resolution:
 Keywords:  has-patch has-unit-tests  |     Focuses:
--------------------------------------+------------------------------

Comment (by Clorith):

 Applied patch from [https://github.com/WordPress/wordpress-
 develop/pull/1336 PR 1336] and it does create appropriate revisions for
 _new_ topics that area created, but as indicated in my initial reply, it
 does not account for _existing_ posts, which is part of the bigger issue
 here.

 Since revisions are enabled per post type with the `supports` section of
 `register_post_type`, I would expect the fix here to work for existing and
 new content alike when `revisions` is added as a supported feature of the
 given post type.

 --

 For anyone else looking to work on, and test this, the steps to test it
 (may be of interest to @hellofromTonya and the testing efforts she's
 heading up):

 To start off, you need a test site with the
 [https://wordpress.org/plugins/bbpress/ bbPress plugin] installed, using
 it for testing, since it has an interface, and is part of the WordPress
 project.

 Some additional information, this bug is only applicable when _not_ using
 the post editor in the wp-admin back-end, this is why using bbPress is
 convenient, since it calls the functions from the front-end and as such is
 able to replicate the bug reliably from a UI point of view as well.

 Create a Forum, since we need a place to create the topics.

 Throughout testing I will be using primarily two texts:

 Original content:
 - Title: `Test topic #N` (increasing the number with each test I make)
 - Post content: `Post with initial content`

 Edited content:
 - Title: (no change)
 - Post content: `Post with modified content`

 Now visit the front-end of your forum, create a new topic with the
 **Original content** from above.

 After editing, click the `Edit` link in the forum topic, and replace your
 content with the **Edited content** from above.

 If you visit the back-end and look in the `Topics` post type, you should
 see your new topic, but if you open it for editing in the back-end, no
 revisions section will show up, as there are no revisions yet.

 In the front-end, edit the post a third time, this time enter any text you
 like, at this point it does not matter what is used, as we have our two
 baseline texts above.

 Visit the back-end again and look at your topic, this time you will see
 revisions show up, but if you click in to look at them, you will see that
 there is one revision less than the total amount of edits and the original
 creation combined, and if you browse the revisions, you will not find the
 `Post with initial content` string, as the entry with `Post with modified
 content` is considered the first post.

 After the patch is applied, if you complete the same steps above, you
 should see the correct amount of revisions (the total amount of edits you
 made plus one for the initial topic), and you should also see that the
 very first revision is the `Post with initial content` text.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/30854#comment:24>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list