WordPress.org

Make WordPress Core

Changeset 1229


Ignore:
Timestamp:
05/05/2004 08:00:13 AM (15 years ago)
Author:
saxmatt
Message:

Upgrades should run faster now.

Location:
trunk/wp-admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/upgrade-functions.php

    r1227 r1229  
    554554    }
    555555    // Get the title and ID of every post, post_name to check if it already has a value
    556     $posts = $wpdb->get_results("SELECT ID, post_title, post_name FROM $tableposts");
    557     foreach($posts as $post) {
    558         if ('' == $post->post_name) {
    559             $newtitle = sanitize_title($post->post_title);
    560             $wpdb->query("UPDATE $tableposts SET post_name = '$newtitle' WHERE ID = '$post->ID'");
     556    $posts = $wpdb->get_results("SELECT ID, post_title, post_name FROM $tableposts WHERE post_name = ''");
     557    if ($posts) {
     558        foreach($posts as $post) {
     559            if ('' == $post->post_name) {
     560                $newtitle = sanitize_title($post->post_title);
     561                $wpdb->query("UPDATE $tableposts SET post_name = '$newtitle' WHERE ID = '$post->ID'");
     562            }
    561563        }
    562564    }
     
    624626        )
    625627        ");
    626     $allposts = $wpdb->get_results("SELECT ID, post_category FROM $tableposts");
    627     foreach ($allposts as $post) {
    628         // Check to see if it's already been imported
    629         $cat = $wpdb->get_row("SELECT * FROM $tablepost2cat WHERE post_id = $post->ID AND category_id = $post->post_category");
    630         if (!$cat && 0 != $post->post_category) { // If there's no result
    631             $wpdb->query("
    632                 INSERT INTO $tablepost2cat
    633                 (post_id, category_id)
    634                 VALUES
    635                 ('$post->ID', '$post->post_category')
    636                 ");
    637         }
    638     }
     628
     629    $done_ids = $wpdb->get_results("SELECT DISTINCT post_id FROM $tablepost2cat");
     630    if ($done_ids) :
     631        foreach ($done_ids as $done_id) :
     632            $done_posts[] = $done_id->post_id;
     633        endforeach;
     634        $catwhere = ' AND ID NOT IN (' . implode(',', $done_posts) . ')';
     635    else:
     636        $catwhere = '';
     637    endif;
     638   
     639    $allposts = $wpdb->get_results("SELECT ID, post_category FROM $tableposts WHERE post_category != '0' $catwhere");
     640    if ($allposts) :
     641        foreach ($allposts as $post) {
     642            // Check to see if it's already been imported
     643            $cat = $wpdb->get_row("SELECT * FROM $tablepost2cat WHERE post_id = $post->ID AND category_id = $post->post_category");
     644            if (!$cat && 0 != $post->post_category) { // If there's no result
     645                $wpdb->query("
     646                    INSERT INTO $tablepost2cat
     647                    (post_id, category_id)
     648                    VALUES
     649                    ('$post->ID', '$post->post_category')
     650                    ");
     651            }
     652        }
     653    endif;
    639654}
    640655
  • trunk/wp-admin/upgrade.php

    r1117 r1229  
    33if (!file_exists('../wp-config.php')) die("There doesn't seem to be a wp-config.php file. Double check that you updated wp-config-sample.php with the proper database connection information and renamed it to wp-config.php.");
    44require('../wp-config.php');
     5timer_start();
    56require('upgrade-functions.php');
    67
     
    5556<h2>Step 1</h2>
    5657<p>There's actually only one step. So if you see this, you're done. <a href="../">Have fun</a>! </p>
     58
     59<!--
     60<pre>
     61<?php echo $wpdb->num_queries; ?> queries
     62
     63<?php timer_stop(1); ?> seconds
     64</pre>
     65-->
     66
    5767<?php
    5868    break;
Note: See TracChangeset for help on using the changeset viewer.