Make WordPress Core

Opened 14 years ago

Closed 14 years ago

Last modified 13 years ago

#7320 closed defect (bug) (fixed)

wp_update() makes category names empty (v 2.6)

Reported by: rm53's profile rm53 Owned by:
Milestone: 2.6.1 Priority: normal
Severity: major Version: 2.6
Component: General Keywords:
Focuses: Cc:


After upgrading an old version (e.g. 2.0) to 2.6 all category names are empty, all slugs are -2 or -2-2 or longer sequences of "-2".
I think I found the bug in function upgrade_230()
(upgrade_230 is in /wp-admin/includes/upgrade.php)
after these lines:

	foreach ($categories as $category) {
		$term_id = (int) $category->cat_ID;
		$term_group = 0;

the variables $name, $slug and maybe others are NOT set,
but some lines later their content is used and written into mysql table as follows:

		$wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->terms (term_id, name, slug, term_group) VALUES 
		(%d, %s, %s, %d)", $term_id, $name, $slug, $term_group) );

the result is IMHO: these fields are empty in the database, see the numerous messages in the support forums about empty category names.

In the same function later on, for link cats the same code is repeated, but with the vars $name etc set correctly:

		foreach ( $link_cats as $category) {
			$cat_id = (int) $category->cat_id;
			$term_id = 0;
			$name = $wpdb->escape($category->cat_name);
			$slug = sanitize_title($name);
			$term_group = 0;

Change History (3)

#1 @ryan
14 years ago

Looks like [7645] broke this.

#2 @ryan
14 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [8350]) Restore fields removed in [7645]. Props rm53. fixes #7320 for trunk

#3 @ryan
14 years ago

(In [8351]) Restore fields removed in [7645]. Props rm53. fixes #7320 for 2.6

Note: See TracTickets for help on using tickets.