Make WordPress Core

Changeset 466


Ignore:
Timestamp:
10/25/2003 10:06:11 PM (22 years ago)
Author:
saxmatt
Message:

Add post_name column, populate column.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/upgrade-072-to-073.php

    r445 r466  
    11<?php
     2require_once('../wp-config.php');
     3require('wp-install-helper.php');
    24
    3 /* Just a placeholder for now, to be updated as features are added that require database changes. */
     5$step = $HTTP_GET_VARS['step'];
     6if (!$step) $step = 0;
     7if (!step) $step = 0;
     8?>
     9<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     10<html xmlns="http://www.w3.org/1999/xhtml">
     11<title>WordPress&rsaquo;.72 to .73 Upgrade</title>
     12<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
     13<style media="screen" type="text/css">
     14    body {
     15        font-family: Georgia, "Times New Roman", Times, serif;
     16        margin-left: 15%;
     17        margin-right: 15%;
     18    }
     19    #logo {
     20        margin: 0;
     21        padding: 0;
     22        background-image: url(http://wordpress.org/images/wordpress.gif);
     23        background-repeat: no-repeat;
     24        height: 72px;
     25        border-bottom: 4px solid #333;
     26    }
     27    #logo a {
     28        display: block;
     29        text-decoration: none;
     30        text-indent: -100em;
     31        height: 72px;
     32    }
     33    p {
     34        line-height: 140%;
     35    }
     36    </style>
     37</head><body>
     38<h1 id="logo"><a href="http://wordpress.org">WordPress</a></h1>
     39<?php
     40switch($step) {
    441
    5 ?>
     42    case 0:
     43?>
     44<p>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.</p>
     45<p>If you&#8217;re all ready, <a href="upgrade-072-to-073.php?step=1">let's go</a>! </p>
     46<?php
     47    break;
     48   
     49    case 1:
     50?>
     51<h1>Step 1</h1>
     52<p>If it isn't there already, let's add a field new to this version.</p>
     53<?php
     54// Create post_name field
     55$query = "ALTER TABLE `$tableposts` ADD `post_name` VARCHAR(200) NOT NULL";
     56maybe_add_column($tableposts, 'post_name', $query);
     57
     58// Create index if it isn't there already, suppress errors if it is
     59$wpdb->hide_errors();
     60$wpdb->query("ALTER TABLE `$tableposts` ADD INDEX (`post_name`)");
     61$wpdb->show_errors();
     62?>
     63<p><strong>Done.</strong></p>
     64<p>Now let's populate the new field.</p>
     65<p>Working
     66  <?php
     67// Get the title and ID of every post, post_name to check if it already has a value
     68$posts = $wpdb->get_results("SELECT ID, post_title, post_name FROM $tableposts");
     69
     70foreach($posts as $post) {
     71    if ('' == $post->post_name) {
     72        $newtitle = sanitize_title($post->post_title);
     73        $wpdb->query("UPDATE $tableposts SET post_name = '$newtitle' WHERE ID = $post->ID");
     74    }
     75    echo ' .';
     76    flush();
     77}
     78
     79?>
     80  <strong>Done.</strong> </p>
     81<p>See, that didn't hurt a bit. All done!</p>
     82<?php
     83    break;
     84}
     85?>
     86</body>
     87</html>
Note: See TracChangeset for help on using the changeset viewer.