Hello,

Regarding hook_update and hook_insert :

The existing check on the term parent is:

if (empty($term->parent)) {

But when the term doesn’t have a parent, the value of $term->parent is: array(‘0’ => ‘0’) so the check passes when it shouldn’t and the processing goes on.

If there is a parent, the value of $term->parent is: array('[Tid-parent]' => '[Tid-parent]’).

My proposal is to modify the existing check to be:

if (array_keys($term->parent) == array(0)) {

That would prevent the massive impact on performance while importing a lot of stand-alone terms.

DrDam

CommentFileSizeAuthor
shs-empty-condition.patch786 bytesDrDam
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

DrDam’s picture

Issue summary: View changes
stBorchert’s picture

Status: Active » Closed (won't fix)

Yes, empty() does not check for the parent being array(0 => 0) here.
But that's on purpose. A cache update with "parent = 0" (which equals to "no parent at all") is required.
If I would skip updating when you insert/update a term without parents, would not work anymore as it was intended to, because the top-level list of terms within the hierarchy would not be cached.