From 2df408efdd08942365d6886747f58d67a9e17e60 Mon Sep 17 00:00:00 2001 From: saxmatt Date: Tue, 30 Dec 2003 19:54:09 +0000 Subject: [PATCH] New upgrade scripts and such. git-svn-id: http://svn.automattic.com/wordpress/trunk@668 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/upgrade-072-to-080.php | 321 -------------------------------- 1 file changed, 321 deletions(-) delete mode 100644 wp-admin/upgrade-072-to-080.php diff --git a/wp-admin/upgrade-072-to-080.php b/wp-admin/upgrade-072-to-080.php deleted file mode 100644 index 04ef7fa9f..000000000 --- a/wp-admin/upgrade-072-to-080.php +++ /dev/null @@ -1,321 +0,0 @@ - - - -WordPress › .72 to .80 Upgrade - - - -

WordPress

- -

This file seeks to upgrade you to the latest version of WordPress. If you are upgrading from any version other than .72, you should run the previous upgrade files to get everything up to date before running this.

-

If you’re all ready, let's go!

- -

Step 1

-

If it isn’t there already, let’s add fields new to this version.

-hide_errors(); -$wpdb->query("ALTER TABLE `$tableposts` ADD INDEX (`post_name`)"); -$wpdb->show_errors(); - -// Create ping status fields - -$query = "ALTER TABLE $tableposts ADD `to_ping` TEXT NOT NULL"; -maybe_add_column($tableposts, 'to_ping', $query); -$query = "ALTER TABLE $tableposts ADD `pinged` TEXT NOT NULL"; -maybe_add_column($tableposts, 'pinged', $query); - -// Create category_nicename field -$query = "ALTER TABLE `$tablecategories` ADD `category_nicename` VARCHAR(200) NOT NULL"; -maybe_add_column($tablecategories, 'category_nicename', $query); - -// Create index if it isn't there already, suppress errors if it is -$wpdb->hide_errors(); -$wpdb->query("ALTER TABLE `$tablecategories` ADD INDEX (`category_nicename`)"); -$wpdb->show_errors(); - -// Create category description field -$query = "ALTER TABLE `$tablecategories` ADD `category_description` TEXT NOT NULL"; -maybe_add_column($tablecategories, 'category_description', $query); - -// Create category parent field -$query = "ALTER TABLE `$tablecategories` ADD `category_parent` INT(4) NOT NULL"; -maybe_add_column($tablecategories, 'category_parent', $query); -?> -

Groovy.

-

Now let’s populate the new fields.

-

