Ticket #7320 (closed defect (bug): fixed)

Opened 4 years ago

Last modified 2 years ago

wp_update() makes category names empty (v 2.6)

Reported by: rm53 Owned by: anonymous
Priority: normal Milestone: 2.6.1
Component: General Version: 2.6
Severity: major Keywords:
Cc:

Description

Problem: 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". Bug: 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

comment:1   ryan4 years ago

Looks like [7645] broke this.

comment:2   ryan4 years ago

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

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

comment:3   ryan4 years ago

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

Note: See TracTickets for help on using tickets.