Make WordPress Core


Ignore:
Timestamp:
04/11/2014 04:54:44 PM (12 years ago)
Author:
nacin
Message:

Recover auto-drafts lost via Quick Draft.

For the 3.8 branch. See [28074].

see #27734.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.8/src/wp-admin/includes/upgrade.php

    r26692 r28075  
    412412                upgrade_380();
    413413
     414        if ( $wp_current_db_version < 26692 )
     415                upgrade_383();
     416
    414417        maybe_disable_link_manager();
    415418
     
    12521255        }
    12531256}
     1257
     1258/**
     1259 * Execute changes made in WordPress 3.8.3.
     1260 *
     1261 * @since 3.8.3
     1262 */
     1263function upgrade_383() {
     1264        global $wp_current_db_version, $wpdb;
     1265        if ( $wp_current_db_version < 26692 ) {
     1266                // Find all lost Quick Draft auto-drafts and promote them to proper drafts.
     1267                $posts = $wpdb->get_results( "SELECT ID, post_title, post_content FROM $wpdb->posts WHERE post_type = 'post'
     1268                        AND post_status = 'auto-draft' AND post_date >= '2014-04-08 00:00:00'" );
     1269
     1270                foreach ( $posts as $post ) {
     1271                        // A regular auto-draft should never have content as that would mean it should have been promoted.
     1272                        // If an auto-draft has content, it's from Quick Draft and it should be recovered.
     1273                        if ( '' === $post->post_content ) {
     1274                                // If it does not have content, we must evaluate whether the title should be recovered.
     1275                                if ( 'Auto Draft' === $post->post_title || __( 'Auto Draft' ) === $post->post_title ) {
     1276                                        // This a plain old auto draft. Ignore it.
     1277                                        continue;
     1278                                }
     1279                        }
     1280
     1281                        $wpdb->update( $wpdb->posts, array( 'post_status' => 'draft' ), array( 'ID' => $post->ID ) );
     1282                        clean_post_cache( $post->ID );
     1283                }
     1284        }
     1285}
     1286
    12541287/**
    12551288 * Execute network level changes
Note: See TracChangeset for help on using the changeset viewer.