Working - get_results("SELECT ID, post_title, post_name FROM $tableposts"); - -foreach($posts as $post) { - if ('' == $post->post_name) { - $newtitle = sanitize_title($post->post_title); - $wpdb->query("UPDATE $tableposts SET post_name = '$newtitle' WHERE ID = $post->ID"); - } - echo ' .'; - flush(); -} - -$categories = $wpdb->get_results("SELECT cat_ID, cat_name, category_nicename FROM $tablecategories"); -foreach ($categories as $category) { - if ('' == $category->category_nicename) { - $newtitle = sanitize_title($category->cat_name); - $wpdb->query("UPDATE $tablecategories SET category_nicename = '$newtitle' WHERE cat_ID = $category->cat_ID"); - } - echo ' .'; - flush(); -} - -if (!$wpdb->get_var("SELECT option_name FROM $tableoptions WHERE option_name = 'permalink_structure'")) { // If it's not already there - $wpdb->query("INSERT INTO `$tableoptions` - (`option_id`, `blog_id`, `option_name`, `option_can_override`, `option_type`, `option_value`, `option_width`, `option_height`, `option_description`, `option_admin_level`) - VALUES - ('', '0', 'permalink_structure', 'Y', '3', '', '20', '8', 'How the permalinks for your site are constructed. See permalink options page for necessary mod_rewrite rules and more information.', '8');"); - } - -if (!$wpdb->get_var("SELECT option_name FROM $tableoptions WHERE option_name = 'gzipcompression'")) { // If it's not already there - $wpdb->query("INSERT INTO `$tableoptions` - (`option_id`, `blog_id`, `option_name`, `option_can_override`, `option_type`, `option_value`, `option_width`, `option_height`, `option_description`, `option_admin_level`) - VALUES - ('', '0', 'gzipcompression', 'Y', '2', '0', '20', '8', 'Whether your output should be gzipped or not. Enable this if you don’t already have mod_gzip running.', '8');"); - $optionid = $wpdb->get_var("SELECT option_id FROM $tableoptions WHERE option_name = 'gzipcompression'"); - $wpdb->query("INSERT INTO $tableoptiongroup_options - (group_id, option_id, seq) - VALUES - (2, $optionid, 5)"); - } -?> - Done with the name game. Now a little option action.

-

Now on to step 2.

- -

Step 2

-

Now we need to adjust some option data (don't worry this won't change any of your settings.)

-

Working -hide_errors(); // Turn this off for dev and we should probably just fix the queries anyway -// fix timezone diff range -$wpdb->query("UPDATE $tableoptionvalues SET optionvalue_max = 23 , optionvalue_min = -23 WHERE option_id = 51"); -echo ' .'; -flush(); -// fix upload users description -$wpdb->query("UPDATE $tableoptions SET option_description = '...or you may authorize only some users. enter their logins here, separated by spaces. if you leave this variable blank, all users who have the minimum level are authorized to upload. example: \'barbara anne george\'' WHERE option_id = 37"); -echo ' .'; -flush(); -// and file types -$wpdb->query("UPDATE $tableoptions SET option_description = 'accepted file types, separated by spaces. example: \'jpg gif png\'' WHERE option_id = 34"); -echo ' .'; -flush(); -// add link to php date format. this could be to a wordpress.org page in the future -$wpdb->query("UPDATE $tableoptions SET option_description = 'see help for format characters' WHERE option_id = 52"); -$wpdb->query("UPDATE $tableoptions SET option_description = 'see help for format characters' WHERE option_id = 53"); -echo ' .'; -flush(); -if (!$wpdb->get_var("SELECT option_id FROM $tableoptions WHERE option_name = 'hack_file'")) { - $wpdb->query("INSERT INTO `$tableoptions` - ( `option_id` , `blog_id` , `option_name` , `option_can_override` , `option_type` , `option_value` , `option_width` , `option_height` , `option_description` , `option_admin_level` ) - VALUES - ('', '0', 'hack_file', 'Y', '2', '0', '20', '8', 'Set this to true if you plan to use a hacks file. This is a place for you to store code hacks that won’t be overwritten when you upgrade. The file must be in your wordpress root and called my-hacks.php', '8')"); - $optionid = $wpdb->get_var("SELECT option_id FROM $tableoptions WHERE option_name = 'hack_file'"); - $wpdb->query("INSERT INTO $tableoptiongroup_options - (group_id, option_id, seq) - VALUES - (2, $optionid, 5)"); -} -?> - Done with the options updates. Now for a bit of comment action

-query("ALTER TABLE $tablecomments ADD INDEX (comment_approved)"); - } -} - -// Insert new option "comment_moderation" to settings -if (!$wpdb->get_var("SELECT option_id FROM $tableoptions WHERE option_name = 'comment_moderation'")) { - $wpdb->query("INSERT INTO $tableoptions - (option_id, blog_id, option_name, option_can_override, option_type, option_value, option_width, option_height, option_description, option_admin_level) - VALUES - ('0', '0', 'comment_moderation', 'Y', '5',' none', 20, 8, 'If enabled, comments will only be shown after they have been approved.', 8)"); -} - -// attach option to group "General blog settings" -if ($continue) { - $oid = $wpdb->get_var("SELECT option_id FROM $tableoptions WHERE option_name = 'comment_moderation'"); - $gid = $wpdb->get_var("SELECT group_id FROM $tableoptiongroups WHERE group_name = 'General blog settings'"); - - $seq = $wpdb->get_var("SELECT MAX(seq) FROM $tableoptiongroup_options WHERE group_id = '$gid'"); - - ++$seq; - - $wpdb->query("INSERT INTO $tableoptiongroup_options - (group_id, option_id, seq) - VALUES - ('$gid', '$oid', '$seq')"); -} - -// Insert option values for new option "comment_moderation" -if ($continue) { - $ddl = array(); - $ddl[] = "INSERT INTO $tableoptionvalues - (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) - VALUES - ('$oid', 'none', 'None', NULL, NULL, 1)"; - $ddl[] = "INSERT INTO $tableoptionvalues - (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) - VALUES - ('$oid', 'manual', 'Manual', NULL, NULL, 2)"; - $ddl[] = "INSERT INTO $tableoptionvalues - (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) - VALUES - ('$oid','auto', 'Automatic', NULL, NULL, 3)"; - - foreach ($ddl as $query) { - $wpdb->query($query); - } - -} - -// Insert new option "moderation_notify" to settings -if (!$wpdb->get_var("SELECT option_id FROM $tableoptions WHERE option_name = 'moderation_notify'")) { - $wpdb->query("INSERT INTO $tableoptions - (option_id, blog_id, option_name, option_can_override, option_type, option_value, option_width, option_height, option_description, option_admin_level) - VALUES - ('0', '0', 'moderation_notify' , 'Y', '2', '1', 20, 8, 'Set this to true if you want to be notified about new comments that wait for approval', 8)"); -} - -// attach option to group "General blog settings" -if ($continue) { - $oid = $wpdb->get_var("SELECT option_id FROM $tableoptions WHERE option_name = 'moderation_notify'"); - $gid = $wpdb->get_var("SELECT group_id FROM $tableoptiongroups WHERE group_name = 'General blog settings'"); - - $seq = $wpdb->get_var("SELECT MAX(seq) FROM $tableoptiongroup_options WHERE group_id = '$gid'"); - - ++$seq; - $wpdb->query("INSERT INTO $tableoptiongroup_options - (group_id, option_id, seq) - VALUES - ('$gid', '$oid', '$seq')"); -} -$wpdb->show_errors(); -?> -

Comment spammers should now watch out for you.

-

See, that didn’t hurt a bit (again). Now on to the next step.

- - -

Step 3

-

This is a most exciting step. We’re going to make it so each post can now have multiple categories. Hold on tight.

-Table created successfully.

'; - else echo '

New category table already created. Skipping.

'; -?> -

Now we need to transfer all your old categories into the new table.

-

Working... -get_results("SELECT ID, post_category FROM $tableposts"); - -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) { // If there's no result - $wpdb->query(" - INSERT INTO $tablepost2cat - (post_id, category_id) - VALUES - ($post->ID, $post->post_category) - "); - echo '. '; - flush(); - } -} - -// Going to leave the post table category field in for now. We can remove it in a future version. -?> - All done!

-

You are ready to rock ’n roll. Next step.

- - -

Step 4

-

This is the final step. We’re going to update the paths for the default links images that have moved.

-

If you do not still have the default settings it will not make any changes.

-query("UPDATE $tableoptions SET option_value = REPLACE(option_value, 'wp-links/links-images/', 'wp-images/links/') - WHERE option_name LIKE 'links_rating_image%' - AND option_value LIKE 'wp-links/links-images/%'"); -?> -

All done!

-

You are ready to rock ’n roll. Go crazy.

- - -