Index: tests/phpunit/tests/term.php
===================================================================
--- tests/phpunit/tests/term.php	(revision 29734)
+++ tests/phpunit/tests/term.php	(working copy)
@@ -702,4 +702,32 @@
 		$cat_id2 = $this->factory->category->create( array( 'parent' => $cat_id1 ) );
 		$this->assertWPError( $cat_id2 );
 	}
+
+	/**
+	 * @ticket 29614
+	 */
+	function test_orphan_category_update() {
+		$parent_cat_id1 = $this->factory->category->create();
+		$parent_cat_id2 = $this->factory->category->create();
+
+		$child_cat_id = $this->factory->category->create( array( 'parent' => $parent_cat_id1 ) );
+
+		wp_update_term( $child_cat_id, 'category', array( 'parent' => $parent_cat_id2 ) );
+
+		//Test if the parent term has changed
+		$child_cat_term = get_term( $child_cat_id, 'category' );
+		$this->assertEquals( $child_cat_term->parent, $parent_cat_id2 );
+
+		wp_delete_category( $parent_cat_id2 );
+		clean_term_cache( $child_cat_id, 'category' );
+
+		//Test if the parent is set to 0
+		$child_cat_term = get_term( $child_cat_id, 'category' );
+		$this->assertEquals( $child_cat_term->parent, 0 );
+
+		//Test for WP_Error when updating to a deleted parent
+		$cat_id2 = wp_update_term( $child_cat_id, 'category', array( 'parent' => $parent_cat_id2 ) );
+		$this->assertWPError( $cat_id2 );
+		
+	}
 }
Index: src/wp-includes/taxonomy.php
===================================================================
--- src/wp-includes/taxonomy.php	(revision 29734)
+++ src/wp-includes/taxonomy.php	(working copy)
@@ -2947,6 +2947,10 @@
 	if ( '' == trim($name) )
 		return new WP_Error('empty_term_name', __('A name is required for this term'));
 
+	if ( $parsed_args['parent'] > 0 && ! term_exists( (int) $parsed_args['parent'] ) ) {
+		return new WP_Error( 'missing_parent', __( 'Parent term does not exist.' ) );
+	}
+
 	$empty_slug = false;
 	if ( empty( $args['slug'] ) ) {
 		$empty_slug = true;
