WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 4 years ago

Last modified 4 years ago

#11354 closed defect (bug) (fixed)

WordPress Importer duplicates categories

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

Description

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 5 years ago.
patch for process_categories() and process_tags() methods

Download all attachments as: .zip

Change History (9)

@briancolinger5 years ago

patch for process_categories() and process_tags() methods

comment:1 @markjaquith5 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.

comment:2 @scribu5 years ago

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

Related: #11080

comment:3 @westi5 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.

comment:4 @demetris5 years ago

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

comment:5 @nacin5 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.

comment:6 @mhhenn4 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".

example:

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

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

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

after importing the categories:

room1
-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)

room2
Empty -> Empty

room3
Empty -> Empty


comment:7 @nacin4 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 (http://plugins.trac.wordpress.org/changeset/304249):

  • 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.

comment:8 @nacin4 years ago

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