WordPress.org

Make WordPress Core

Changeset 28077


Ignore:
Timestamp:
04/11/2014 05:28:30 PM (7 years ago)
Author:
nacin
Message:

Recover auto-drafts lost via Quick Draft.

Merges [28075] from the 3.8 to the 3.7 branch. See [28074].

fixes #27734.

Location:
branches/3.7
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/3.7

  • branches/3.7/src/wp-admin/includes/upgrade.php

    r26450 r28077  
    409409        upgrade_372();
    410410
     411    if ( $wp_current_db_version < 26149 )
     412        upgrade_373();
     413
    411414    maybe_disable_link_manager();
    412415
     
    12361239    if ( $wp_current_db_version < 26148 )
    12371240        wp_clear_scheduled_hook( 'wp_maybe_auto_update' );
     1241}
     1242
     1243/**
     1244 * Execute changes made in WordPress 3.7.3.
     1245 *
     1246 * @since 3.7.3
     1247 */
     1248function upgrade_373() {
     1249    global $wp_current_db_version, $wpdb;
     1250    if ( $wp_current_db_version < 26149 ) {
     1251        // Find all lost Quick Draft auto-drafts and promote them to proper drafts.
     1252        $posts = $wpdb->get_results( "SELECT ID, post_title, post_content FROM $wpdb->posts WHERE post_type = 'post'
     1253            AND post_status = 'auto-draft' AND post_date >= '2014-04-08 00:00:00'" );
     1254
     1255        foreach ( $posts as $post ) {
     1256            // A regular auto-draft should never have content as that would mean it should have been promoted.
     1257            // If an auto-draft has content, it's from Quick Draft and it should be recovered.
     1258            if ( '' === $post->post_content ) {
     1259                // If it does not have content, we must evaluate whether the title should be recovered.
     1260                if ( 'Auto Draft' === $post->post_title || __( 'Auto Draft' ) === $post->post_title ) {
     1261                    // This a plain old auto draft. Ignore it.
     1262                    continue;
     1263                }
     1264            }
     1265
     1266            $wpdb->update( $wpdb->posts, array( 'post_status' => 'draft' ), array( 'ID' => $post->ID ) );
     1267            clean_post_cache( $post->ID );
     1268        }
     1269    }
    12381270}
    12391271
  • branches/3.7/src/wp-includes/version.php

    r28056 r28077  
    1212 * @global int $wp_db_version
    1313 */
    14 $wp_db_version = 26148;
     14$wp_db_version = 26149;
    1515
    1616/**
Note: See TracChangeset for help on using the changeset viewer.