[wp-trac] [WordPress Trac] #58141: `wp_post_insert` considers `"0"` as empty content.
WordPress Trac
noreply at wordpress.org
Mon Apr 17 01:04:29 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 | Keywords:
Focuses: |
-------------------------------+-----------------------------
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.
[https://core.trac.wordpress.org/browser/tags/6.2/src/wp-
includes/post.php?marks=4115-4119#L4115 See code reference].
As the code currently uses loose comparisons, the string `"0"` is
considered empty content, to reproduce:
1. Create a new post
2. Switch to code editing view
3. Set the title to `0`
4. Set the content to `0`
5. Attempt to publish the post
6. WordPress with throw an error: Publishing failed. Content, title and
excerpt are empty.
See the attached screen shot.
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.
Props due: @cybr following discussion in
[https://wordpress.slack.com/archives/C02RQBWTW/p1681682924744069 Slack].
--
Ticket URL: <https://core.trac.wordpress.org/ticket/58141>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list