Changeset 3517 for trunk/wp-admin/upgrade-functions.php
- Timestamp:
- 02/12/2006 07:53:23 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/upgrade-functions.php
r3514 r3517 21 21 $wp_current_db_version = 2541; 22 22 } 23 23 24 24 populate_options(); 25 25 … … 30 30 upgrade_130(); 31 31 } 32 32 33 33 if ( $wp_current_db_version < 3308 ) 34 34 upgrade_160(); … … 38 38 39 39 $wp_rewrite->flush_rules(); 40 40 41 41 update_option('db_version', $wp_db_version); 42 42 } … … 55 55 } 56 56 } 57 57 58 58 $categories = $wpdb->get_results("SELECT cat_ID, cat_name, category_nicename FROM $wpdb->categories"); 59 59 foreach ($categories as $category) { … … 78 78 $catwhere = ''; 79 79 endif; 80 80 81 81 $allposts = $wpdb->get_results("SELECT ID, post_category FROM $wpdb->posts WHERE post_category != '0' $catwhere"); 82 82 if ($allposts) : … … 112 112 function upgrade_110() { 113 113 global $wpdb; 114 114 115 115 // Set user_nicename. 116 116 $users = $wpdb->get_results("SELECT ID, user_nickname, user_nicename FROM $wpdb->users"); … … 281 281 $wpdb->query("UPDATE $wpdb->users SET display_name = '$id' WHERE ID = '$user->ID'"); 282 282 endif; 283 283 284 284 // FIXME: RESET_CAPS is temporary code to reset roles and caps if flag is set. 285 285 $caps = get_usermeta( $user->ID, $table_prefix . 'capabilities'); … … 289 289 update_usermeta( $user->ID, $table_prefix . 'capabilities', array($role => true) ); 290 290 } 291 291 292 292 endforeach; 293 293 $old_user_fields = array( 'user_firstname', 'user_lastname', 'user_icq', 'user_aim', 'user_msn', 'user_yim', 'user_idmode', 'user_ip', 'user_domain', 'user_browser', 'user_description', 'user_nickname', 'user_level' ); … … 296 296 $wpdb->query("ALTER TABLE $wpdb->users DROP $old"); 297 297 $wpdb->show_errors(); 298 298 299 299 if ( 0 == $wpdb->get_var("SELECT SUM(category_count) FROM $wpdb->categories") ) { // Create counts 300 300 $categories = $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories"); … … 322 322 post_type = '' 323 323 WHERE ID = $object->ID"); 324 324 325 325 $meta = get_post_meta($object->ID, 'imagedata', true); 326 326 if ( ! empty($meta['file']) ) … … 336 336 // Update status and type. 337 337 $posts = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts"); 338 338 339 339 if ( ! empty($posts) ) foreach ($posts as $post) { 340 340 $status = $post->post_status; … … 346 346 } else if ( 'attachment' == $status ) { 347 347 $status = 'inherit'; 348 $type = 'attachment'; 348 $type = 'attachment'; 349 349 } 350 350 351 351 $wpdb->query("UPDATE $wpdb->posts SET post_status = '$status', post_type = '$type' WHERE ID = '$post->ID'"); 352 352 } 353 353 } 354 354 355 355 if ( $wp_current_db_version < 3513 ) { 356 populate_roles_210(); 356 populate_roles_210(); 357 357 } 358 358 } … … 478 478 function dbDelta($queries, $execute = true) { 479 479 global $wpdb; 480 480 481 481 // Seperate individual queries into an array 482 482 if( !is_array($queries) ) { … … 484 484 if('' == $queries[count($queries) - 1]) array_pop($queries); 485 485 } 486 486 487 487 $cqueries = array(); // Creation Queries 488 488 $iqueries = array(); // Insertion Queries 489 489 $for_update = array(); 490 490 491 491 // Create a tablename index for an array ($cqueries) of queries 492 492 foreach($queries as $qry) { … … 507 507 // Unrecognized query type 508 508 } 509 } 509 } 510 510 511 511 // Check to see which tables and fields exist … … 526 526 527 527 //echo "<hr/><pre>\n".print_r(strtolower($table), true).":\n".print_r($cqueries, true)."</pre><hr/>"; 528 528 529 529 // For every field line specified in the query 530 530 foreach($flds as $fld) { … … 532 532 preg_match("|^([^ ]*)|", trim($fld), $fvals); 533 533 $fieldname = $fvals[1]; 534 534 535 535 // Verify the found field name 536 536 $validfield = true; … … 548 548 } 549 549 $fld = trim($fld); 550 550 551 551 // If it's a valid field, add it to the field array 552 552 if($validfield) { … … 554 554 } 555 555 } 556 556 557 557 // Fetch the table column structure from the database 558 558 $tablefields = $wpdb->get_results("DESCRIBE {$table};"); 559 559 560 560 // For every field in the table 561 foreach($tablefields as $tablefield) { 561 foreach($tablefields as $tablefield) { 562 562 // If the table field exists in the field array... 563 563 if(array_key_exists(strtolower($tablefield->Field), $cfields)) { … … 572 572 $for_update[$table.'.'.$tablefield->Field] = "Changed type of {$table}.{$tablefield->Field} from {$tablefield->Type} to {$fieldtype}"; 573 573 } 574 574 575 575 // Get the default value from the array 576 576 //echo "{$cfields[strtolower($tablefield->Field)]}<br>"; … … 599 599 $for_update[$table.'.'.$fieldname] = 'Added column '.$table.'.'.$fieldname; 600 600 } 601 601 602 602 // Index stuff goes here 603 603 // Fetch the table index structure from the database 604 604 $tableindices = $wpdb->get_results("SHOW INDEX FROM {$table};"); 605 605 606 606 if($tableindices) { 607 607 // Clear the index array … … 632 632 $index_columns = ''; 633 633 // For each column in the index 634 foreach($index_data['columns'] as $column_data) { 634 foreach($index_data['columns'] as $column_data) { 635 635 if($index_columns != '') $index_columns .= ','; 636 636 // Add the field to the column list string
Note: See TracChangeset
for help on using the changeset viewer.