Index: wp-includes/post.php
===================================================================
--- wp-includes/post.php	(revision 12985)
+++ wp-includes/post.php	(working copy)
@@ -1976,7 +1976,7 @@
 	// Create a valid post name.  Drafts and pending posts are allowed to have an empty
 	// post name.
 	if ( !isset($post_name) || empty($post_name) ) {
-		if ( !in_array( $post_status, array( 'draft', 'pending' ) ) )
+		if ( !in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ) )
 			$post_name = sanitize_title($post_title);
 		else
 			$post_name = '';
@@ -1989,7 +1989,7 @@
 		$post_date = current_time('mysql');
 
 	if ( empty($post_date_gmt) || '0000-00-00 00:00:00' == $post_date_gmt ) {
-		if ( !in_array( $post_status, array( 'draft', 'pending' ) ) )
+		if ( !in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ) )
 			$post_date_gmt = get_gmt_from_date($post_date);
 		else
 			$post_date_gmt = '0000-00-00 00:00:00';
@@ -2089,7 +2089,7 @@
 		$where = array( 'ID' => $post_ID );
 	}
 
-	if ( empty($data['post_name']) && !in_array( $data['post_status'], array( 'draft', 'pending' ) ) ) {
+	if ( empty($data['post_name']) && !in_array( $data['post_status'], array( 'draft', 'pending', 'auto-draft' ) ) ) {
 		$data['post_name'] = sanitize_title($data['post_title'], $post_ID);
 		$wpdb->update( $wpdb->posts, array( 'post_name' => $data['post_name'] ), $where );
 	}
@@ -2172,7 +2172,7 @@
 		$post_cats = $post['post_category'];
 
 	// Drafts shouldn't be assigned a date unless explicitly done so by the user
-	if ( in_array($post['post_status'], array('draft', 'pending')) && empty($postarr['edit_date']) &&
+	if ( in_array($post['post_status'], array('draft', 'pending', 'auto-draft')) && empty($postarr['edit_date']) &&
 			 ('0000-00-00 00:00:00' == $post['post_date_gmt']) )
 		$clear_date = true;
 	else
@@ -2276,7 +2276,7 @@
  * @return string unique slug for the post, based on $post_name (with a -1, -2, etc. suffix)
  */
 function wp_unique_post_slug($slug, $post_ID, $post_status, $post_type, $post_parent) {
-	if ( in_array( $post_status, array( 'draft', 'pending' ) ) )
+	if ( in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ) )
 		return $slug;
 
 	global $wpdb, $wp_rewrite;
Index: wp-includes/js/autosave.dev.js
===================================================================
--- wp-includes/js/autosave.dev.js	(revision 12985)
+++ wp-includes/js/autosave.dev.js	(working copy)
@@ -39,7 +39,7 @@
 
 	// preview
 	$('#post-preview').click(function(){
-		if ( 1 > $('#post_ID').val() && notSaved ) {
+		if ( $('#auto_draft').val() == '1' && notSaved ) {
 			autosaveDelayPreview = true;
 			autosave();
 			return false;
@@ -58,7 +58,7 @@
 	if ( typeof tinyMCE != 'undefined' ) {
 		$('#title')[$.browser.opera ? 'keypress' : 'keydown'](function (e) {
 			if ( e.which == 9 && !e.shiftKey && !e.controlKey && !e.altKey ) {
-				if ( ($("#post_ID").val() < 1) && ($("#title").val().length > 0) ) { autosave(); }
+				if ( ($('#auto_draft').val() == '1') && ($("#title").val().length > 0) ) { autosave(); }
 				if ( tinyMCE.activeEditor && ! tinyMCE.activeEditor.isHidden() && dotabkey ) {
 					e.preventDefault();
 					dotabkey = false;
@@ -70,11 +70,10 @@
 	}
 
 	// autosave new posts after a title is typed but not if Publish or Save Draft is clicked
-	if ( 0 > $('#post_ID').val() ) {
+	if ( '1' == $('#auto_draft').val() ) {
 		$('#title').blur( function() {
-			if ( !this.value || 0 < $('#post_ID').val() )
+			if ( !this.value || $('#auto_draft').val() != '1' )
 				return;
-
 			delayed_autosave();
 		});
 	}
@@ -121,24 +120,19 @@
 
 // called when autosaving pre-existing post
 function autosave_saved(response) {
+	blockSave = false;
 	autosave_parse_response(response); // parse the ajax response
 	autosave_enable_buttons(); // re-enable disabled form buttons
 }
 
 // called when autosaving new post
 function autosave_saved_new(response) {
+	blockSave = false;
 	var res = autosave_parse_response(response), tempID, postID;
-	// if no errors: update post_ID from the temporary value, grab new save-nonce for that new ID
 	if ( res && res.responses.length && !res.errors ) {
-		tempID = jQuery('#post_ID').val();
+		// An ID is sent only for real auto-saves, not for autosave=0 "keepalive" saves
 		postID = parseInt( res.responses[0].id, 10 );
 		autosave_update_post_ID( postID ); // disabled form buttons are re-enabled here
-		if ( tempID < 0 && postID > 0 ) { // update media buttons
-			notSaved = false;
-			jQuery('#media-buttons a').each(function(){
-				this.href = this.href.replace(tempID, postID);
-			});
-		}
 		if ( autosaveDelayPreview ) {
 			autosaveDelayPreview = false;
 			doPreview();
@@ -151,22 +145,11 @@
 function autosave_update_post_ID( postID ) {
 	if ( !isNaN(postID) && postID > 0 ) {
 		if ( postID == parseInt(jQuery('#post_ID').val(), 10) ) { return; } // no need to do this more than once
-		jQuery('#post_ID').attr({name: "post_ID"});
-		jQuery('#post_ID').val(postID);
-		// We need new nonces
-		jQuery.post(autosaveL10n.requestFile, {
-			action: "autosave-generate-nonces",
-			post_ID: postID,
-			autosavenonce: jQuery('#autosavenonce').val(),
-			post_type: jQuery('#post_type').val()
-		}, function(html) {
-			jQuery('#_wpnonce').val(html.updateNonce);
-			jQuery('#delete-action a.submitdelete').attr('href', html.deleteURL);
-			autosave_enable_buttons(); // re-enable disabled form buttons
-			jQuery('#delete-action a.submitdelete').fadeIn();
-		},
-		'json');
+		notSaved = false;
+		autosave_enable_buttons();
+		jQuery('#delete-action a.submitdelete').fadeIn();
 		jQuery('#hiddenaction').val('editpost');
+		jQuery('#auto_draft').val('0'); // No longer an auto-draft
 	}
 }
 
@@ -217,6 +200,7 @@
 
 autosave = function() {
 	// (bool) is rich editor enabled and active
+	blockSave = true;
 	var rich = (typeof tinyMCE != "undefined") && tinyMCE.activeEditor && !tinyMCE.activeEditor.isHidden(), post_data, doAutoSave, ed, origStatus, successCallback;
 
 	autosave_disable_buttons();
@@ -281,6 +265,8 @@
 	if ( jQuery("#post_author").size() )
 		post_data["post_author"] = jQuery("#post_author").val();
 	post_data["user_ID"] = jQuery("#user-id").val();
+	if ( jQuery('#auto_draft').val() == '1' )
+		post_data["auto_draft"] = '1';
 
 	if ( doAutoSave ) {
 		autosaveLast = jQuery("#title").val()+jQuery("#content").val();
@@ -288,15 +274,14 @@
 		post_data['autosave'] = 0;
 	}
 
-	if ( parseInt(post_data["post_ID"], 10) < 1 ) {
-		post_data["temp_ID"] = post_data["post_ID"];
+	if ( post_data["auto_draft"] == '1' ) {
+		// post_data["temp_ID"] = post_data["post_ID"];
 		successCallback = autosave_saved_new; // new post
 	} else {
 		successCallback = autosave_saved; // pre-existing post
 	}
 
 	autosaveOldMessage = jQuery('#autosave').html();
-
 	jQuery.ajax({
 		data: post_data,
 		beforeSend: doAutoSave ? autosave_loading : null,
Index: wp-includes/js/autosave.js
===================================================================
--- wp-includes/js/autosave.js	(revision 12985)
+++ wp-includes/js/autosave.js	(working copy)
@@ -1 +1 @@
-var autosave,autosaveLast="",autosavePeriodical,autosaveOldMessage="",autosaveDelayPreview=false,notSaved=true,blockSave=false,interimLogin=false;jQuery(document).ready(function(b){var a=true;autosaveLast=b("#post #title").val()+b("#post #content").val();autosavePeriodical=b.schedule({time:autosaveL10n.autosaveInterval*1000,func:function(){autosave()},repeat:true,protect:true});b("#post").submit(function(){b.cancel(autosavePeriodical)});b('input[type="submit"], a.submitdelete',"#submitpost").click(function(){blockSave=true;window.onbeforeunload=null;b(":button, :submit","#submitpost").each(function(){var c=b(this);if(c.hasClass("button-primary")){c.addClass("button-primary-disabled")}else{c.addClass("button-disabled")}});b("#ajax-loading").css("visibility","visible")});window.onbeforeunload=function(){var c=typeof(tinyMCE)!="undefined"?tinyMCE.activeEditor:false,e,d;if(c&&!c.isHidden()){if(c.isDirty()){return autosaveL10n.saveAlert}}else{e=b("#post #title").val(),d=b("#post #content").val();if((e||d)&&e+d!=autosaveLast){return autosaveL10n.saveAlert}}};b("#post-preview").click(function(){if(1>b("#post_ID").val()&&notSaved){autosaveDelayPreview=true;autosave();return false}doPreview();return false});doPreview=function(){b("input#wp-preview").val("dopreview");b("form#post").attr("target","wp-preview").submit().attr("target","");b("input#wp-preview").val("")};if(typeof tinyMCE!="undefined"){b("#title")[b.browser.opera?"keypress":"keydown"](function(c){if(c.which==9&&!c.shiftKey&&!c.controlKey&&!c.altKey){if((b("#post_ID").val()<1)&&(b("#title").val().length>0)){autosave()}if(tinyMCE.activeEditor&&!tinyMCE.activeEditor.isHidden()&&a){c.preventDefault();a=false;tinyMCE.activeEditor.focus();return false}}})}if(0>b("#post_ID").val()){b("#title").blur(function(){if(!this.value||0<b("#post_ID").val()){return}delayed_autosave()})}});function autosave_parse_response(c){var e=wpAjax.parseAjaxResponse(c,"autosave"),f="",a,b,d;if(e&&e.responses&&e.responses.length){f=e.responses[0].data;if(e.responses[0].supplemental){b=e.responses[0].supplemental;if("disable"==b.disable_autosave){autosave=function(){};e={errors:true}}if(b.session_expired&&(d=b.session_expired)){if(!interimLogin||interimLogin.closed){interimLogin=window.open(d,"login","width=600,height=450,resizable=yes,scrollbars=yes,status=yes");interimLogin.focus()}delete b.session_expired}jQuery.each(b,function(g,h){if(g.match(/^replace-/)){jQuery("#"+g.replace("replace-","")).val(h)}})}if(!e.errors){a=parseInt(e.responses[0].id,10);if(!isNaN(a)&&a>0){autosave_update_slug(a)}}}if(f){jQuery("#autosave").html(f)}else{if(autosaveOldMessage&&e){jQuery("#autosave").html(autosaveOldMessage)}}return e}function autosave_saved(a){autosave_parse_response(a);autosave_enable_buttons()}function autosave_saved_new(b){var d=autosave_parse_response(b),c,a;if(d&&d.responses.length&&!d.errors){c=jQuery("#post_ID").val();a=parseInt(d.responses[0].id,10);autosave_update_post_ID(a);if(c<0&&a>0){notSaved=false;jQuery("#media-buttons a").each(function(){this.href=this.href.replace(c,a)})}if(autosaveDelayPreview){autosaveDelayPreview=false;doPreview()}}else{autosave_enable_buttons()}}function autosave_update_post_ID(a){if(!isNaN(a)&&a>0){if(a==parseInt(jQuery("#post_ID").val(),10)){return}jQuery("#post_ID").attr({name:"post_ID"});jQuery("#post_ID").val(a);jQuery.post(autosaveL10n.requestFile,{action:"autosave-generate-nonces",post_ID:a,autosavenonce:jQuery("#autosavenonce").val(),post_type:jQuery("#post_type").val()},function(b){jQuery("#_wpnonce").val(b.updateNonce);jQuery("#delete-action a.submitdelete").attr("href",b.deleteURL);autosave_enable_buttons();jQuery("#delete-action a.submitdelete").fadeIn()},"json");jQuery("#hiddenaction").val("editpost")}}function autosave_update_slug(a){if("undefined"!=makeSlugeditClickable&&jQuery.isFunction(makeSlugeditClickable)&&!jQuery("#edit-slug-box > *").size()){jQuery.post(ajaxurl,{action:"sample-permalink",post_id:a,new_title:jQuery("#title").val(),samplepermalinknonce:jQuery("#samplepermalinknonce").val()},function(b){jQuery("#edit-slug-box").html(b);makeSlugeditClickable()})}}function autosave_loading(){jQuery("#autosave").html(autosaveL10n.savingText)}function autosave_enable_buttons(){setTimeout(function(){jQuery(":button, :submit","#submitpost").removeAttr("disabled");jQuery("#ajax-loading").css("visibility","hidden")},500)}function autosave_disable_buttons(){jQuery(":button, :submit","#submitpost").attr("disabled","disabled");setTimeout(autosave_enable_buttons,5000)}function delayed_autosave(){setTimeout(function(){if(blockSave){return}autosave()},200)}autosave=function(){var c=(typeof tinyMCE!="undefined")&&tinyMCE.activeEditor&&!tinyMCE.activeEditor.isHidden(),d,f,b,e,a;autosave_disable_buttons();d={action:"autosave",post_ID:jQuery("#post_ID").val()||0,post_title:jQuery("#title").val()||"",autosavenonce:jQuery("#autosavenonce").val(),post_type:jQuery("#post_type").val()||"",autosave:1};jQuery(".tags-input").each(function(){d[this.name]=this.value});f=true;if(jQuery("#TB_window").css("display")=="block"){f=false}if(c&&f){b=tinyMCE.activeEditor;if(b.plugins.spellchecker&&b.plugins.spellchecker.active){f=false}else{if("mce_fullscreen"==b.id){tinyMCE.get("content").setContent(b.getContent({format:"raw"}),{format:"raw"})}tinyMCE.get("content").save()}}d.content=jQuery("#content").val();if(jQuery("#post_name").val()){d.post_name=jQuery("#post_name").val()}if((d.post_title.length==0&&d.content.length==0)||d.post_title+d.content==autosaveLast){f=false}e=jQuery("#original_post_status").val();goodcats=([]);jQuery("[name='post_category[]']:checked").each(function(g){goodcats.push(this.value)});d.catslist=goodcats.join(",");if(jQuery("#comment_status").attr("checked")){d.comment_status="open"}if(jQuery("#ping_status").attr("checked")){d.ping_status="open"}if(jQuery("#excerpt").size()){d.excerpt=jQuery("#excerpt").val()}if(jQuery("#post_author").size()){d.post_author=jQuery("#post_author").val()}d.user_ID=jQuery("#user-id").val();if(f){autosaveLast=jQuery("#title").val()+jQuery("#content").val()}else{d.autosave=0}if(parseInt(d.post_ID,10)<1){d.temp_ID=d.post_ID;a=autosave_saved_new}else{a=autosave_saved}autosaveOldMessage=jQuery("#autosave").html();jQuery.ajax({data:d,beforeSend:f?autosave_loading:null,type:"POST",url:autosaveL10n.requestFile,success:a})};
\ No newline at end of file
+var autosave,autosaveLast="",autosavePeriodical,autosaveOldMessage="",autosaveDelayPreview=false,notSaved=true,blockSave=false,interimLogin=false;jQuery(document).ready(function($){var dotabkey=true;autosaveLast=$("#post #title").val()+$("#post #content").val();autosavePeriodical=$.schedule({time:autosaveL10n.autosaveInterval*1000,func:function(){autosave()},repeat:true,protect:true});$("#post").submit(function(){$.cancel(autosavePeriodical)});$('input[type="submit"], a.submitdelete',"#submitpost").click(function(){blockSave=true;window.onbeforeunload=null;$(":button, :submit","#submitpost").each(function(){var t=$(this);if(t.hasClass("button-primary")){t.addClass("button-primary-disabled")}else{t.addClass("button-disabled")}});$("#ajax-loading").css("visibility","visible")});window.onbeforeunload=function(){var mce=typeof(tinyMCE)!="undefined"?tinyMCE.activeEditor:false,title,content;if(mce&&!mce.isHidden()){if(mce.isDirty()){return autosaveL10n.saveAlert}}else{title=$("#post #title").val(),content=$("#post #content").val();if((title||content)&&title+content!=autosaveLast){return autosaveL10n.saveAlert}}};$("#post-preview").click(function(){if($("#auto_draft").val()=="1"&&notSaved){autosaveDelayPreview=true;autosave();return false}doPreview();return false});doPreview=function(){$("input#wp-preview").val("dopreview");$("form#post").attr("target","wp-preview").submit().attr("target","");$("input#wp-preview").val("")};if(typeof tinyMCE!="undefined"){$("#title")[$.browser.opera?"keypress":"keydown"](function(e){if(e.which==9&&!e.shiftKey&&!e.controlKey&&!e.altKey){if(($("#auto_draft").val()=="1")&&($("#title").val().length>0)){autosave()}if(tinyMCE.activeEditor&&!tinyMCE.activeEditor.isHidden()&&dotabkey){e.preventDefault();dotabkey=false;tinyMCE.activeEditor.focus();return false}}})}if("1"==$("#auto_draft").val()){$("#title").blur(function(){if(!this.value||$("#auto_draft").val()!="1"){return}delayed_autosave()})}});function autosave_parse_response(response){var res=wpAjax.parseAjaxResponse(response,"autosave"),message="",postID,sup,url;if(res&&res.responses&&res.responses.length){message=res.responses[0].data;if(res.responses[0].supplemental){sup=res.responses[0].supplemental;if("disable"==sup.disable_autosave){autosave=function(){};res={errors:true}}if(sup.session_expired&&(url=sup.session_expired)){if(!interimLogin||interimLogin.closed){interimLogin=window.open(url,"login","width=600,height=450,resizable=yes,scrollbars=yes,status=yes");interimLogin.focus()}delete sup.session_expired}jQuery.each(sup,function(selector,value){if(selector.match(/^replace-/)){jQuery("#"+selector.replace("replace-","")).val(value)}})}if(!res.errors){postID=parseInt(res.responses[0].id,10);if(!isNaN(postID)&&postID>0){autosave_update_slug(postID)}}}if(message){jQuery("#autosave").html(message)}else{if(autosaveOldMessage&&res){jQuery("#autosave").html(autosaveOldMessage)}}return res}function autosave_saved(response){blockSave=false;autosave_parse_response(response);autosave_enable_buttons()}function autosave_saved_new(response){blockSave=false;var res=autosave_parse_response(response),tempID,postID;if(res&&res.responses.length&&!res.errors){postID=parseInt(res.responses[0].id,10);autosave_update_post_ID(postID);if(autosaveDelayPreview){autosaveDelayPreview=false;doPreview()}}else{autosave_enable_buttons()}}function autosave_update_post_ID(postID){if(!isNaN(postID)&&postID>0){if(postID==parseInt(jQuery("#post_ID").val(),10)){return}notSaved=false;autosave_enable_buttons();jQuery("#delete-action a.submitdelete").fadeIn();jQuery("#hiddenaction").val("editpost");jQuery("#auto_draft").val("0")}}function autosave_update_slug(post_id){if("undefined"!=makeSlugeditClickable&&jQuery.isFunction(makeSlugeditClickable)&&!jQuery("#edit-slug-box > *").size()){jQuery.post(ajaxurl,{action:"sample-permalink",post_id:post_id,new_title:jQuery("#title").val(),samplepermalinknonce:jQuery("#samplepermalinknonce").val()},function(data){jQuery("#edit-slug-box").html(data);makeSlugeditClickable()})}}function autosave_loading(){jQuery("#autosave").html(autosaveL10n.savingText)}function autosave_enable_buttons(){setTimeout(function(){jQuery(":button, :submit","#submitpost").removeAttr("disabled");jQuery("#ajax-loading").css("visibility","hidden")},500)}function autosave_disable_buttons(){jQuery(":button, :submit","#submitpost").attr("disabled","disabled");setTimeout(autosave_enable_buttons,5000)}function delayed_autosave(){setTimeout(function(){if(blockSave){return}autosave()},200)}autosave=function(){blockSave=true;var rich=(typeof tinyMCE!="undefined")&&tinyMCE.activeEditor&&!tinyMCE.activeEditor.isHidden(),post_data,doAutoSave,ed,origStatus,successCallback;autosave_disable_buttons();post_data={action:"autosave",post_ID:jQuery("#post_ID").val()||0,post_title:jQuery("#title").val()||"",autosavenonce:jQuery("#autosavenonce").val(),post_type:jQuery("#post_type").val()||"",autosave:1};jQuery(".tags-input").each(function(){post_data[this.name]=this.value});doAutoSave=true;if(jQuery("#TB_window").css("display")=="block"){doAutoSave=false}if(rich&&doAutoSave){ed=tinyMCE.activeEditor;if(ed.plugins.spellchecker&&ed.plugins.spellchecker.active){doAutoSave=false}else{if("mce_fullscreen"==ed.id){tinyMCE.get("content").setContent(ed.getContent({format:"raw"}),{format:"raw"})}tinyMCE.get("content").save()}}post_data.content=jQuery("#content").val();if(jQuery("#post_name").val()){post_data.post_name=jQuery("#post_name").val()}if((post_data.post_title.length==0&&post_data.content.length==0)||post_data.post_title+post_data.content==autosaveLast){doAutoSave=false}origStatus=jQuery("#original_post_status").val();goodcats=([]);jQuery("[name='post_category[]']:checked").each(function(i){goodcats.push(this.value)});post_data.catslist=goodcats.join(",");if(jQuery("#comment_status").attr("checked")){post_data.comment_status="open"}if(jQuery("#ping_status").attr("checked")){post_data.ping_status="open"}if(jQuery("#excerpt").size()){post_data.excerpt=jQuery("#excerpt").val()}if(jQuery("#post_author").size()){post_data.post_author=jQuery("#post_author").val()}post_data.user_ID=jQuery("#user-id").val();if(jQuery("#auto_draft").val()=="1"){post_data.auto_draft="1"}if(doAutoSave){autosaveLast=jQuery("#title").val()+jQuery("#content").val()}else{post_data.autosave=0}if(post_data.auto_draft=="1"){successCallback=autosave_saved_new}else{successCallback=autosave_saved}autosaveOldMessage=jQuery("#autosave").html();jQuery.ajax({data:post_data,beforeSend:doAutoSave?autosave_loading:null,type:"POST",url:autosaveL10n.requestFile,success:successCallback})};
\ No newline at end of file
Index: wp-includes/link-template.php
===================================================================
--- wp-includes/link-template.php	(revision 12985)
+++ wp-includes/link-template.php	(working copy)
@@ -111,7 +111,7 @@
 
 	$permalink = get_option('permalink_structure');
 
-	if ( '' != $permalink && !in_array($post->post_status, array('draft', 'pending')) ) {
+	if ( '' != $permalink && !in_array($post->post_status, array('draft', 'pending', 'auto-draft')) ) {
 		$unixtime = strtotime($post->post_date);
 
 		$category = '';
Index: wp-admin/admin-ajax.php
===================================================================
--- wp-admin/admin-ajax.php	(revision 12985)
+++ wp-admin/admin-ajax.php	(working copy)
@@ -887,57 +887,51 @@
 		$supplemental['session_expired'] = add_query_arg( 'interim-login', 1, wp_login_url() );
 
 	$id = $revision_id = 0;
-	if ( $_POST['post_ID'] < 0 ) {
+
+	$post_ID = (int) $_POST['post_ID'];
+	$_POST['ID'] = $post_ID;
+	$post = get_post($post_ID);
+	if ( 'auto-draft' == $post->post_status )
 		$_POST['post_status'] = 'draft';
-		$_POST['temp_ID'] = $_POST['post_ID'];
-		if ( $do_autosave ) {
-			$id = wp_write_post();
-			$data = $message;
-		}
-	} else {
-		$post_ID = (int) $_POST['post_ID'];
-		$_POST['ID'] = $post_ID;
-		$post = get_post($post_ID);
 
-		if ( $last = wp_check_post_lock( $post->ID ) ) {
-			$do_autosave = $do_lock = false;
+	if ( $last = wp_check_post_lock( $post->ID ) ) {
+		$do_autosave = $do_lock = false;
 
-			$last_user = get_userdata( $last );
-			$last_user_name = $last_user ? $last_user->display_name : __( 'Someone' );
-			$data = new WP_Error( 'locked', sprintf(
-				$_POST['post_type'] == 'page' ? __( 'Autosave disabled: %s is currently editing this page.' ) : __( 'Autosave disabled: %s is currently editing this post.' ),
-				esc_html( $last_user_name )
-			) );
+		$last_user = get_userdata( $last );
+		$last_user_name = $last_user ? $last_user->display_name : __( 'Someone' );
+		$data = new WP_Error( 'locked', sprintf(
+			$_POST['post_type'] == 'page' ? __( 'Autosave disabled: %s is currently editing this page.' ) : __( 'Autosave disabled: %s is currently editing this post.' ),
+			esc_html( $last_user_name )
+		) );
 
-			$supplemental['disable_autosave'] = 'disable';
-		}
+		$supplemental['disable_autosave'] = 'disable';
+	}
 
-		if ( 'page' == $post->post_type ) {
-			if ( !current_user_can('edit_page', $post_ID) )
-				die(__('You are not allowed to edit this page.'));
-		} else {
-			if ( !current_user_can('edit_post', $post_ID) )
-				die(__('You are not allowed to edit this post.'));
-		}
+	if ( 'page' == $post->post_type ) {
+		if ( !current_user_can('edit_page', $post_ID) )
+			die(__('You are not allowed to edit this page.'));
+	} else {
+		if ( !current_user_can('edit_post', $post_ID) )
+			die(__('You are not allowed to edit this post.'));
+	}
 
-		if ( $do_autosave ) {
-			// Drafts are just overwritten by autosave
-			if ( 'draft' == $post->post_status ) {
-				$id = edit_post();
-			} else { // Non drafts are not overwritten.  The autosave is stored in a special post revision.
-				$revision_id = wp_create_post_autosave( $post->ID );
-				if ( is_wp_error($revision_id) )
-					$id = $revision_id;
-				else
-					$id = $post->ID;
-			}
-			$data = $message;
-		} else {
-			$id = $post->ID;
+	if ( $do_autosave ) {
+		// Drafts and auto-drafts are just overwritten by autosave
+		if ( 'auto-draft' == $post->post_status || 'draft' == $post->post_status ) {
+			$id = edit_post();
+		} else { // Non drafts are not overwritten.  The autosave is stored in a special post revision.
+			$revision_id = wp_create_post_autosave( $post->ID );
+			if ( is_wp_error($revision_id) )
+				$id = $revision_id;
+			else
+				$id = $post->ID;
 		}
+		$data = $message;
+	} else {
+		$id = $post->ID;
 	}
 
-	if ( $do_lock && $id && is_numeric($id) )
+	if ( $do_lock && $_POST['auto_draft'] != '1' && $id && is_numeric($id) )
 		wp_set_post_lock( $id );
 
 	if ( $nonce_age == 2 ) {
@@ -961,18 +955,6 @@
 	) );
 	$x->send();
 	break;
-case 'autosave-generate-nonces' :
-	check_ajax_referer( 'autosave', 'autosavenonce' );
-	$ID = (int) $_POST['post_ID'];
-	$post_type = $_POST['post_type'];
-	$post_type_object = get_post_type_object($post_type);
-	if ( !$post_type_object )
-		die('0');
-	if ( current_user_can( $post_type_object->edit_cap, $ID ) )
-		die( json_encode( array( 'updateNonce' => wp_create_nonce( "update-{$post_type}_{$ID}" ), 'deleteURL' => str_replace( '&amp;', '&', wp_nonce_url( admin_url( $post_type . '.php?action=trash&post=' . $ID ), "trash-{$post_type}_{$ID}" ) ) ) ) );
-	do_action('autosave_generate_nonces');
-	die('0');
-break;
 case 'closed-postboxes' :
 	check_ajax_referer( 'closedpostboxes', 'closedpostboxesnonce' );
 	$closed = isset( $_POST['closed'] ) ? $_POST['closed'] : '';
Index: wp-admin/post-new.php
===================================================================
--- wp-admin/post-new.php	(revision 12985)
+++ wp-admin/post-new.php	(working copy)
@@ -50,7 +50,10 @@
 
 // Show post form.
 if ( current_user_can($post_type_object->edit_type_cap) ) {
-	$post = get_default_post_to_edit( $post_type );
+	$post = get_default_post_to_edit( $post_type, true );
+	$post_ID = $post->ID;
+	global $auto_draft;
+	$auto_draft = true;
 	include('edit-form-advanced.php');
 }
 
Index: wp-admin/includes/post.php
===================================================================
--- wp-admin/includes/post.php	(revision 12985)
+++ wp-admin/includes/post.php	(working copy)
@@ -336,7 +336,8 @@
  *@param string A post type string, defaults to 'post'.
  * @return object stdClass object containing all the default post data as attributes
  */
-function get_default_post_to_edit( $post_type = 'post' ) {
+function get_default_post_to_edit( $post_type = 'post', $create_in_db = false ) {
+	global $wpdb;
 
 	$post_title = '';
 	if ( !empty( $_REQUEST['post_title'] ) )
@@ -350,26 +351,35 @@
 	if ( !empty( $_REQUEST['excerpt'] ) )
 		$post_excerpt = esc_html( stripslashes( $_REQUEST['excerpt'] ));
 
-	$post->ID = 0;
-	$post->post_name = '';
-	$post->post_author = '';
-	$post->post_date = '';
-	$post->post_date_gmt = '';
-	$post->post_password = '';
+	if ( $create_in_db ) {
+		// Cleanup old auto-drafts more than 7 days old
+		$old_posts = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_status = 'auto-draft' AND DATE_SUB( NOW(), INTERVAL 7 DAY ) > post_date" );
+		foreach ( (array) $old_posts as $delete )
+			wp_delete_post( $delete, true ); // Force delete
+		$post = get_post( wp_insert_post( array( 'post_title' => __( 'Auto Draft' ), 'post_type' => $post_type, 'post_status' => 'auto-draft' ) ) );
+	} else {
+		$post->ID = 0;
+		$post->post_author = '';
+		$post->post_date = '';
+		$post->post_date_gmt = '';
+		$post->post_password = '';
+		$post->post_type = $post_type;
+		$post->to_ping = '';
+		$post->pinged = '';
+		$post->comment_status = get_option( 'default_comment_status' );
+		$post->ping_status = get_option( 'default_ping_status' );
+		$post->post_pingback = get_option( 'default_pingback_flag' );
+		$post->post_category = get_option( 'default_category' );
+		$post->page_template = 'default';
+		$post->post_parent = 0;
+		$post->menu_order = 0;
+	}
+
 	$post->post_status = 'draft';
-	$post->post_type = $post_type;
-	$post->to_ping = '';
-	$post->pinged = '';
-	$post->comment_status = get_option( 'default_comment_status' );
-	$post->ping_status = get_option( 'default_ping_status' );
-	$post->post_pingback = get_option( 'default_pingback_flag' );
-	$post->post_category = get_option( 'default_category' );
-	$post->post_content = apply_filters( 'default_content', $post_content);
-	$post->post_title = apply_filters( 'default_title', $post_title );
-	$post->post_excerpt = apply_filters( 'default_excerpt', $post_excerpt);
-	$post->page_template = 'default';
-	$post->post_parent = 0;
-	$post->menu_order = 0;
+	$post->post_content = apply_filters( 'default_content', $post_content );
+	$post->post_title   = apply_filters( 'default_title',   $post_title   );
+	$post->post_excerpt = apply_filters( 'default_excerpt', $post_excerpt );
+	$post->post_name = '';
 
 	return $post;
 }
@@ -464,24 +474,6 @@
 			return new WP_Error( 'edit_posts', __( 'You are not allowed to create posts or drafts on this blog.' ) );
 	}
 
-	// Check for autosave collisions
-	$temp_id = false;
-	if ( isset($_POST['temp_ID']) ) {
-		$temp_id = (int) $_POST['temp_ID'];
-		if ( !$draft_ids = get_user_option( 'autosave_draft_ids' ) )
-			$draft_ids = array();
-		foreach ( $draft_ids as $temp => $real )
-			if ( time() + $temp > 86400 ) // 1 day: $temp is equal to -1 * time( then )
-				unset($draft_ids[$temp]);
-
-		if ( isset($draft_ids[$temp_id]) ) { // Edit, don't write
-			$_POST['post_ID'] = $draft_ids[$temp_id];
-			unset($_POST['temp_ID']);
-			update_user_option( $user_ID, 'autosave_draft_ids', $draft_ids );
-			return edit_post();
-		}
-	}
-
 	$translated = _wp_translate_postdata( false );
 	if ( is_wp_error($translated) )
 		return $translated;
Index: wp-admin/edit-form-advanced.php
===================================================================
--- wp-admin/edit-form-advanced.php	(revision 12985)
+++ wp-admin/edit-form-advanced.php	(working copy)
@@ -60,28 +60,27 @@
 }
 
 $notice = false;
-if ( 0 == $post_ID ) {
-	$form_action = 'post';
-	$nonce_action = 'add-' . $post_type;
-	$temp_ID = -1 * time(); // don't change this formula without looking at wp_write_post()
-	$form_extra = "<input type='hidden' id='post_ID' name='temp_ID' value='" . esc_attr($temp_ID) . "' />";
+$form_extra = '';
+if ( $auto_draft ) {
 	$autosave = false;
+	$form_extra .= "<input type='hidden' id='auto_draft' name='auto_draft' value='1' />";
 } else {
-	$form_action = 'editpost';
-	$nonce_action = 'update-' . $post_type . '_' . $post_ID;
-	$form_extra = "<input type='hidden' id='post_ID' name='post_ID' value='" . esc_attr($post_ID) . "' />";
 	$autosave = wp_get_post_autosave( $post_ID );
+}
 
-	// Detect if there exists an autosave newer than the post and if that autosave is different than the post
-	if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt, false ) > mysql2date( 'U', $post->post_modified_gmt, false ) ) {
-		foreach ( _wp_post_revision_fields() as $autosave_field => $_autosave_field ) {
-			if ( normalize_whitespace( $autosave->$autosave_field ) != normalize_whitespace( $post->$autosave_field ) ) {
-				$notice = sprintf( __( 'There is an autosave of this post that is more recent than the version below.  <a href="%s">View the autosave</a>' ), get_edit_post_link( $autosave->ID ) );
-				break;
-			}
+$form_action = 'editpost';
+$nonce_action = 'update-' . $post_type . '_' . $post_ID;
+$form_extra .= "<input type='hidden' id='post_ID' name='post_ID' value='" . esc_attr($post_ID) . "' />";
+
+// Detect if there exists an autosave newer than the post and if that autosave is different than the post
+if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt, false ) > mysql2date( 'U', $post->post_modified_gmt, false ) ) {
+	foreach ( _wp_post_revision_fields() as $autosave_field => $_autosave_field ) {
+		if ( normalize_whitespace( $autosave->$autosave_field ) != normalize_whitespace( $post->$autosave_field ) ) {
+			$notice = sprintf( __( 'There is an autosave of this post that is more recent than the version below.  <a href="%s">View the autosave</a>' ), get_edit_post_link( $autosave->ID ) );
+			break;
 		}
-		unset($autosave_field, $_autosave_field);
 	}
+	unset($autosave_field, $_autosave_field);
 }
 
 $post_type_object = get_post_type_object($post_type);
@@ -197,7 +196,7 @@
 if ( !( 'pending' == $post->post_status && !current_user_can( $post_type_object->publish_cap ) ) ) { ?>
 	<div id="edit-slug-box">
 <?php
-	if ( ! empty($post->ID) && ! empty($sample_permalink_html) ) :
+	if ( ! empty($post->ID) && ! empty($sample_permalink_html) && !$auto_draft ) :
 		echo $sample_permalink_html;
 endif; ?>
 	</div>
@@ -215,7 +214,7 @@
 	<td class="autosave-info">
 	<span id="autosave">&nbsp;</span>
 <?php
-	if ( $post_ID ) {
+	if ( !$auto_draft ) {
 		echo '<span id="last-edit">';
 		if ( $last_id = get_post_meta($post_ID, '_edit_last', true) ) {
 			$last_user = get_userdata($last_id);
