Make WordPress Core

Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#11354 closed defect (bug) (fixed)

WordPress Importer duplicates categories

Reported by: briancolinger's profile briancolinger Owned by:
Milestone: 3.1 Priority: normal
Severity: normal Version:
Component: Import Keywords: has-patch needs-unit-tests early
Focuses: Cc:


The WordPress importer duplicates categories.
This only seems to affect child categories.
To reproduce, get an export file that has parent and children categories. Run the importer multiple times with the same file.
View the category screen under Posts->Categories, you should see duplicated child categories.

I've included a patch for the process_categories() method that fixes this by explicitly checking if each category_exists().
I've included the same patch for process_tags() method. Tags do not duplicate, but wp_insert_term() is called without checking if the tag exists.

Attachments (1)

wordpress-importer.patch (1.3 KB) - added by briancolinger 14 years ago.
patch for process_categories() and process_tags() methods

Download all attachments as: .zip

Change History (9)

14 years ago

patch for process_categories() and process_tags() methods

#1 @markjaquith
14 years ago

  • Milestone changed from 2.9 to 3.0

Thanks for the patch, but this needs some time to be reviewed, and we're too close to 2.9.

#2 @scribu
14 years ago

  • Keywords has-patch added; duplicate categories wordpress importer removed

Related: #11080

#3 @westi
14 years ago

  • Cc westi added
  • Keywords needs-unit-tests added

When we fix this I would like to add to the set of unit tests for import that we already have.

#4 @demetris
14 years ago

Maybe related: #12813. (Importer multiplies category with non-ASCII name)

#5 @nacin
14 years ago

  • Keywords early added
  • Milestone changed from 3.0 to 3.1

Because of some extensive changes to the taxonomy API, is this still current as-is? I'm going to move this to 3.1 for the same reason it was moved to 3.0 -- we need some time to review it. Marking for early.

#6 @mhhenn
14 years ago

I am finding other problem regarding this subject. Seems that the parent-cat-slug is not transferred, it just look for parent-name. So if I have 3 main categories called "room1, room2 and room3" and each has a child-category with the same name but different slugs like "teacher1" and if every "teacher1" has a category-child with same name but different slug called "student1" when transferring the categories "student1" they are going to be located what seems to be randomly regardless the different slugs and not one "student" category for each "teacher1".


-teacher1(slug:room1-teacher1) -> student1 (slug:room1-teacher1-student1)

-teacher1(slug:room2-teacher1) -> student1 (slug:room2-teacher1-student1)

-teacher1(slug:room3-teacher1) -> student1 (slug:room3-teacher1-student1)

after importing the categories:

-teacher1(slug:room1-teacher1) -> student1 (slug:room1-teacher1-student1)
-teacher1(slug:room2-teacher1) -> student1 (slug:room2-teacher1-student1)
-teacher1(slug:room3-teacher1) -> student1 (slug:room3-teacher1-student1)

Empty -> Empty

Empty -> Empty

#7 @nacin
14 years ago

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

(In [15961]) Importer and exporter overhaul, mega props duck.

Exporter overhaul:

  • Add author information to export
  • Greater usage of slug identifiers
  • Don't export auto-drafts, spam comments, or edit lock/last meta keys
  • Inline documentation improvements
  • Remove filtering for now (@todo)
  • Bump WXR version to 1.1, but remain back compat in the importer

Importer overhaul (

  • Use an XML parser where available (SimpleXML, XML Parser)
  • Proper import support for navigation menus
  • Many bug fixes, specifically improvements to category and custom taxonomy handling
  • Better author/user mapping

Fixes #5447 #5460 #7400 #7973 #8471 #9237 #10319 #11118 #11144 #11354 #11574 #12685 #13364 #13394 #13453 #13454 #13627 #14306 #14442 #14524 #14750 #15055 #15091 #15108.

See #15197.

#8 @nacin
14 years ago

  • Milestone changed from Awaiting Triage to 3.1
Note: See TracTickets for help on using tickets.