WordPress.org

Make WordPress Core

Ticket #27734: 27734.3.diff

File 27734.3.diff, 2.0 KB (added by nacin, 7 years ago)
  • src/wp-admin/includes/upgrade.php

     
    411411        if ( $wp_current_db_version < 26691 )
    412412                upgrade_380();
    413413
     414        if ( $wp_current_db_version < 30000 )
     415                upgrade_382();
     416
    414417        maybe_disable_link_manager();
    415418
    416419        maybe_disable_automattic_widgets();
     
    12511254                deactivate_plugins( array( 'mp6/mp6.php' ), true );
    12521255        }
    12531256}
     1257
    12541258/**
     1259 * Execute changes made in WordPress 3.8.2.
     1260 *
     1261 * @since 3.8.2
     1262 */
     1263function upgrade_382() {
     1264        global $wp_current_db_version, $wpdb;
     1265        if ( $wp_current_db_version < 30000 ) {
     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                foreach ( $posts as $post ) {
     1270                        // A proper auto-draft should never have content as that would mean they should have been promoted.
     1271                        // If an auto-draft has content, it should be recovered.
     1272                        // If it does not have content, we must evaluate whether the title should be recovered.
     1273                        if ( '' === $post->post_content ) {
     1274                                if ( 'Auto Draft' === $post->post_title || __( 'Auto Draft' ) === $post->post_title ) {
     1275                                        // This a plain old auto draft. Ignore it.
     1276                                        continue;
     1277                                }
     1278                        }
     1279                        $wpdb->update( $wpdb->posts, array( 'post_status' => 'draft' ), array( 'ID' => $post->ID ) );
     1280                        clean_post_cache( $post_id );
     1281                }
     1282        }
     1283}
     1284
     1285/**
    12551286 * Execute network level changes
    12561287 *
    12571288 * @since 3.0.0
  • src/wp-includes/version.php

     
    1111 *
    1212 * @global int $wp_db_version
    1313 */
    14 $wp_db_version = 26691;
     14$wp_db_version = 26692;
    1515
    1616/**
    1717 * Holds the TinyMCE version