Problem/Motivation

Hide the unpublished terms for the node form because the user does not have full permission for the taxonomy, the user can not save the node if he selects an unpublished term
Error: This entity (taxonomy_term: xxx) cannot be referenced.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Firass Ziedan created an issue. See original summary.

firass.ziedan’s picture

Status: Active » Needs review
StatusFileSize
new1.3 KB
firass.ziedan’s picture

StatusFileSize
new1.14 KB
jaydub’s picture

While I agree that the most straightforward way of doing this is by loading the Term entities in question, the current version of the module goes out of its way to NOT load full Term entities per the notes in _term_reference_tree_get_chidren():

function _term_reference_tree_get_children($tid, $vid) {
  // DO NOT LOAD TAXONOMY TERMS HERE.
  // Taxonomy terms take a lot of time and memory to load, and this can be
  // very bad on large vocabularies.  Instead, we load the term as necessary
  // in cases where it's needed (such as using tokens or when the locale
  // module is enabled).

Per that note and per keeping things slim if possible, I created another patch that accomplishes the same thing more or less without requiring the full Term entities to be loaded.

maacl’s picture

Version: 8.x-1.x-dev » 2.0.x-dev
Status: Needs review » Reviewed & tested by the community

Patch still applies, the extending the query looks good. Solved the problem for me.

vladimiraus made their first commit to this issue’s fork.

  • vladimiraus committed 8e2ffb81 on 2.0.x
    Issue #3195698: Hide the unpublished terms for node form
    
vladimiraus’s picture

Status: Reviewed & tested by the community » Fixed

Thanks, all.
Committed! 🧁

nicrodgers’s picture

Discovered this issue after updating to 2.0.2.
Unfortunately I don't think the change made here is correct. We shouldn't exclude unpublished terms, as the user may well have permission to view and use the unpublished term (the 'administer taxonomy' permission).

I've raised https://www.drupal.org/project/term_reference_tree/issues/3497889

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.