Upgrades should run faster now.
git-svn-id: https://develop.svn.wordpress.org/trunk@1229 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
6eae3c0e1e
commit
d912dbea1c
@ -553,11 +553,13 @@ function upgrade_100() {
|
|||||||
('$gid', '$oid', '$seq')");
|
('$gid', '$oid', '$seq')");
|
||||||
}
|
}
|
||||||
// Get the title and ID of every post, post_name to check if it already has a value
|
// Get the title and ID of every post, post_name to check if it already has a value
|
||||||
$posts = $wpdb->get_results("SELECT ID, post_title, post_name FROM $tableposts");
|
$posts = $wpdb->get_results("SELECT ID, post_title, post_name FROM $tableposts WHERE post_name = ''");
|
||||||
foreach($posts as $post) {
|
if ($posts) {
|
||||||
if ('' == $post->post_name) {
|
foreach($posts as $post) {
|
||||||
$newtitle = sanitize_title($post->post_title);
|
if ('' == $post->post_name) {
|
||||||
$wpdb->query("UPDATE $tableposts SET post_name = '$newtitle' WHERE ID = '$post->ID'");
|
$newtitle = sanitize_title($post->post_title);
|
||||||
|
$wpdb->query("UPDATE $tableposts SET post_name = '$newtitle' WHERE ID = '$post->ID'");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -623,19 +625,32 @@ function upgrade_100() {
|
|||||||
INDEX ( `post_id` , `category_id` )
|
INDEX ( `post_id` , `category_id` )
|
||||||
)
|
)
|
||||||
");
|
");
|
||||||
$allposts = $wpdb->get_results("SELECT ID, post_category FROM $tableposts");
|
|
||||||
foreach ($allposts as $post) {
|
$done_ids = $wpdb->get_results("SELECT DISTINCT post_id FROM $tablepost2cat");
|
||||||
// Check to see if it's already been imported
|
if ($done_ids) :
|
||||||
$cat = $wpdb->get_row("SELECT * FROM $tablepost2cat WHERE post_id = $post->ID AND category_id = $post->post_category");
|
foreach ($done_ids as $done_id) :
|
||||||
if (!$cat && 0 != $post->post_category) { // If there's no result
|
$done_posts[] = $done_id->post_id;
|
||||||
$wpdb->query("
|
endforeach;
|
||||||
INSERT INTO $tablepost2cat
|
$catwhere = ' AND ID NOT IN (' . implode(',', $done_posts) . ')';
|
||||||
(post_id, category_id)
|
else:
|
||||||
VALUES
|
$catwhere = '';
|
||||||
('$post->ID', '$post->post_category')
|
endif;
|
||||||
");
|
|
||||||
|
$allposts = $wpdb->get_results("SELECT ID, post_category FROM $tableposts WHERE post_category != '0' $catwhere");
|
||||||
|
if ($allposts) :
|
||||||
|
foreach ($allposts as $post) {
|
||||||
|
// Check to see if it's already been imported
|
||||||
|
$cat = $wpdb->get_row("SELECT * FROM $tablepost2cat WHERE post_id = $post->ID AND category_id = $post->post_category");
|
||||||
|
if (!$cat && 0 != $post->post_category) { // If there's no result
|
||||||
|
$wpdb->query("
|
||||||
|
INSERT INTO $tablepost2cat
|
||||||
|
(post_id, category_id)
|
||||||
|
VALUES
|
||||||
|
('$post->ID', '$post->post_category')
|
||||||
|
");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
endif;
|
||||||
}
|
}
|
||||||
|
|
||||||
function upgrade_101() {
|
function upgrade_101() {
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
$_wp_installing = 1;
|
$_wp_installing = 1;
|
||||||
if (!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.");
|
if (!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.");
|
||||||
require('../wp-config.php');
|
require('../wp-config.php');
|
||||||
|
timer_start();
|
||||||
require('upgrade-functions.php');
|
require('upgrade-functions.php');
|
||||||
|
|
||||||
$step = $_GET['step'];
|
$step = $_GET['step'];
|
||||||
@ -54,6 +55,15 @@ switch($step) {
|
|||||||
?>
|
?>
|
||||||
<h2>Step 1</h2>
|
<h2>Step 1</h2>
|
||||||
<p>There's actually only one step. So if you see this, you're done. <a href="../">Have fun</a>! </p>
|
<p>There's actually only one step. So if you see this, you're done. <a href="../">Have fun</a>! </p>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
<pre>
|
||||||
|
<?php echo $wpdb->num_queries; ?> queries
|
||||||
|
|
||||||
|
<?php timer_stop(1); ?> seconds
|
||||||
|
</pre>
|
||||||
|
-->
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user