From 9c1b1dd073c15b91a69561b176207e7919028551 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Fri, 11 Apr 2014 17:29:10 +0000 Subject: [PATCH] Recover auto-drafts lost via Quick Draft. Merges [28075] from the 3.8 to the 3.7 branch. See [28074]. fixes #27734. Built from https://develop.svn.wordpress.org/branches/3.7@28077 git-svn-id: http://core.svn.wordpress.org/branches/3.7@27908 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/upgrade.php | 32 ++++++++++++++++++++++++++++++++ wp-includes/version.php | 2 +- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/wp-admin/includes/upgrade.php b/wp-admin/includes/upgrade.php index 6108d67d99..56f7ac5d6a 100644 --- a/wp-admin/includes/upgrade.php +++ b/wp-admin/includes/upgrade.php @@ -408,6 +408,9 @@ function upgrade_all() { if ( $wp_current_db_version < 26148 ) upgrade_372(); + if ( $wp_current_db_version < 26149 ) + upgrade_373(); + maybe_disable_link_manager(); maybe_disable_automattic_widgets(); @@ -1237,6 +1240,35 @@ function upgrade_372() { wp_clear_scheduled_hook( 'wp_maybe_auto_update' ); } +/** + * Execute changes made in WordPress 3.7.3. + * + * @since 3.7.3 + */ +function upgrade_373() { + global $wp_current_db_version, $wpdb; + if ( $wp_current_db_version < 26149 ) { + // Find all lost Quick Draft auto-drafts and promote them to proper drafts. + $posts = $wpdb->get_results( "SELECT ID, post_title, post_content FROM $wpdb->posts WHERE post_type = 'post' + AND post_status = 'auto-draft' AND post_date >= '2014-04-08 00:00:00'" ); + + foreach ( $posts as $post ) { + // A regular auto-draft should never have content as that would mean it should have been promoted. + // If an auto-draft has content, it's from Quick Draft and it should be recovered. + if ( '' === $post->post_content ) { + // If it does not have content, we must evaluate whether the title should be recovered. + if ( 'Auto Draft' === $post->post_title || __( 'Auto Draft' ) === $post->post_title ) { + // This a plain old auto draft. Ignore it. + continue; + } + } + + $wpdb->update( $wpdb->posts, array( 'post_status' => 'draft' ), array( 'ID' => $post->ID ) ); + clean_post_cache( $post->ID ); + } + } +} + /** * Execute network level changes * diff --git a/wp-includes/version.php b/wp-includes/version.php index a42664daf9..8b94ed6543 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -11,7 +11,7 @@ $wp_version = '3.7.2'; * * @global int $wp_db_version */ -$wp_db_version = 26148; +$wp_db_version = 26149; /** * Holds the TinyMCE version