[wp-trac] [WordPress Trac] #37441: get_default_post_to_edit() function is broken

WordPress Trac noreply at wordpress.org
Sun Aug 31 19:44:15 UTC 2025


#37441: get_default_post_to_edit() function is broken
-------------------------------------------------+-------------------------
 Reporter:  tfrommen                             |       Owner:  (none)
     Type:  defect (bug)                         |      Status:  reopened
 Priority:  normal                               |   Milestone:  Future
                                                 |  Release
Component:  Posts, Post Types                    |     Version:  5.6
 Severity:  normal                               |  Resolution:
 Keywords:  has-test-info good-first-bug has-    |     Focuses:
  patch needs-unit-tests changes-requested       |  administration
-------------------------------------------------+-------------------------
Changes (by SirLouen):

 * keywords:  has-test-info good-first-bug has-patch =>
     has-test-info good-first-bug has-patch needs-unit-tests changes-
     requested


Comment:

 Replying to [comment:6 siliconforks]:
 > [https://github.com/WordPress/wordpress-develop/pull/9681 PR #9681] is
 not really what I had in mind for addressing this issue.  I was thinking
 it would be best to do what was described in
 [https://core.trac.wordpress.org/ticket/37441#comment:3 this comment] -
 i.e., try to set the second argument to `wp_insert_post()` to `true` in
 order to (hopefully) get a meaningful error message.  (Then you could just
 call `wp_die()` with that error message.)

 Yep, I think I explained
 [https://core.trac.wordpress.org/ticket/37441?replyto=6#comment:3 it
 here]. @rishabhwp please review this again. We think its much easier than
 your proposed solution.

 Also I've been thinking if a Unit Test is worthy here, that triggers at
 least the error. I believe that I will add as a personal "policy" to
 figure out a unit test if anything can manually tested. In this case is
 pretty straight forward: adding the hook like commented above, and then
 checking for the specific `WP_Error` happening.

 [https://github.com/WordPress/wordpress-
 develop/blob/da59c19dcaae731f64c9f512d35157e356e25931/tests/phpunit/tests/auth.php#L1659-L1665
 Something like this]

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


More information about the wp-trac mailing list