Opened 15 years ago
Closed 11 years ago
#11082 closed defect (bug) (invalid)
Saving an empty draft dumps user out to edit.php
Reported by: | markel | Owned by: | akhilasuram |
---|---|---|---|
Milestone: | Priority: | low | |
Severity: | minor | Version: | 2.7 |
Component: | Editor | Keywords: | needs-refresh |
Focuses: | Cc: |
Description
ENV: wp trunk r12138 (2.9-rare)
When a user starts up the editor for a new post and attempts to save a post with no title and no content, WordPress dumps the user back out to the list of posts in edit.php with no message or indication as to why this happened. You can edit the publish information (date, status, etc.), tags, and categories, but as long as there is nothing for either the post title or the post content, the behavior is the same.
It's expected that a post with no content whatsoever wouldn't be saved (there's nothing there!), but would be nice if the behavior were easier to understand or explained why nothing was happening.
Attachments (9)
Change History (51)
#1
@
15 years ago
- Keywords needs-patch added; confusing ux draft publish removed
- Milestone changed from Unassigned to 3.0
#7
in reply to:
↑ 5
@
15 years ago
- Keywords needs-patch added; has-patch removed
Replying to akhilasuram:
It doesn't look like you have changed the correct bit of code here.
I think Ryans comments may help you focus in on the piece of code that needs fixing do you want to have another go?
#8
@
15 years ago
Here's a quick patch for the post part that I think handles the root cause. Try that out and extend the patch to cover pages if you like it.
#9
follow-up:
↓ 10
@
15 years ago
- Status changed from accepted to assigned
Thanks for guidance.I 'll write a patch for it.
#15
@
15 years ago
- Keywords needs-patch added; has-patch removed
We would need die() or exit() statements after any wp_redirect() calls.
Also, you're going to want to svn up
, as some files you have patched no longer exist -- some big changes occurred recently (see also #9674).
#17
@
15 years ago
- Keywords needs-patch added; has-patch removed
Patch is already stale due to [12728] :)
Here's what is needed:
- A second new string in edit-form-advanced.php, for pages.
- Whitespace improvements here:
if( 0== $post_id ){
(See ryan's patch.) - Intendation improvements. (See ryan's patch.)
- Don't remove the
default:
logic.
#22
follow-up:
↓ 24
@
15 years ago
- Cc idealien added
Tested with r13709 for both posts and pages doing both save draft and publish. In each case the expected result was performed - no posts / pages were added to the edit view. However, the status message received - i.e. "Page published. View Page" - was not consistent with what actually occured. Perhaps an additional status message should be added?
Suggestions:
-"[Post / Page] without any title or content will not be saved."
-"[Post / Page] not published. A minimum of title and/or content is required."
#23
@
15 years ago
hi idealien, i could not follow your comment. As far as the status message is concerned I m getting it as "You attempted to save or publish an empty post. Provide some content before saving." for an empty post and "You attempted to save or publish an empty page. Provide some content before saving." for an empty page. Can you please explain the issue with the patch more clearly. Thank you.
#25
@
15 years ago
- Keywords needs-refresh added
Latest patch is not against trunk, also, other files are missing from it.
#26
follow-up:
↓ 27
@
15 years ago
- Keywords needs-testing added; needs-refresh removed
- Version changed from 2.9 to 2.7
Patch decides if post is new by checking if $_POST['auto_draft']
is set to '1'.
Requires the following (line 147 in wp-includes/autosave.dev.js):
if(postID==parseInt(jQuery("#post_ID").val(),10)){return}
to be removed from wp-includes/autosave.js, because otherwise auto_draft field is not set to '0' on autosave, so new posts with a title, content, etc. are classified as emptied (patch in related ticket #12859 also contains this fix for the same reason).
Only minimal testing with custom post types, so not sure how well it works with them. Even so, I noticed that it wouldn't work with a custom post type which didn't support 'title' and 'editor' as an autosave is not performed:
wp_nonce_field( 'autosave', 'autosavenonce', false );
is not called by edit-form-advanced.php unless an editor is included and a title is needed to trigger an autosave. Therefore, the auto_draft field is not set to '0'. (I decided to post this even in light of this as it might help someone else)
(Version bumped back to 2.7 as this behaviour existed then.)
#27
in reply to:
↑ 26
@
15 years ago
Replying to duck_:
Only minimal testing with custom post types, so not sure how well it works with them. Even so, I noticed that it wouldn't work with a custom post type which didn't support 'title' and 'editor' as an autosave is not performed
See #12867 for patch; patch for this ticket should be good.
#28
@
15 years ago
- Keywords needs-refresh added; needs-testing removed
Tested with r14233 and encountered conflicts to applying the patch specific to the edit-form-advanced.php file changes. Two blocks between lines 30 - 60 were source of issue that needs to be refreshed.
<demetris> Idealien: I am not familiar with that patch, but the conflicts most likely mean that something changed in core AFTER the patch was made, and now the patch will have to be refreshed.
<duck_> I wrote that patch, and yes probably needs a refresh then
#30
@
15 years ago
- Keywords needs-work added
The patch needs additional work.
The new message is showing up in all post use cases, not just the expected one(s):
-Title / Editor both empty = No Draft Saved -> As expected
-Title empty / Editor has content = Draft Saved -> Default messaging expected
-Title has content / Editor empty = Draft Saved -> Default messaging expected
-Title / Editor both have content = Draft Saved -> Default messaging expected
Should not be applied to 3.0 based on current state.
#31
@
15 years ago
- Keywords needs-testing added; needs-work removed
Problem was that you were entering content/title without an autosave occurring so the post was still being treated as auto-draft. Update solves this by setting $_POST['auto_draft']
to 0 at the end of the edit_post function. Should all work now...
#32
@
15 years ago
- Keywords needs-work added; needs-testing removed
Oops, probably should've had more sleep, just realised the 'fix' broke what I was fixing in the first place...
#34
@
15 years ago
When I updated to todays trunk, whenever I click update for the post or page (with or without changes made), I am redirected to this url:
/edit.php#038;action=edit
Not sure if it's directly related to this, but it might be.
#36
@
15 years ago
- Keywords has-patch added; needs-patch removed
New patch tests for status being 'auto-draft'.
#39
@
14 years ago
- Keywords needs-refresh added; has-patch removed
- Milestone changed from Awaiting Triage to Future Release
Patch should need a refresh.
#41
follow-up:
↓ 42
@
12 years ago
- Cc mdhansen@… added
The current behavior of saving a post with no title or content is it stays on post.php and shows message "Post published. View post" yet no post exists in the all post list or in the preview from "View Post" link. So, in summary it still seems to be a problem just slightly different and just as confusing.
#42
in reply to:
↑ 41
@
11 years ago
- Milestone Future Release deleted
- Resolution set to invalid
- Status changed from assigned to closed
Replying to MikeHansenMe:
The current behavior of saving a post with no title or content is it stays on post.php and shows message "Post published. View post" yet no post exists in the all post list or in the preview from "View Post" link.
So it appears to me as well, which is what #17115 is reporting, so I'm going to close this, noting that the last patch from duck_ seems like it might still be relevant.
When the 'post' action is processed we end up with a post_ID of 0. redirect_post() doesn't handle a 0 post ID properly. redirect_post() needs to be fixed.