Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A PHP notice is generated when distributing child terms without parents #219

Open
jeremyfelt opened this issue Oct 5, 2018 · 2 comments
Labels
type:enhancement New feature or request.
Milestone

Comments

@jeremyfelt
Copy link
Contributor

In its current state Distributor results in a PHP notice when you attempt to assign a child term from a hierarchy where the parent term does not yet exist on the other site and when that parent term is also not selected for distribution.

if ( ! empty( $term_array['parent'] ) ) {
wp_update_term(
$term_id_mapping[ $term_array['term_id'] ],
$taxonomy,
[
'parent' => $term_id_mapping[ $term_array['parent'] ],
]
);
}

The code assumes the parent exists as an already mapped term when it attempts to update the latest term. This is probably okay when both the parent and child have been selected.

For my specific case, I'm less concerned about the relationship on the distributed content, so I would choose to skip dt_update_term_hierarchy for this taxonomy. I'm going to open a pull request suggesting that $taxonomy be provided to that filter so that this can be enabled/disabled based on that value rather than as a blanket decision.

It does seem that handling of the term hierarchy is somewhat of a larger problem than that.

@jeremyfelt
Copy link
Contributor Author

It would be helpful to know the actual error. :)

PHP message: PHP Notice: Undefined offset: 1102 in /Users/jeremyfelt/Development/cfemedia/wp-content/plugins/distributor/includes/utils.php on line 399

In this case, 1102 is the term ID of the parent that exists on the main site, but not the distributed site. It doesn't exist in the $term_id_mapping array.

@helen helen modified the milestones: 1.3.2, 1.4 Oct 16, 2018
arsendovlatyan added a commit to NovemBit/distributor that referenced this issue Nov 28, 2018
…p#219

also, remove parent them, if it's removed in source
@arsendovlatyan
Copy link
Contributor

When parent is not mapped, but we are trying to update term parent in destination, we may damage existing hierarchy and bring secondary level terms to root level.

Please check #262, where this issue is solved.

@jeffpaul jeffpaul added the type:enhancement New feature or request. label Jun 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:enhancement New feature or request.
Projects
None yet
Development

No branches or pull requests

5 participants