Make WordPress Core

Opened 12 years ago

Last modified 5 years ago

#20903 new defect (bug)

Exporter gets stuck in a loop a loop/break in the category hierarchy

Reported by: westi's profile westi Owned by: westi's profile westi
Milestone: Priority: normal
Severity: normal Version: 3.1
Component: Export Keywords: has-patch
Focuses: Cc:

Description

Ideally it should be impossible for a loop/incorrect parentage in a category hierarchy to exist.

But sometimes they do.

If one does exist then export_wp() gets stuck :(

It gets stuck in this code:

		// put categories in order with no child going before its parent
		while ( $cat = array_shift( $categories ) ) {
			if ( $cat->parent == 0 || isset( $cats[$cat->parent] ) )
				$cats[$cat->term_id] = $cat;
			else
				$categories[] = $cat;
		}

Similar to #20635 but different.

Attachments (2)

20903.diff (808 bytes) - added by westi 12 years ago.
Simple fix using term_exits to check that the parent of a term exists before adding to the array to try again later.
20903.2.diff (814 bytes) - added by westi 12 years ago.
Improved patch - term_exists only tests true ints as term_ids :(

Download all attachments as: .zip

Change History (6)

@westi
12 years ago

Simple fix using term_exits to check that the parent of a term exists before adding to the array to try again later.

#1 @duck_
12 years ago

Patch looks sensible.

#2 @westi
12 years ago

  • Version changed from 3.4 to 3.1

This uses to have a looping guard prior to [15961] so setting Version to 3.1

@westi
12 years ago

Improved patch - term_exists only tests true ints as term_ids :(

#3 @westi
12 years ago

Found a "fun" bug in my patch - I assumed that term_exists would use something like is_numeric to decide if I was giving it an ID instead of a slug but it uses is_int() and this code was failing to work correctly.

#4 @chriscct7
9 years ago

  • Keywords 3.5-early removed
Note: See TracTickets for help on using tickets.