Opened 2 years ago
Last modified 7 months ago
#17115 new defect (bug)
Publishing an empty post results in success
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Administration | Version: | 3.1 |
| Severity: | normal | Keywords: | needs-patch |
| Cc: | eddie@…, trepmal@… |
Description
Steps to reproduce:
- Go to Add New post screen
- Publish post
- Success message is displayed with link to initial auto-draft of post
The issue can be traced back to the editpost switch case in post.php (line 204), which calls edit_post() and redirect_post().
edit_post() saves any meta values passed with the post to the auto-draft, which isn't necessarily desirable, and returns the auto-draft post ID.
redirect_post() then defaults to status message code 6 which incorrectly reports success in publishing.
Attachments (2)
Change History (13)
comment:2
dd32
— 21 months ago
This sounds like it might even be a duplicate/new behaviour of #11082
comment:3
eddieringle
— 21 months ago
- Cc eddie@… added
- Keywords has-patch added; needs-patch removed
Attached a diff that disables the submit buttons in the posting form. As soon as the user changes the contents of the title field and clicks off (causing the title field to lose focus), some background JS re-enables the submit inputs. (Just to clarify, all the diff does is initially disable the submit input elements).
comment:4
dd32
— 21 months ago
By the look of that, the elements are disabled in HTML to start with? That will cause problems for non-js/accessible modes. Best bet would be to disable them via JS when loading the document if we took that route.
comment:5
eddieringle
— 21 months ago
Ah, hadn't thought of that. Why don't we just validate the title and content fields and return a message if said validation fails?
comment:6
follow-up:
↓ 7
eddieringle
— 21 months ago
New diff disables the submit inputs through JS as suggested above. Appears to work nicely.
comment:7
in reply to:
↑ 6
kawauso
— 21 months ago
Replying to eddieringle:
New diff disables the submit inputs through JS as suggested above. Appears to work nicely.
Good to see some life on this ticket. The new diff works fine for the HTML mode, but doesn't seem to work with TinyMCE / the visual editor. Also for future reference, you only need to provide a diff for the .dev version.
comment:8
eddieringle
— 21 months ago
Works for me in both editors.
comment:9
SergeyBiryukov
— 19 months ago
Related: #11082
comment:10
SergeyBiryukov
— 7 months ago
#22483 was marked as a duplicate.
comment:11
trepmal
— 7 months ago
- Cc trepmal@… added
- Keywords needs-patch added; has-patch removed
Two primary issues I see with the JS method:
- Prematurely enables the update button if a non-crucial (title, content, excerpt) element is changed. For example, custom fields. (Mentioned in my dupe ticket #22483)
- Doesn't enable the button if only a featured image is added
I suspect there are also accessibility issues with a button that can only be used after being enabled (undisabled?) via javascript - but that is far from any area of expertise I may have.
The root of the problem seems to come from WordPress not allowing new posts without a title, content, and excerpt (http://core.trac.wordpress.org/browser/trunk/wp-includes/post.php#L2701).
While it may be correct for WordPress to not allow publishing a post without title/content, I think draft posts still need to be allowed. Someone may very well want to first upload and nice featured image and preview the post before adding anything else, and they cannot currently do so.
I'm not sure of the best way to go about patching this, but I'm going to tinker around and see what I can put together that makes any kind of sense to the user.
It seems like this would be best solved in the front-end Javascript. Just a simple check that disables the Publish button until you've made a change to something on the page.