[wp-trac] [WordPress Trac] #58141: `wp_post_insert` considers `"0"` as empty content.

WordPress Trac noreply at wordpress.org
Mon Apr 17 13:37:06 UTC 2023


#58141: `wp_post_insert` considers `"0"` as empty content.
-------------------------------+------------------------------
 Reporter:  peterwilsoncc      |       Owner:  (none)
     Type:  defect (bug)       |      Status:  new
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  Posts, Post Types  |     Version:  3.3
 Severity:  normal             |  Resolution:
 Keywords:                     |     Focuses:
-------------------------------+------------------------------

Comment (by ugyensupport):

 == Bug Report
 === Description
 The wp_insert_post function includes a check to prevent the publishing of
 empty posts. A post is considered empty if the title, excerpt and content
 are undefined on post types that support all three items.

 === Environment
 - WordPress: 6.2
 - PHP: 8.0.0
 - Server: Apache/2.4.10 (Debian)
 - Database: mysqli (Server: 5.5.59-MariaDB-1~wheezy / Client: 5.5.62)
 - Browser: Chrome 112.0.0.0 (macOS)
 - Theme: Twenty Twenty-Three 1.1 ----> Twenty Twenty-Fourteen
 - MU-Plugins: None activated
 - Plugins:
   *  Gutenberg 15.5.1

 === Steps to Reproduce
 1. As the code currently uses loose comparisons, the string "0" is
 considered empty content,
    to reproduce:
 2. Create a new post
 3. Switch to code editing view
 4. Set the title to 0
 5. Set the content to 0
 6. Attempt to publish the post
 WordPress with throw an error: Publishing failed. Content, title and
 excerpt are empty.
 x. 🐞 Bug occurs.: While 0 isn't great content, it is content so WordPress
 should allow the publishing of articles with this. Converting the tests to
 strict checks against an empty string should resolve the issue. and In
 regard to WordPress 6.2 + Twenty Twenty-Three 1.1 It only display the
 content but not title.

 Screencast : [WordPress 6.2 not displaying post title, if we set Post
 Title to 0] [https://www.loom.com/share/b69bace69b1142978bad6f9bad415ec9]

 === Expected Results
 1.  ✅ Should View both the content and Post title in any versions of
 WordPress, importantly current version of WordPress.

 === Actual Results
 1.  ❌ In conclusion I could see that the issue is due to the classic
 editor with WordPress 4.9 as I don't see major blocks with WordPress 5.0
 and above as mentioned by @peterwilsoncc
 Having said that I could see a minor block with WordPress 6.2 + Twenty
 Twenty-Three 1.1 as after we published the wordpress site with title and
 content "0" could only view content but not the Post Title.

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


More information about the wp-trac mailing list