Skip to content
Snippets Groups Projects
Commit 1441191d authored by hatznie's avatar hatznie Committed by vbouchet
Browse files

Issue #2831702 by hatznie, vbouchet, krina.addweb: Fatal error when creating new terms

parent 9b00422a
Branches
Tags 8.x-1.1
No related merge requests found
......@@ -67,9 +67,12 @@ function flat_taxonomy_taxonomy_term_presave(Term $term) {
// programmatical save (migration, services, ...).
$vocabulary = Vocabulary::load($term->getVocabularyId());
if ($vocabulary->getThirdPartySetting('flat_taxonomy', 'flat') == FLAT_TAXONOMY_FLAT && !empty($term->parent)) {
\Drupal::logger('flat_taxonomy')->warning('Illegal parent %parent_tid for the term %name as vocabulary is flat. Parent has been updated.', array('%parent_tid' => $term->parent, '%name' => $term->name));
drupal_set_message($this->t('Illegal parent %parent_tid for the term %name as vocabulary is flat. Parent has been updated.', array('%parent_tid' => $term->parent, '%name' => $term->name)), 'warning');
if (
$vocabulary->getThirdPartySetting('flat_taxonomy', 'flat') == FLAT_TAXONOMY_FLAT
&& !empty($term->parent->target_id)
) {
\Drupal::logger('flat_taxonomy')->warning('Illegal parent %parent_tid for the term %name as vocabulary is flat. Parent has been updated.', array('%parent_tid' => $term->parent->target_id, '%name' => $term->name->value));
drupal_set_message(t('Illegal parent %parent_tid for the term %name as vocabulary is flat. Parent has been updated.', array('%parent_tid' => $term->parent->target_id, '%name' => $term->name->value)), 'warning');
// @TODO: Update the term weight so it is ordered after the parent.
$term->parent = 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment